kickarse Posted November 4, 2006 Posted November 4, 2006 I'm trying to get a drop down menu to change another hidden input something like If form.input.INPUT1.option.value == "145" write form.input.INPUT2.value "NameOfItem" Endif The dropdown menu has a couple of value like 145, 155, 165 and whichever is selected changes the input2 value automatically... I just cant figure how to write it... Quote
Sparda Posted November 4, 2006 Posted November 4, 2006 That sounds like your site is going to NEED JavaScript to work... this is a bad design practice. Quote
kickarse Posted November 4, 2006 Author Posted November 4, 2006 This wouldn't be considered a design practice at all. In fact this would be considered a coding practice if anything. I am already running javascript elements in on the site so it wouldn't really matter if it was javascript or not. Btw, javascript is supported by every major web browser and has been for quite some time now. The site is a general consumer site, none of the stat's have shown that people have javascript disabled. Quote
Guest Posted November 4, 2006 Posted November 4, 2006 just on a side not i take it the value inside the hidden element is going to be used by php or asp or something that, which means you shouldnt trust those values, it would be very easy to use javascript injection to trick the app if you do trust the values inside the hidden element. Quote
jool Posted November 4, 2006 Posted November 4, 2006 Since the complaining is already taken care of I thought I would come with an actual response to the question. Very simple with no error checking but it should be understandable enough. <script language="javascript"> function select_box_changed(){ document.getElementById('the_output_box').value = this.options[this.selectedIndex].value; } function init(){ document.getElementById('the_select_box').onchange = select_box_changed; } window.onload = init; </script> Quote
kickarse Posted November 4, 2006 Author Posted November 4, 2006 Thanks Jool for actual help :D I understand there's a certain security risk to it but the fact remains that it's not a security risk... All I'm trying to do it change a field according to a drop down menu action... I'm trying to do something like this <form target="" action="" method="post" name="form01"> <input type="hidden" name="changeneeded01" value="value.needs.change"> <input type="hidden" name="on0" value="Finish"> <select name="changefrom01"> <option value="Aluminum">Aluminum</option> <option value="Iron">Aluminum</option> <option value="Lead">Aluminum</option> </select> </form> While I want it to change based on the value selected I don't want that value to be inputted. I want it if the user selects Iron then a number goes into the hidden input. Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.