How to redirect to link with <select option in php?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
susain
Forum Newbie
Posts: 1
Joined: Tue Feb 03, 2009 8:21 am

How to redirect to link with <select option in php?

Post by susain »

Hi Friends,

My requirement is redirect to a page based on select option

I have a html code as shown below
<select name="url">
<option Value=".....&pid=00ac92ca52dc2ad07c3d5">10</option>
<option Value=".....&pid=00ac92ca52dc2ad07c3d6">20</option>
</select>

Problem is in the php page &pid is treating as variable, to redirect to page I must need &pid=.....

How solve this problem?

Thanks,
Farooq
mavieng
Forum Newbie
Posts: 10
Joined: Thu Jan 29, 2009 12:34 pm

Re: How to redirect to link with <select option in php?

Post by mavieng »

Code: Select all

 
<script type='text/javascript'>
    function openurl()
    {
        site = document.myform.url[document.myform.url.selectedIndex].value;
        if(site!="")
        {
            location.href = site;
        }
    }
</script>
 
<form name='myform'>
<select name="url" onchange='openurl()'>
<option Value="">Select One</option>
<option Value="http://www.rediff.com">Rediff.com</option>
<option Value="http://www.whereincity.com">Whereincity.com</option>
</select>
</form>
 
 
 
Post Reply