vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=15)
-   -   Javascript : Auto redirection select dropdown .... weird (https://vborg.vbsupport.ru/showthread.php?t=77773)

cinq 03-09-2005 07:24 AM

Javascript : Auto redirection select dropdown .... weird
 
I am trying to place this auto redirect select dropdown box on the postbits of all member.

The code:

Code:

<Script language="JavaScript">
<!-- Script courtesy of http://www.web-source.net - Your Guide to Professional Web Site Design and Development
function goto(form) { var index=form.select.selectedIndex
if (form.select.options[index].value != "0") {
location=form.select.options[index].value;}}
//-->
</SCRIPT>
<FORM NAME="form1">
<SELECT NAME="select" ONCHANGE="goto(this.form)" SIZE="1">
<OPTION VALUE="$vboptions[bburl]/index.php">Home
<OPTION VALUE="$vboptions[bburl]/usercp.php">Control Panel
</SELECT>
</FORM>

used code from here

Once there, all a user has to do is select the appropriate item in the dropdown, say "Control Panel" and it will automatically redirect to the usercp.php page.

However it doesn't seem to redirect. Anyone, any ideas why this doesn't work ? :(

Edit : hmm odd, it works on IE it seems but not on Firefox.
Is there any way around it so that it works on all browsers ?

Ok nvm...ended up using this code and it seems to work :

Code:

<SELECT name="select" ONCHANGE="window.location=(this.options[selectedIndex].value);" SIZE="1">

Colin F 03-09-2005 02:45 PM

Alternately you could have a look at the code used for the dropdown menus in the admincp (for usergroups for example).

Jolten 03-09-2005 03:02 PM

The script I use....

Code:

<script language="JavaScript">
<!--
function goToURL(form)
  {

    var myindex=form.dropdownmenu.selectedIndex
    if(!myindex=="")
      {
        //window.location.href=form.dropdownmenu.options[myindex].value;

        //This is an alternative method you can use
        var Target = "_blank";
        window.open(form.dropdownmenu.options[myindex].value,Target,"");
      }
}
//-->
</script>

I've got the top string commented out because I wanted new windows when selected. You can uncomment it and comment out the alternative method to open links in the same window.

and the form...

Code:

<form name="dropDownForm">
        <select name="dropdownmenu" size="1" onChange="goToURL(this.form)">
                <option value="url">Text</option>
                <option value="url">Text</option>
        </select>
</form>

This works perfectly with every browser as far as I know.


All times are GMT. The time now is 08:39 AM.

Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.00988 seconds
  • Memory Usage 1,718KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (4)bbcode_code_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (3)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • printthread_start
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete