getting enter to behave like onclick button

  Post new topicReply to topicPrintable Version
<< View previous topic View next topic >>
Share: Del.icio.us  Digg  Google  Spurl  Blink  Furl  Y! MyWeb  
#1   getting enter to behave like onclick button
swidler
CZ Newbie
swidler has been a member for over 20 year's 20 Year Member
Status: Offline
Joined: Mar 22, 2004
0.00 posts per day
Posts: 1
Points: 100
   
i have a form with a text box that submits using onclick with a button. when i click on the button, it goes to a function that decides which url should be brought up. when i hit enter, it goes to the url defined in the action= of the form. how do i make enter go to the function?

<form name=gcFormKeywords method=get
action="http://url/script.pl">;

<input type=text name="search" size=30>
<input type=button value="Go" onClick=gcGo() name="button">
</form>

where gcGo is (something like) the following (actually, i've expanded it, but the structure is the same):

function gcGo(searchType) {
var searchType = document.gcFormSearchType.search.selectedIndex;
// index 0 is the keywords option; index 1 is the symbol option; index 2 is the gc id option
// alert(searchType);
// alert(document.gcFormKeywords.search.value);
if (searchType == 1) {
var re = /\*/
if (re.exec (document.gcFormKeywords.search.value)) {
document.gcFormSymStar.symsearch.value =
document.gcFormKeywords.search.value;
document.gcFormSymStar.submit();
}else {
document.gcFormSymbol._symbol.value =
document.gcFormKeywords.search.value;
document.gcFormSymbol.submit();
}
} else{
if (searchType == 2) {
var re = /\*/
if (re.exec (document.gcFormKeywords.search.value)) {
document.gcFormSymStar.symsearch.value =
document.gcFormKeywords.search.value;
document.gcFormSymStar.submit();
}else {
document.gcFormGcid.gc_id.value =
document.gcFormKeywords.search.value;
document.gcFormGcid.submit();
}
}else {
document.gcFormKeywords.submit();
}
}
}

there are 3 or 4 forms after the one quoted above. each sends to a different url.

tia,
naomi



Back to top Reply with quote
Display posts from previous:      
Add To: Del.icio.us  Digg  Google  Spurl  Blink  Furl  Y! MyWeb  
<< View previous topic View next topic >>
Post new topicReply to topic

Jump to 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You cannot download files in this forum