www.webdeveloper.com
Results 1 to 7 of 7

Thread: read <h3> and input?

  1. #1
    Join Date
    Jun 2008
    Posts
    6

    read <h3> and input?

    i was wondering if its possible to read <h3>THIS TEXT IS RANDOM</h3> and put into a text field eg <input type="text" name="nation" value="" /> and
    submit?


    cheers

  2. #2
    Join Date
    Aug 2007
    Posts
    3,767
    document.getElementsByName("nation")[0].value = document.getElementsByTagName("h3")[0].innerHTML;

    If you want to submit the form as well, use
    document.FORMNAME.submit();
    Great wit and madness are near allied, and fine a line their bounds divide.

  3. #3
    Join Date
    Jun 2008
    Posts
    6
    ah thanks that worked but now the code has changed for the text its all spans damn guess there is no way to find the correct one for each letter and input

    maybe there is a way to find the text using the div id? i have this <div id="app8743457343_content"
    Last edited by sleepysonic; 08-11-2008 at 08:34 AM.

  4. #4
    Join Date
    Jun 2008
    Posts
    6
    this is the source
    <div id="app8743457343_content" fbcontext="2b977181d850">

    <span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span>R</span>
    <span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span>O</span>
    <span></span><span></span><span></span><span></span><span>M</span><span></span><span></span><span></span><span>E</span><span></span><span></span><span></span>

    the span were the text is also random so this is probably difficult to code
    Last edited by sleepysonic; 08-11-2008 at 09:12 AM.

  5. #5
    Join Date
    May 2005
    Location
    Dirty Jersey
    Posts
    1,402
    Code:
    	div = document.getElementById("app8743457343_content")
    
    	newValue = ""
    
    	for(x = 0; x < div.children.length; x++)
    		if(div.children[x].childNodes.length != 0)
    			newValue += div.children[x].childNodes[0].nodeValue
    
    	document.getElementsByName("nation")[0].value = newValue

    1. If you reply to my post, and your reply would then appear directly beneath my post, DON'T QUOTE MY ENTIRE POST!!! IT'S REDUNTANT!!! IT'S ASININE!!!! IT'S REDUNDANTLY ASININE!!!!! DON'T DO IT!!!!
    2. jQuery extends the functionality of JavaScript. If you don't know JavaScript, give up on that jQuery script and learn JavaScript. You'll save yourself a lot of frustration, I promise.
    3. Use the [code][/code] tags. Otherwise, you may be left wondering why no one responded to your eyesore of a thread.


  6. #6
    Join Date
    Jun 2008
    Posts
    6
    i tried this code and it didnt do anything

  7. #7
    Join Date
    May 2005
    Location
    Dirty Jersey
    Posts
    1,402
    post what you tried. there is a 100% likelyhood you implemented it wrong

    1. If you reply to my post, and your reply would then appear directly beneath my post, DON'T QUOTE MY ENTIRE POST!!! IT'S REDUNTANT!!! IT'S ASININE!!!! IT'S REDUNDANTLY ASININE!!!!! DON'T DO IT!!!!
    2. jQuery extends the functionality of JavaScript. If you don't know JavaScript, give up on that jQuery script and learn JavaScript. You'll save yourself a lot of frustration, I promise.
    3. Use the [code][/code] tags. Otherwise, you may be left wondering why no one responded to your eyesore of a thread.


Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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



Recent Articles