Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Input text to select the file to include in <FORM ACTION=>

Status
Not open for further replies.

delorfra

Programmer
Mar 8, 2001
79
FR
Within a form I want to use an input textbox to select the file to be referred in <FORM ACTION=&quot;myfile.htm&quot;> so that I can use the same form to submit to different pages.

 
Create a javascript function and call it when your form is submitted.

Some thing like:

<HTML>
<HEAD>
<SCRIPT>
function submitForm()
{
var form = document.myForm;
var myFile = form.myField.value;

if (myFile == '') return false;
else {
form.action = myFile;
form.submit();
return true;
}
}
</SCRIPT>
</HEAD>
<BODY>
<FORM NAME=&quot;myForm&quot; method=&quot;POST&quot;>
<INPUT TYPE=&quot;TEXT&quot; NAME=&quot;myField&quot; VALUE=&quot;&quot;>
<INPUT TYPE=&quot;BUTTON&quot; NAME=&quot;Submit&quot; VALUE=&quot;Submit&quot; onClick=&quot;return submitForm()&quot;>
</FORM>
</BODY>
</HTML>

Hope this helps.

Mise Le Meas,

Mighty :)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top