SitePoint Sponsor

User Tag List

Results 1 to 8 of 8
  1. #1
    SitePoint Enthusiast
    Join Date
    Mar 2003
    Location
    Texas
    Posts
    86
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Automatic forwarding from drop-down menu.

    Hopefully this is a simple question...

    Can a form be setup so that when select an item from a drop-down menu you are automatically forwarded to the page? I'm trying to do this to circumvent using a submit button or pressing "Enter."

  2. #2
    $postcount++; koomann's Avatar
    Join Date
    Feb 2003
    Location
    Posts
    428
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Code:
    <form name="form1">
      <select name="menu1" onChange="MM_jumpMenu('parent',this,0)">
    	<option value="http://www.gotohere.com">Click Me!</option>
      </select>
    </form>
    TY Dreamweaver

  3. #3
    gingham dress, army boots... silver trophy redux's Avatar
    Join Date
    Apr 2002
    Location
    Salford / Manchester / UK
    Posts
    4,838
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by koomann
    Code:
    <form name="form1">
      <select name="menu1" onChange="MM_jumpMenu('parent',this,0)">
    	<option value="http://www.gotohere.com">Click Me!</option>
      </select>
    </form>
    TY Dreamweaver
    and of course you do realise that that won't work unless the MM_jumpMenu function is defined somewhere, don't you (which dreamweaver does) ?

    stick the following in your <head> section as well for the above to work...

    <script language="JavaScript">
    <!--
    function MM_jumpMenu(targ,selObj,restore){ //v3.0
    eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
    if (restore) selObj.selectedIndex=0;
    }
    //-->
    </script>
    redux (adj.): brought back; returned. used postpositively
    [latin : re-, re- + dux, leader; see duke.]
    WaSP Accessibility Task Force Member
    splintered.co.uk | photographia.co.uk | redux.deviantart.com

  4. #4
    Sultan of Ping jofa's Avatar
    Join Date
    Mar 2002
    Location
    Svj
    Posts
    4,080
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Or
    Code:
    <select onchange="if(this.selectedIndex!=0){location.href=this.value;}">
      <option>Please select...</option>
      <option value="http://www.example.com">Example</option>
      <!-- ...and some more options... -->
    </select>

  5. #5
    $postcount++; koomann's Avatar
    Join Date
    Feb 2003
    Location
    Posts
    428
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by redux
    and of course you do realise that that won't work unless the MM_jumpMenu function is defined somewhere, don't you (which dreamweaver does) ? [img]images/smilies/tongue.gif[/img]
    Now I do

  6. #6
    SitePoint Enthusiast
    Join Date
    Mar 2003
    Location
    Texas
    Posts
    86
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks, the above described methods do work, but now I need to take this a step or two further -- let me explain.

    At present, the choices found in this drop-down menu are used to load another page based on what you selected. That is to say, if you choose "A" then the effected page will return results based on the decision of "A."

    The effected page is not under my control. It's some other site that handles the request.

    The page is here:
    http://www.partypics.com/ver2/

    What you do is enter a "password" and that password is what determines what page is loaded. What I have in a drop-down menu works fine right now, but the problem is that you have to use a "submit" style button. I need for the page to be loaded automatically based on the choice from the drop-down menu.

    For the sake of information, the page that is handling the "password" is here:
    http://www.partypics.com/ver2/checkpassword.aspx

    The security of the password within the drop-down menu isn't a concern because it's just pictures that are being viewed.

    So, to clarify things, I need a drop-down list where all you do is select the password and the page described above is generated.

    Here's what I currently have that works, but you have to press the Submit button:

    Code:
    		<FORM name="pwdform" ACTION="http://www.partypics.com/ver2/checkpassword.aspx" ENCTYPE="'ENCTYPE="x-www-form-urlencoded"'" METHOD="post">
    		<input type="submit" name="Go" value="Submit" STYLE="font-size: 8pt">
    		<select name="EventPwd">
    		<option selected STYLE="background:FFFFFF" STYLE="color:006633">Please select...
    		<option value="blah" STYLE="background:006633" STYLE="color:FFFFFF">Just Something
    		</select>
    		</FORM>

  7. #7
    Sultan of Ping jofa's Avatar
    Join Date
    Mar 2002
    Location
    Svj
    Posts
    4,080
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    No matter what the user selects in the list, (s)he should be directed to the same page, it's just the EventPwd parameter that will be different, correct?

    <select name="EventPwd" onchange="if(this.selectedIndex!=0){this.form.submit();}">

    If the page checkpassword.aspx in some way "requires" that there must be an element called "Go" (the submit button) in the posted form, add an <input type="hidden" name="Go" value="submit">

  8. #8
    SitePoint Enthusiast
    Join Date
    Mar 2003
    Location
    Texas
    Posts
    86
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks for your help. The above described line made it work correctly.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •