Page 1 of 1

link with dynamic value

Posted: Thu Nov 24, 2005 10:13 pm
by shiznatix
i have a link but i want to add a value on to it with javascript with a onclick event. heres the idea

Code: Select all

<input type="text" name="other" size="3">

<a href="?go=b_funk&other=">Click ME!</a>
when you click that link, i want the value of the text box to be put into the end of the link so the get value would be the value that was in the text box.

how would i go about doing this? don't tell me there are so many other better ways to do somtin like this because i am struggling to fix these problems in this project i got in at the very end and this is the only real way to do this.

Posted: Thu Nov 24, 2005 10:19 pm
by josh
make a javascript function that takes the base URL and the string to append to it as params

Code: Select all

function jump2url (base, append) {
   window.location=base+append;
}
not tested but that's the general idea

Posted: Fri Nov 25, 2005 12:28 am
by n00b Saibot
n00b Saibot to rescue :wink:

Code: Select all

<form name="frm">
<input type="text" name="other" size="3">
</form>

<a href="?go=b_funk&other=" onclick="this.href = this.href.substr(0, 17) + document.frm.other.value">Click ME!</a>

Posted: Fri Nov 25, 2005 12:52 am
by shiznatix
many thanks. works just fine