TalkPHP
 
 
Account Login
Latest Articles
» The basic usage of PHPTAL, a XML/XHTML template library for PHP
» Vulnerable methods and the areas they are commonly trusted in.
» Simple way to protect a form from bot
» The Basics On: How Session Stealing Works
» How to keep your forms from double posting data
IRC Channel
IRC Speech Bubble Join the friendly bunch on IRC...
(#TalkPHP on Freenode)

...Also available via a web interface.

See this thread for information on the TalkPHP Free Hugs Initiative™. Subject to availability.
Associates
Associates
CSS Tutorials
Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old 10-02-2008, 05:54 PM   #1 (permalink)
The Contributor
 
Join Date: Apr 2008
Location: Nevada, USA
Posts: 52
Thanks: 10
h0ly lag is on a distinguished road
Default Load url on select, via drop down menu

Ok, my title pretty much says it all. I need to create a drop down menu with the titles of the pages I need to load. The pages are being included with a $_GET command and a switch statement. The page inclusion works good. I just need to create the drop down menu and have it load the $_GET requests when their selected. Help please?

I already have something like this:
Code:
<select name=\"page\">
<option value=\"change_auth_level\">Change auth level</option>
<option value=\"email_activation\">Email activation settings</option>
</select>
__________________
Send a message via AIM to h0ly lag Send a message via MSN to h0ly lag
h0ly lag is offline  
Reply With Quote
Old 10-02-2008, 06:22 PM   #2 (permalink)
La Vida es Sueño
Advanced Programmer Top Contributor 
 
Wildhoney's Avatar
 
Join Date: Sep 2007
Location: Oldham
Posts: 2,280
Thanks: 90
Wildhoney is on a distinguished road
Default

I have coded the following for you. With this HTML code:

html4strict Code:
<body onload="TalkPHP_Dropdown_Select.init();">

    <select name="page" id="page">
        <option>Choose one...</option>
        <option value="auth_level.php">Change auth level</option>
        <option value="email_settings.php">Email activation settings</option>
    </select>

</body>

And the following JavaScript code as well:

javascript Code:
<script type="text/javascript">

    var TalkPHP_Dropdown_Select =
    {
        init: function()
        {
            TalkPHP_Dropdown_Select.Address = 'http://www.talkphp.com/';
            TalkPHP_Dropdown_Select.Target = document.getElementById('page');
            TalkPHP_Dropdown_Select.Target.onchange = function()
            {
                TalkPHP_Dropdown_Select.gotoAddress();
            }
        },
       
        gotoAddress: function()
        {
            var pTarget = TalkPHP_Dropdown_Select.Target;
            var szValue = pTarget.options[pTarget.selectedIndex].getAttribute('value');
           
            if (szValue == null)
            {
                return;
            }
           
            location.href = TalkPHP_Dropdown_Select.Address + szValue;
        }
    }

</script>

It should produce something similar to what you're after. I hope it helps!
Attached Files
File Type: html dropdown.html (1.0 KB, 501 views)
__________________
The man who comes back through the Door in the Wall will never be quite the same as the man who went out.
Send a message via AIM to Wildhoney Send a message via MSN to Wildhoney Send a message via Yahoo to Wildhoney
Wildhoney is offline  
Reply With Quote
The Following User Says Thank You to Wildhoney For This Useful Post:
h0ly lag (10-03-2008)
Old 10-03-2008, 05:39 AM   #3 (permalink)
The Contributor
 
Join Date: Apr 2008
Location: Nevada, USA
Posts: 52
Thanks: 10
h0ly lag is on a distinguished road
Default

Wow, that worked perfect. Thank you very much!
__________________
Send a message via AIM to h0ly lag Send a message via MSN to h0ly lag
h0ly lag is offline  
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


All times are GMT. The time now is 06:01 AM.

 
     

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0
Inactive Reminders By Icora Web Design