...

View Full Version : output box value help...



2Bumz
12-08-2004, 10:01 PM
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

hemebond
12-08-2004, 10:15 PM
<script type="text/javascript">
document.getElementById("q").value = keyword;
</script>

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

Philip M
12-08-2004, 10:16 PM
Too late! Hemebond has dealt with it.

2Bumz
12-09-2004, 02:01 AM
Thanks Hemebond, but I can't get it to do what I want.

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



<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.


<body>

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

</body>

Thanks, John

Brandoe85
12-09-2004, 02:20 AM
did you use an onLoad event handler?

2Bumz
12-09-2004, 02:34 AM
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.

Brandoe85
12-09-2004, 02:41 AM
I'm still not sure if i understand correctly...
<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>

Bobo
12-09-2004, 02:42 AM
Make it so it calls the func onload so the box has loaded when the script is called.
Ex.:

function Doit()
{
~.~=keyWord
}
window.onload=Doit

EDIT:
Oops, someone beat me to it.

2Bumz
12-09-2004, 03:04 AM
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

hemebond
12-09-2004, 03:27 AM
Look at my code. Look very, very hard.

2Bumz
12-09-2004, 04:41 AM
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

hemebond
12-09-2004, 07:31 AM
Using document.getElementById (http://www.mozilla.org/docs/dom/domref/dom_doc_ref48.html#1025944) 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.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum