This work perfectly! ;)
This can be done using Ajax and with what I call: "a form mirror element". Instead to send a form with an element outside, you can create a fake form.
The previous form is not needed.
<!-- This will do the trick -->
<div >
<input id="mirror_element" type="text" name="your_input_name">
<input type="button" value="Send Form">
</div>
Code ajax would be like:
<script>
ajax_form_mirror("#mirror_element", "your_file.php", "#your_element_response", "POST");
function ajax_form_mirror(form, file, element, method) {
$(document).ready(function() {
// Ajax
$(form).change(function() { // catch the forms submit event
$.ajax({ // create an AJAX call...
data: $(this).serialize(), // get the form data
type: method, // GET or POST
url: file, // the file to call
success: function (response) { // on success..
$(element).html(response); // update the DIV
}
});
return false; // cancel original event to prevent form submitting
});
});
}
</script>
This is very usefull if you want to send some data inside another form without submit the parent form.
This code probably can be adapted/optimized according to the need. It works perfectly!! ;)
Also works if you want a select option box like this:
<div>
<select id="mirror_element" name="your_input_name">
<option id="1" value="1">A</option>
<option id="2" value="2">B</option>
<option id="3" value="3">C</option>
<option id="4" value="4">D</option>
</select>
</div>
I hope it helped someone like it helped me. ;)