vbcoach Posted March 22, 2010 Share Posted March 22, 2010 Hello once again. From within a form I have a PHP call to a MsSql database for available leagues and returns some basic information. It's in a dropdown menu. What I would like to do is when a user makes a selection from that form, I would like this form to immediate launch either the results in the same page, or launch a link to a new page with the requested information. Attached is the code I am using. I am trying to avoid multiple key or mouse presses. Just select the league - and then go there. <label>List registered teams for <select name="league" tabindex="2" > <option value="" selected="selected">-- Select League --</option> <?php while ($lrow = mssql_fetch_assoc($lres)) { ?> <option value="<?php echo $lrow['l_id'];?>"><?php echo "$lrow[night] $lrow[type] $lrow's $lrow[division]"; ?></option> <?php } ?> Then I either want the results printed below the selection, or a new page launched to http://www.somewebsite.com/viewleague.php?l= <selected league ID goes here> Does this make sense? Link to comment https://forums.phpfreaks.com/topic/196077-launching-a-link-directly-from-a-menu-selection/ Share on other sites More sharing options...
5kyy8lu3 Posted March 22, 2010 Share Posted March 22, 2010 you need javascript to do that, but it's simple. just do a google search for it =) http://www.davesite.com/webstation/js/theory1jump.shtml Link to comment https://forums.phpfreaks.com/topic/196077-launching-a-link-directly-from-a-menu-selection/#findComment-1029831 Share on other sites More sharing options...
vbcoach Posted March 22, 2010 Author Share Posted March 22, 2010 Ok, so far so good. However my drop down menu is dynamically created. I want to take the variable $lrow['l_id'] and add it to the end of http://www.mywebsite.com/info.php?l= then launch URL. The example you gave me has static addresses and I cannot figure out how to add my website url to the script. Any thoughts? Link to comment https://forums.phpfreaks.com/topic/196077-launching-a-link-directly-from-a-menu-selection/#findComment-1029837 Share on other sites More sharing options...
scvinodkumar Posted March 22, 2010 Share Posted March 22, 2010 <label>List registered teams for <select name="league" tabindex="2" OnChange="location.href=this.value"> <option value="" selected="selected">-- Select League --</option> <?php while ($lrow = mssql_fetch_assoc($lres)) { ?> <option value="http://www.mywebsite.com/info.php?l=<?php echo $lrow['l_id'];?>"><?php echo "$lrow[night] $lrow[type] $lrow[size]'s $lrow[division]"; ?></option> <?php } ?> Link to comment https://forums.phpfreaks.com/topic/196077-launching-a-link-directly-from-a-menu-selection/#findComment-1029931 Share on other sites More sharing options...
vbcoach Posted March 22, 2010 Author Share Posted March 22, 2010 Oh thank you so very much! I knew it was easy, but at 1am and brain-fried just couldn't grasp it. Mucho Gracias! Link to comment https://forums.phpfreaks.com/topic/196077-launching-a-link-directly-from-a-menu-selection/#findComment-1030040 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.