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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

form

Status
Not open for further replies.

novice2004

Programmer
Feb 2, 2004
62
0
0
US
Hi,

When I click on text field I would like to redirect my page to "index_1.php"
but I get "Error on Page".


and by submiting button I would like to to go to "index_2.php".

Thank you.


<form name='myForm' action=\"\" method=post>


setLink_1(form){
form.action="index_1.php";
form.submit();
}


setLink_2(form){
form.action="index_2.php";
form.submit();
}



<input type='text' onKeyPress=setLink_1(myForm) ...
<input type='submit' value='GO' name='submit' onClick=setLink_1(myForm) />
 
a) clicking on a text field would need to utilize the onclick event, not the onkeypress event.

b) this code will not redirect. rather, it will set the action of the form so that when you DO submit it, the submission will go to the page.

c) don't use words like 'form', they're misleading.

Try the code with the following changes:

FUNCTIONS:
Code:
setLink_1(f){
    f.action="index_1.php";
    f.submit();
}


setLink_2(f){
    f.action="index_2.php";
    f.submit();
}


THE FORM:
Code:
<form name='myForm' action="" method="post">
<input type='text' [red]onclick=setLink_1(myForm);"[/red] />
<input type='[red]button[/red]' value='GO' name='submit' onclick="setLink_1(this.form);" />
</form>

*cLFlaVA
----------------------------
Lois: "Peter, you're drunk!"
Peter: "I'm not drunk, I'm just exhausted from stayin' up all night drinking!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top