capture click event and append to end of a form's action via Ajax
I need to capture the click event, edit form action then re-submit the form with the captured input value appended to the end of the action. Anyone got any ideas? Been messing around with the following: so I would like the end url action to be google.com/tada
- <html>
<head>
<script type="text/javascript" src="http://code.jquery.com/jquery-1.4.2.min.js"></script>
</head>
<body>
<script type="text/javascript">
$(document).ready(function() {
$("form[class='ajax'] input[type='submit']").live('click',function(e) {
//var f = $(this).parents('form:first');
$('#submit').submit(function() {
var result = $(this).attr('action').replace('elan');
$.post("tada", f.serialize(), function(data) {
$(result).html(data);
});
return false;
});
});
});
</script>
<div id="plugin_form_container">
<form class="ajax" action="http://www.google.com" method="post">
<table width="100%">
<tr>
<td class="r">Test</td>
<td><input type="text" name="test" value="" size="45"></td>
</tr>
<tr>
<td></td>
<td>
<input type="hidden" name="p" value="plugin" />
<input type="hidden" name="m" value="module" />
<input type="hidden" name="a" value="add_record" />
<input type="submit" id="submit" value="Submit" />
</td>
</table>
</form>
</div>
</body>
</html>