Go Back   CodingForums.com > :: Server side development > PHP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 10-03-2003, 06:32 AM   PM User | #1
angelic81
New Coder

 
Join Date: Oct 2003
Posts: 19
Thanks: 0
Thanked 0 Times in 0 Posts
angelic81 is an unknown quantity at this point
Double Combo Drop Down menu in PHP

Hi I have been searching a lot and no one seems to have the answer to this question so i figured Id try here. I am running a phpBB forum and I have successfuly modded it to ad a regular drop down menu for the profile field. I need a script though, that will allow my users to select a state and once the state is selected it loads a second drop down menu wich contains all the cities. There is a code on this site that does something similar to what i want but it is in javascript and I have tried unsucsessfuly to get the cities to load upon choosing a state. This code is used for opening up a link with the button go but i can do without the button

<form name="doublecombo">
<p><select name="example" size="1" onChange="redirect(this.options.selectedIndex)">
<option>Technology Sites</option>
<option>News Sites</option>
<option>Search Engines</option>
</select>
<select name="stage2" size="1">
<option value="http://javascriptkit.com">JavaScript Kit</option>
<option value="http://www.news.com">News.com</option>
<option value="http://www.wired.com">Wired News</option>
</select>
<input type="button" name="test" value="Go!"
onClick="go()">
</p>

<script>
<!--

/*
Double Combo Script Credit
By JavaScript Kit (www.javascriptkit.com)
Over 200+ free JavaScripts here!
*/

var groups=document.doublecombo.example.options.length
var group=new Array(groups)
for (i=0; i<groups; i++)
group[i]=new Array()

group[0][0]=new Option("JavaScript Kit","http://javascriptkit.com")
group[0][1]=new Option("News.com","http://www.news.com")
group[0][2]=new Option("Wired News","http://www.wired.com")

group[1][0]=new Option("CNN","http://www.cnn.com")
group[1][1]=new Option("ABC News","http://www.abcnews.com")

group[2][0]=new Option("Hotbot","http://www.hotbot.com")
group[2][1]=new Option("Infoseek","http://www.infoseek.com")
group[2][2]=new Option("Excite","http://www.excite.com")
group[2][3]=new Option("Lycos","http://www.lycos.com")

var temp=document.doublecombo.stage2

function redirect(x){
for (m=temp.options.length-1;m>0;m--)
temp.options[m]=null
for (i=0;i<group[x].length;i++){
temp.options[i]=new Option(group[x][i].text,group[x][i].value)
}
temp.options[0].selected=true
}

function go(){
location=temp.options[temp.selectedIndex].value
}
//-->
</script>

</form>

<p align="center"><font face="arial" size="-2">This free script provided by</font><br>
<font face="arial, helvetica" size="-2"><a href="http://javascriptkit.com">JavaScript
Kit</a></font></p>
angelic81 is offline   Reply With Quote
Old 10-03-2003, 08:23 AM   PM User | #2
Nightfire
Senior Coder

 
Nightfire's Avatar
 
Join Date: Jun 2002
Posts: 4,266
Thanks: 6
Thanked 48 Times in 48 Posts
Nightfire is on a distinguished road
You would be better off with javascript to do this, if someone choose a wrong option, then they'd have to rechoose it and wait for the page to reload once again.
__________________
Blue Panda
Website Design | 1 Pound Ads | 'ow much? | Coding Geeks
Nightfire is offline   Reply With Quote
Old 10-03-2003, 05:20 PM   PM User | #3
Shift4Sms
Regular Coder

 
Join Date: Jul 2002
Location: Las Vegas, NV - USA
Posts: 104
Thanks: 0
Thanked 0 Times in 0 Posts
Shift4Sms is an unknown quantity at this point
Question

Are you sure the concept works for the customers using the form? To me, typing in LAS VEGAS is easier than scrolling down almost halfway through a drop down list of cities looking for my city. I can imagine the frustration of someone living in a state like California with hundreds of more cities than Nevada.

Anyway, that's my thought. Sorry I could not be more helpful.
__________________
Steven Sommers (blog)
Shift4 Corporation -- www.shift4.com

Creators of $$$ ON THE NET(tm) payment processing services.
Shift4Sms is offline   Reply With Quote
Old 10-03-2003, 08:56 PM   PM User | #4
angelic81
New Coder

 
Join Date: Oct 2003
Posts: 19
Thanks: 0
Thanked 0 Times in 0 Posts
angelic81 is an unknown quantity at this point
I have placed the java script code in a PHP form page but the thing is that the load function does not work...I am relatively new with PHP and Javascript and I cant seem to see why this is not working... a regular drop down menu works just fine but the double combo doesnt...I have no idea what to do

I used to cities as an example but its specific places in cities really it's detailed so thats why I need this
angelic81 is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 02:57 PM.


Advertisement
Log in to turn off these ads.