Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums JavaScript Breaking apart text

  • This topic is empty.
Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • #25358
    BigBrotherBiggs
    Participant

    G-day everyone,

    I have a challenge for anyone interested.

    I have a system that will post announcements stored in a database.

    I then have tags that I can insert into HTML to indicate where I want that code inserted. I then have two layouts I can create using HTML and these tags… a list layout and a detail layout.

    One of the tags renders the date of the announcement in the following format 20-Jul-2009

    What I am wanting to do is strip away the Day and the Month from the rendered text and insert the day in one place and the month in another… so the browser renders the following…

    [attachment=0]Picture 1.png[/attachment]

    This code renders what you see above

    Code:
    20-Jul-2009

    20

    Jul

    New Product Released

    You can now write about your latest news, announcements and much m.

    The CSS for these classes are

    Code:
    .datebox {
    padding-left: 0px;
    padding-bottom: 8px;
    padding-right: 0px;
    padding-top: 0px;
    margin-right: 10px;
    height: 42px;
    width: 40px;
    background-image: url(../images/TF/datebox.png);
    background-repeat: no-repeat;
    }
    .day {
    margin: 0px;
    padding-left: 0px;
    padding-bottom: 0px;
    padding-right: 0px;
    text-align: center;
    color: #e2e2e2;
    font-size: 20px;
    font-weight: bold;
    }
    .month {
    margin-left: 0px;
    margin-bottom: 0px;
    margin-right: 0px;
    margin-top: -8px;
    padding: 0px;
    color: black;
    text-align: center;
    font-size: 12px;
    font-weight: bold;
    text-transform: uppercase;
    background-image: url(/images/TF/);
    }
    .hide {
    visibility: hidden;
    }

    Any ideas as to how I can copy the day and months from the hidden text into the new places?

    #60225
    BigBrotherBiggs
    Participant

    So i have been reading up on jQuery a bit more… to be honest it is hard for my mind to wrap around…

    if I put a string of text like such…

    Code:

    20-Jul-2009

    Can I create some jQuery code that will virtually erase everything after the 20?

    Then if I had that same string of text but displayed as such…

    Code:

    20-Jul-2009

    Can I have another line of script that will erase the 20- and the -2009?

    I was looking at http://docs.jquery.com/Manipulation where it talks about Changing and Removing Content and am wondering if i am in the right area or even on the right track?
    Thank you in advance for any help on the matter

    #60226
    TheDoc
    Member

    You can parse it using PHP and split each item with an array. Any reason for sticking with jquery?

    [edit]And that was my 500th post! Hurrah![/edit]

    #60218
    BigBrotherBiggs
    Participant

    I am just a designer and am learning JavaScript. I find jQuery the easiest to understand yet it is still a challenge for me. The CMS I am using won’t allow php on the servers because I think php is what runs it even thought most evidence of php is not evident.

    #60221
    eXo
    Member

    So i have this right you already can print the date with the following format 20-Jul-2009

    "BigBrotherBiggs" wrote:
    One of the tags renders the date of the announcement in the following format 20-Jul-2009

    is that is true then just use a diffrent date format
    http://blog.stevenlevithan.com/archives … ent-page-3

    #60322
    TheDoc
    Member

    To clarify, you have a database and there are three fields for each item, "Title" + "Date" + "Description".

    You are pulling that information from the database using some form of javascript.

    The problem is that you need to split the "Date" field into three distinct pieces, and you are having trouble accomplishing this using JS and/or JQuery.

    Is this all correct?

    #60393
    BigBrotherBiggs
    Participant

    I am using a CMS called Business Catalyst. it is great for guys like me that have a hard time working with php.

    When i create an announcement in the announcement module. i enter a date by picking it from a date picker (much like a mini calendar)

    then i tell the system where i want that Date to be displayed. the system tag I sue for this is

    Code:
    {tag_postdate}

    When the page is rendered in a browser it shows 20-Jul-2009 or what ever date was entered.

    All I want to do is take that tag ans strip away the unwanted text. In one case i just want the day and in another case i just want the month. the year is not important to me.

    i had some help from a user here who was able to pull some numbers out of a tag and insert it into a new field using jQuery. I am not sure how he did it.

Viewing 7 posts - 1 through 7 (of 7 total)
  • The forum ‘JavaScript’ is closed to new topics and replies.