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 12 of 12
  1. #1
    New to the CF scene
    Join Date
    Dec 2004
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    output box value help...

    I need to get the javascript code below...

    <!-- Beginning of Javascript code -->
    <script type="text/javascript">
    document.write(keyword);
    </script>
    <!-- End of Javascript code -->


    To appear in the output box for the... value=""

    <input type="text" name="q" size="31" maxlength="255" value=""></input>


    Thanks, John

  • #2
    Senior Coder
    Join Date
    Jul 2004
    Location
    New Zealand
    Posts
    1,315
    Thanks
    0
    Thanked 2 Times in 2 Posts
    Code:
    <script type="text/javascript">
    	document.getElementById("q").value = keyword;
    </script> 
    
    <input id="q" name="q" type="text" size="31" maxlength="255" value="">

  • #3
    Supreme Master coder! Philip M's Avatar
    Join Date
    Jun 2002
    Location
    London, England
    Posts
    18,015
    Thanks
    203
    Thanked 2,538 Times in 2,516 Posts
    Too late! Hemebond has dealt with it.

  • #4
    New to the CF scene
    Join Date
    Dec 2004
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thanks Hemebond, but I can't get it to do what I want.

    Here's a basic keyword example of what I have now:

    Code:
    <html>
    <head>
    <script type="text/javascript" src = "dynamic.js"></script>
    </head>
    
    <body>
    
    <script type="text/javascript">
    document.write(keyword);
    </script> 
    
    </body>
    </html>
    I need the resulting keyword in the body tags above to
    somehow be put inside the text box below when the
    page is loaded.
    Code:
    <body>
    
    <input type="text" name="q" size="31" maxlength="255" value=""></input>
    <input type="submit" name="sa" value="Search"></input>
    
    </body>
    Thanks, John

  • #5
    teh Moderatorinator
    Join Date
    Sep 2004
    Location
    USA
    Posts
    2,472
    Thanks
    4
    Thanked 40 Times in 40 Posts
    did you use an onLoad event handler?

  • #6
    New to the CF scene
    Join Date
    Dec 2004
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Hi Brando,

    I can get the "keyword" to load fine outside of the box,
    in a HTML document. But I don't know how to get it
    inside the search box.

  • #7
    teh Moderatorinator
    Join Date
    Sep 2004
    Location
    USA
    Posts
    2,472
    Thanks
    4
    Thanked 40 Times in 40 Posts
    I'm still not sure if i understand correctly...
    Code:
    <body onload="document.forms[0].q.value= keyword;">
    <input type="text" name="q" size="31" maxlength="255" value=""></input>
    <input type="submit" name="sa" value="Search"></input>
    </body>

  • #8
    Regular Coder
    Join Date
    Jan 2004
    Location
    Port Huron, MI, U.S.A.
    Posts
    280
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Make it so it calls the func onload so the box has loaded when the script is called.
    Ex.:
    Code:
    function Doit()
    {
    ~.~=keyWord
    }
    window.onload=Doit
    EDIT:
    Oops, someone beat me to it.
    Oh, was I supposed to put something here? ........

  • #9
    New to the CF scene
    Join Date
    Dec 2004
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I need the search box filled with text from the
    peviously searched page. The text/keyword
    shows up on the new page fine. But I need
    it to be inside the search box, ready to be
    searched again when the search button
    is clicked.

    Thanks, John

  • #10
    Senior Coder
    Join Date
    Jul 2004
    Location
    New Zealand
    Posts
    1,315
    Thanks
    0
    Thanked 2 Times in 2 Posts
    Look at my code. Look very, very hard.

  • #11
    New to the CF scene
    Join Date
    Dec 2004
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Hi hemebond, I don't know much about javascript.
    Can you please explain what I need to look at in
    your code and what I need to change in mine to
    make it work.

    Thanks, John

  • #12
    Senior Coder
    Join Date
    Jul 2004
    Location
    New Zealand
    Posts
    1,315
    Thanks
    0
    Thanked 2 Times in 2 Posts
    Using document.getElementById returns a handle to a specific element with that id attribute.

    Form elements have a value property you can access through Javascript. What I have done is set this property to the value of your variable keyword.

    Take my code, and put the script block after the element.


  •  

    Posting Permissions

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