I'm trying to override some data via Prototope JS before submitting the form. How can I achieve it?
Here's the snippet:
<script type='text/javascript'>
$('formId').observe('submit', function(e) {
//override some field data here
//before submitting
//...
});
</script>
So you are picking the right event as the submit event fires before the submit takes place.
Here is a simple example that will change the value of the one input to all uppercase on submit
<form id="formId">
<input type="text" name="forminput1" id="forminput1" />
<input type="submit" name="submit" value="Submit" />
</form>
<script type='text/javascript'>
$('formId').observe('submit', function(e) {
$('forminput1').value = $('forminput1').value.toUpperCase()
});
</script>
In general you can make any edits you want in the submit event handler as long as you can address the fields.