Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Onclick should pass parameter 1

Status
Not open for further replies.

JeroenB

Programmer
Apr 8, 2001
93
BE
Hi all,

I would like to do the following; hope someone can help me out. I have an input field in a webpage in which I can enter a variable (name="VAR").
Now, by clicking on a href link (not a button!), I would like to pass this variable (together with some fixed parameters) to a host. So the complete GET string should be:
Can someone please complete/modify the values that I need to put in the attributes of the <a> element? Do I need additional scripts?

...
<input type=&quot;text&quot; name=&quot;VAR&quot; size=&quot;8&quot;>
...
<a href=&quot; onclick=&quot;???&quot;>
...

Thanks in advance
jeroen
 
Have a look at this example and see if it helps you.
Code:
<script type=&quot;text/javascript&quot;>

function buildURL( obj, str ) {

	obj.href = obj.href + &quot;&&quot; + str + &quot;=&quot; + document.getElementById( str ).value;
}

</script>

	

<input type=&quot;text&quot; name=&quot;VAR&quot; id=&quot;VAR&quot; size=&quot;8&quot; />

<a href=&quot;[URL unfurl="true"]http://foo:7070?par-1=value-1&par-2=value-2&quot;;[/URL] onclick=&quot;buildURL( this, 'VAR' );&quot;>Test</a>

HTH.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top