Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

change form action upon drop down selection

Explorer ,
Sep 15, 2006 Sep 15, 2006
Hi,
I'm trying to find the best (browser supported) way of changing the action of a form based on the selection of a drop down box. Any ideas or code snippets appreciated.
TOPICS
Server side applications
317
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Sep 15, 2006 Sep 15, 2006
LATEST
since posting this I've found a script that works in Firefox but not IE:

<SCRIPT LANGUAGE="JavaScript"><!--
function setAction() {
if (navigator.appName.indexOf('Netscape') > -1) {
document.formName.action = document.formName.selectName.options[document.formName.selectName.selectedIndex].value;
return true;
}
else {
alert('Sorry, your browser does not support the changing of the action property of a form');
return false;
}

}
//--></SCRIPT>

Is there an alternative to changing the action of a form for this ?

I basically want to create a search facility on the site. From a text box, drop down and submit button I want the user to be able to select the area of the site they wish to search and target that area.

Two of the areas are database data, the other is going to be text search in html. I can handle the queries/search results, I just need to figure out how I can target the results page dependant on the users choice of search category (from the drop down)

I had planned to just pass the variable form the text input to the results page and the results page would do the rest from the recordset sql query. But if I can't target a specific page depending upon the users choice of category, how can I determine what results to display ?

Any advice appreciated.
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines