HowardMarks
MIS
Hello chaps
I am just playing around with my first foray into ajax.
I am attempting to submit a form which can either be submitted via a main submit button, or by a series of image fields which apply to specific rows of the form.
The original server side script would check to see which one of the submit buttons was pressed by checking the value of 'Submit' from the form fields.
Now when the form is submitted using ajax, it seems that the submit field gets passed through with the id of the main submit button, regardless of whether one of the image fields was used to submit it.
The function I am using to extract the values from the form and send them via ajax is as follows:
Does anyone have any advice on this situation, as it seems that the "document.getElementById("predictionForm").onsubmit = function()" line is not distinguishing between which method was used to submit the form.
Many thanks
Nick Price
Nick (Webmaster)
I am just playing around with my first foray into ajax.
I am attempting to submit a form which can either be submitted via a main submit button, or by a series of image fields which apply to specific rows of the form.
The original server side script would check to see which one of the submit buttons was pressed by checking the value of 'Submit' from the form fields.
Now when the form is submitted using ajax, it seems that the submit field gets passed through with the id of the main submit button, regardless of whether one of the image fields was used to submit it.
The function I am using to extract the values from the form and send them via ajax is as follows:
Code:
function prepareForm(){
if(!document.getElementById){
return;
}
if(!document.getElementById("predictionForm")){
return;
}
document.getElementById("predictionForm").onsubmit = function(){
var data = "";
for(var i=0; i<this.elements.length; i++){
data+= this.elements[i].name;
data+= "=";
data+= escape(this.elements[i].value);
data+= "&";
}
data += "sender=ajax"
return !sendData(data);
};
}
Does anyone have any advice on this situation, as it seems that the "document.getElementById("predictionForm").onsubmit = function()" line is not distinguishing between which method was used to submit the form.
Many thanks
Nick Price
Nick (Webmaster)