jquery - How to modify form fields with JavaScript? -
i have big form lots fields, want use javascript simplify fields, means, pre process , delete of fields javascript return new processed field.
for example, have fields in form plot_country, plot_state, plot_city, want precalculate location_# country, state, city in javascript, , return fields contain location_#.
in way url simplified, , server can directly use location_# , doesn't need process location combinations more.
does have ideas? thanks!
try this:
<form id="location_form"> <input type="text" id="plot_country"> <input type="text" id="plot_state"> <input type="text" id="plot_city"> <input type="hidden" id="location"> <input type="submit"> </form> <script type="text/javascript"> $( "#location_form" ).submit(function( event ) { $('#location').value($(this).serialize()); $('input[type=text]').remove(); }); </script>
Comments
Post a Comment