Monday, May 20, 2024
 Popular · Latest · Hot · Upcoming
49
rated 0 times [  50] [ 1]  / answers: 1 / hits: 27943  / 12 Years ago, mon, april 30, 2012, 12:00:00

Hi i have have this form that i do no want to perform an action when the submit button is clicked. All i want to do is perform the a function that loads data into a div. Any Ideas??



<form  method=POST   action= id=search-form>
<input type=text name=keywords />
<input type=submit value=Search id=sButton onclick=loadXMLDoc('file.xml') />
</form>

More From » jquery

 Answers
98
onclick=loadXMLDoc('file.xml'); return false;


or even better:



<script>
window.onload = function() {
document.getElementById(search-form).onsubmit = function() {
loadXMLDoc('file.xml');
return false;
};
};
</script>


To implement loadXMLDoc, you can use the ajax module in jQuery. for example:



function loadXMLDoc() { 
$(div).load(file.xml);
}


Final code using jQuery:



<script>
$(function() {
$(#search-form).submit(function() {
$(div).load(file.xml);
return false;
});
});
</script>

[#85892] Saturday, April 28, 2012, 12 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
micayla

Total Points: 148
Total Questions: 92
Total Answers: 109

Location: Aruba
Member since Sat, Oct 2, 2021
3 Years ago
micayla questions
Fri, Dec 24, 21, 00:00, 2 Years ago
Thu, Apr 16, 20, 00:00, 4 Years ago
Thu, Nov 14, 19, 00:00, 5 Years ago
;