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

two similar forms one function

Status
Not open for further replies.

storm1976

Programmer
Jul 6, 2001
31
GB
hi there,

the problem ive got is that i have two forms (one at the top and one at the bottom) which do the same thing.

would just like to know how i could differentiate between the two forms. as in which form has been submitted.

at the moment the function i have is:

function goThere(){
if (document.myForm_bottom.botttom) {
thisPage = document.myForm_bottom.ipag.value
thisForm = document.myForm_bottom
}else{
thisPage = document.myForm_top.ipag.value
thisForm = document.myForm_top
}
start = <%=firstPage%>
finish = <%=iPageCount%>
isGood = true
if ((isNaN(thisPage)) || thisPage == &quot;&quot;){
isGood = false
}
else{
thisPage = parseInt(thisPage)
if (thisPage > finish || thisPage < start){
isGood = false
}
}
if (!isGood){
alert(&quot;Please enter a valid number between &quot; + start + &quot; and &quot; + finish)
thisPage=&quot;&quot;; thisForm.ipag.focus();
}
else{
document.location = &quot;searchresults.asp?<%=query%>&ipag=&quot; + thisPage
}
}

but this only looks at the top form. i have tried at the top of the function to find which button has been clicked.

any help would be appreciated

cheers in advance
Storm
 
function goThere(formNum){
thisPage = eval(&quot;document.formNum&quot; + formNum + &quot;.ipag.value&quot;)
start = <%=firstPage%>
finish = <%=iPageCount%>
isGood = true
if ((isNaN(thisPage)) || thisPage == &quot;&quot;){
isGood = false
}
else{
thisPage = parseInt(thisPage)
if (thisPage > finish || thisPage < start){
isGood = false
}
}
if (!isGood){
alert(&quot;Please enter a valid number between &quot; + start + &quot; and &quot; + finish)
thisPage=&quot;&quot;; thisForm.ipag.focus();
}
else{
document.location = &quot;searchresults.asp?<%=query%>&ipag=&quot; + thisPage
}
}

<form name=&quot;formNum1&quot;>
<input name=&quot;ipag&quot;>
<input type=button onClick=&quot;goThere(1)&quot; value=&quot;Submit&quot;>
</form>
...
...
...
<form name=&quot;formNum2&quot;>
<input name=&quot;ipag&quot;>
<input type=button onClick=&quot;goThere(2)&quot; value=&quot;Submit&quot;>
</form>
Get the Best Answers! faq333-2924
Is this an asp FAQ? faq333-3048
Tek-Tips Best Practices: FAQ183-3179
mikewolf@tst-us.com (Do not email regarding this thread unless requested - I don't check this account regularly)
 
not to sound too bit dodgy, but you beauty!

cheers mwolf00
worked a treat

Storm
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top