jquery - Changing the name od a dropdown using javascript onchange -


hi need change name of dropdown box depending on selected list.

<form  name="dofilter" method="post" action="<%=site_url%>/product">     <select name="ff" onchange="form.submit();">         <option value="">--</option>         <option value="brut">brut</option>         <option value="moet"> moet</option>     </select> </form> 

if option brut selected need select name fk , if option moet selected need select name ff

help please

this how did it:

$("form > select").change(function () {     $(this).parent().attr("name", $(this).find("option:selected").attr("id")); }); 

here jsfiddle demo.

you can check inspecting element see name change instantly.


Comments

Popular posts from this blog

javascript - Using jquery append to add option values into a select element not working -

Android soft keyboard reverts to default keyboard on orientation change -

Rendering JButton to get the JCheckBox behavior in a JTable by using images does not update my table -