Gossamer Forum
Home : General : Perl Programming :

Changing two values with one pull-down in a form?

Quote Reply
Changing two values with one pull-down in a form?
Hi,

any hint how i could change to values with one pull-down-menu in a html-form?

For example: If anyone chooses one value of a pull-down-menu this value is saved and additionally a second value (hidden) should be changed ...

Thanks for hints!


Quote Reply
Re: Changing two values with one pull-down in a form? In reply to
You sound like you need Javascript. This isn't really the best forum to ask these type of questions as many of us wouldn't be able to help you as much as we would like to. How about trying http://www.htmlforums.com.

Hope you find the answer

Andy

http://www.ace-installer.com
webmaster@Ace-installer.com
Quote Reply
Re: Changing two values with one pull-down in a form? In reply to
you need to read up on the DOM for the different browsers.
luckily, form handling this simple is pretty generic.
setup a function to handle the field changes you need and call the function from an onChange event in your select tag.

-g


s/(\d{2})/chr($1)/ge + print if $_ = '8284703280698276687967';
Quote Reply
Re: Changing two values with one pull-down in a form? In reply to
Hi GClemmons,

could you post a simple sample?

Thanks


Quote Reply
Re: Changing two values with one pull-down in a form? In reply to
Code:
<script>
function changeVal(val) {
document.yourForm.yourHiddenField.value = val;
}
</script>
...
<form name="yourForm" action="your.cgi" method="post">
<input type="hidden" name="yourHiddenField" value="0">
<select name="yourSelect" onchange="changeVal('VALUE HERE');">
<option value="1">one</option>
<option value="2">two</option>
...
</select>
</form>
...
if you wanted to change the value of the hidden field to the value of the selected field you can just make the function have no args passed and grab the current value of the select box and assign it to the hidden value.

-g


s/(\d{2})/chr($1)/ge + print if $_ = '8284703280698276687967';
Quote Reply
Re: Changing two values with one pull-down in a form? In reply to
Thanks for your hint - is it possible to change the hidden variable to a different value than the one from the pulldown?



Quote Reply
Re: Changing two values with one pull-down in a form? In reply to
you can change it to anything you have the value of.
what are you wanting the value to be changed to?

-g



s/(\d{2})/chr($1)/ge + print if $_ = '8284703280698276687967';
Quote Reply
Re: Changing two values with one pull-down in a form? In reply to
Hi,

seems that i'm blind :)

Ok - let's say the pulldown 'product' has three options: "Black car", "Red car" and "Blue Car".

The hidden variable 'price' should have "5000", "3000" or "1000" depending on the option the user chooses from the pulldown.

A sample would be GREAT!

Thanks
Chef