I am trying to create a very dynamic form using AJAX. My AJAX function eval()s the responseText of the request as this is the best way of doing several other things.
I am writing this to input data into a database, and I would like to only use one function in php to input data into each of several tables. This means that I need to dynamically load both the text boxes and their validation rules.
Because i am eval()ing the responseText, I need my servder to return something like this.
The problem I am having is that, instead of creating the function validate, it runs the code from the function as it eval()s.
Any help would be appreciated.
I am writing this to input data into a database, and I would like to only use one function in php to input data into each of several tables. This means that I need to dynamically load both the text boxes and their validation rules.
Because i am eval()ing the responseText, I need my servder to return something like this.
Code:
formnode.innerHTML=' \
<form method="" action="" onsubmit="return validate(this);"> \
//4 or 5 text boxes here
<input type="submit" value="Save"> \
</form> ';
var validate=new function(frm) {
//for each text box validate it e.g.
if(frm.name.value=='')alert('Please Input Name');
//then submit data using AJAX
AJAX_processform(frm);
return false;
};
The problem I am having is that, instead of creating the function validate, it runs the code from the function as it eval()s.
Any help would be appreciated.