Jump to content

Recommended Posts

Posted

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...

Posted

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.

Posted

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.

Posted

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>

Posted

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.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...