I have a simple form with a few textboxes on it. I would like to capture the input of the textboxes, modify it slightly and then append it to the form action URL.
$('.myBox').on('change', function (event) {
var myVal = $(this).val();
$('form').attr('action').appendTo("&MyVal="+myVal);
});
The above code doesn't work because there is no appendTo to the attr value. Is there another way to accomplish this?
Your syntax isn't quite right as you want to update the value of the action
attribute, not append
an element. Try this:
$('.myBox').on('change', function (event) {
var myVal = $(this).val();
$('form').attr('action', function(i, value) {
return value + "&MyVal=" + myVal;
});
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With