Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5
  1. #1
    New to the CF scene
    Join Date
    Apr 2005
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    word replacement in a paragraph

    I would like to build a page whose top part has about 4 text fields, and a button "convert".

    The lower part of the same page has a paragraph of text which has 4 words in different places that needs to be replaced with whatever is filled in the above text fields, by clicking the "Convert" button.

    I'd like to stay on the same page and this action to happen when I click the button.

    Any help, how to achieve this?

    Thanks.

  • #2
    Senior Coder
    Join Date
    Jul 2004
    Location
    New Zealand
    Posts
    1,315
    Thanks
    0
    Thanked 2 Times in 2 Posts
    Quote Originally Posted by jdk2005
    Any help, how to achieve this?
    With Javascript. Text nodes. String replace method. Easy.

    http://www.mozilla.org/docs/dom/domref/
    Forget style. Code to semantics. Seperate style from structure, and structure from behaviour.
    I code to specs, and test only in Firefox (unless stated otherwise).

  • #3
    New to the CF scene
    Join Date
    Apr 2005
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I read through all of it, but couldn't quite figure it out from the examples. Am new to javascript, and would appreciate if someone could through a sample code or something.

    Guess I'm stuck to figure out how to have two paragraphs in continuation with different IDs. e.g.

    <p align="center" id="testPara1">Hello</p>

    <p align="center" id="testPara2">How are you</p>.

    I want them to appear as: Hello. How are you. Rather than

    Hello

    How are you.


    ***********
    That way I can probably be able to change different words with in the same paragraph, using different Ids for the nodes.

    Any help is appreciated.
    Thanks.
    Last edited by jdk2005; 04-18-2005 at 05:13 PM.

  • #4
    New to the CF scene
    Join Date
    Apr 2005
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts
    still looking for a lil help here.....

  • #5
    Senior Coder A1ien51's Avatar
    Join Date
    Jun 2002
    Location
    Between DC and Baltimore In a Cave
    Posts
    2,717
    Thanks
    1
    Thanked 94 Times in 88 Posts
    You want to use spans and not paragraph tags. paragraph tags are meant to have a page break. spans will not have a page break.

    Eric
    Tech Author [Ajax In Action, JavaScript: Visual Blueprint]


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •