views:

37

answers:

2

This is probably a very basic javscript question but here it goes. say i have 2 forms which are dynamically generated

<form name=test1 method=get action=insertaction> 
<input type=text name=desc value=2>
<input type=button onclick="document.test1.submit();" value=submit>
</form>


<form name=test2 method=get action=insertaction> 
<input type=text name=desc value=3>
<input type=button onclick="document.test2.submit();" value=submit>
</form>

Is there anything wrong with this code on the two forms? They seem to be passing null to the action

A: 

First, the attribute values should be surrounded by quotes : name="test1", etc.

Is the form action the path of a file ? Because it should, as the form will be passed to this file when submitted.

Fabien Ménager
A: 

When you click the submit button, your onclick is telling your form to submit. Whenever you submit a form, what you have specified for action is what determines how your form data is processed.

Your action=insertaction should be something like action="processData.php". This processData.php file is where you put your logic in handling the form field data. You will need to handle your form processing logic differently depending on what technology is available on the server. My example would indicate that php is available on the server. Some servers will have a cgi-bin and allow for you to use perl, or you may be dealing with asp. Most places where you host your web files at will have some kind of documentation to let you know what you can use and should even have examples.

Try W3Schools for some more information about form basics: W3Schools Form Info

shadenite