Dynamically update variables in a link
- Started
- Last post
- 15 Responses
- effour
Hi,
I need to update a some variables in a link:
home.php?cat=varaible1&f_color=v...Basically I want to have 3 dropdowns for variable1,variable2,variable3 and a go button.
It would then update my link and go to the page...
Any links or help would be appreciated!
Thx.
- skt0
telling us what programming language that you are trying to do this in would help.
- effour0
good point...
php or ajax
- welded0
Assuming by button you mean a proper form control, can't you just submit the form via get?
- effour0
not sure if i can submit the form via get...don't know where to even start...
- welded0
But we're talking a HTML form though, right?
- welded0
Not sure if this is a good tutorial or not, but it looks like it covers the basics:
http://www.javascript-coder.com/…
- effour0
Thanks y'all....the form with the action=home.php did the trick!
- effour0
one more thing:
how can i use a div to pass a form value?
What kind of onclick="javascript:" would pass tat value to the form?
is it possible?
Thanks...
- acescence0
create a hidden field in the form with a default value, then put an anchor tag set to display:block in a div and trigger a javascript function that changes the value of the hidden field, like document.myform.fieldname.value = newvalue
- effour0
It's a shot in the dark and I missed huge....
<a href="#" onclick="javascript:(document.myform.f_color.value = BROWN)">BROWN</a>Help me out with the correct code for an href to pass a form value?
Thanks!
- acescence0
<a href="#" onclick="document.myform.myfield.value='brown';return false">brown</a>
- welded0
The onclick need not be on an anchor necessarily, but if that works for you then go for it. Also, you don't put 'javascript:' in the onclick attribute because those (onmouseover, et al) are only for javascripts anyway so no need to declare it. Anyway, you're pretty close:
<a href="#" onclick="document.getElementById('your_hidden_field').value = 'brown'; return false;">BROWN</a>
<input id="your_hidden_field" name="f_color" value="" />Something along those lines will work.
- effour0
thanks! it works!
- DrBombay0
This thread is an incredible success.