Click to See Complete Forum and Search --> : Move value to action


LordShryku
12-05-2002, 11:54 AM
Hi, I'm really new to JS, so this might be real easy, I just don't know. I have a form that I want to be able to move the value of an input field to a portion of a link. Something like this...

<input type="text" name="a">

<a href="http://www.something.com?a=valueHere ">

Thanks in advance :)

gil davis
12-05-2002, 02:28 PM
<input type="text" name="a">
<a href="http://www.something.com?a=valueHere ">

Does it have to be JavaScript and a link? A standard HTML form will do that at no charge.

<form action="http://www.something.com">
<input type="text" name="a"><br>
<input type="submit">
</form>

If you insist on a link:

<form onSubmit="return false" name="f1">
<input type="text" name="a">
<input type="submit">
</form>
...
<a href="http://www.something.com" onClick="location.href=this.href+'?a='+document.f1.a.value;return false">Click</a>

LordShryku
12-05-2002, 02:54 PM
Well, here's the thing. This link leads to a pdf that is generated through PHP based upon that variable. I need to try to find a way to present the user with an option
1) View the document through the browser, and
2) Download the document

I was hoping to do like an onblur from the text field to add thois variable to the link...this way they could right click, Save As if they wanted to download it, and left click it if they wanted to view it...

gil davis
12-05-2002, 03:50 PM
Unless you need to support NS 4 or IE 4, you can use this:

<form>
<input type="text" size="20"
onBlur="document.getElementById('l1').innerHTML='<a href='http://www.something.com?a='+this.value+'><\/a>'">
</form>
...
<span id="l1"></span>

You can put a default value in tbe SPAN tag if you like.