swidler
03-22-2004, 08:20 AM
i know similar problems have been posted, but i'm new at this and wasn't able to apply the solutions. 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">
<b> </b>
<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
<form name=gcFormKeywords method=get
action="http://url/script.pl">
<b> </b>
<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