JavaScript Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 



Go Back   Dev Articles Community ForumsProgrammingJavaScript Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old August 5th, 2006, 06:20 AM
SnapCracker's Avatar
SnapCracker SnapCracker is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jan 2005
Location: Kent, United Kingdom
Posts: 165 SnapCracker User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 Days 21 h 22 m 31 sec
Reputation Power: 14
Adapting existing js drop-down menu.

Hi! I have an js menu which enables users to select the area in which they live, from one menu, by first selecting their County from another.
This works really well, but now I want to adapt it. I want it to alway show a selection of areas of one particular County that is always selected by messing with the form. here is the original code
Code:
var londonareasArray =  new Array("('Select borough/district','',true,true)",
"('Barking & Dagenham')",
"('Barnet')",
...etc etc
"('Last area')");
var nextcountyArray.......

Code:
function populateBorough(inForm,selected) {
var selectedArray = eval(selected + "Array");
while (selectedArray.length < inForm.borough.options.length) {
inForm.borough.options[(inForm.borough.options.length - 1)] = null;
}
for (var i=0; i < selectedArray.length; i++) {
eval("inForm.borough.options[i]=" + "new Option" + selectedArray[i]);
}
if (inForm.county.options[0].value == '') {
inForm.county.options[0]= null;
if ( navigator.appName == 'Netscape') {
if (parseInt(navigator.appVersion) < 4) {
window.history.go(0);
}
else {   	
if (navigator.platform == 'Win32' || navigator.platform == 'Win16') {
window.history.go(0);
            }
         }
      }
   }
}


Code:
<form name="form1">
 <select  name="county" onChange="populateBorough(document.form1,document.form1.coun  ty.options[document.form1.county.selectedIndex].value)">
			        <option selected value=''>Where are you looking?</option>
			        <option value="londonarea">All LONDON Areas</option>
			        <option value="bedfordshire">Bedfordshire</option>
			        <option value=....etc etc
 </select>
 <select name="borough">
			        <option value=''></option>
 </select>
</form>


Now I have been messing around with the form so instead of 'onChange' it is 'onFocus' and commented out all option values except one of them say "londonarea" but you have to select it to get the area options for londonareas. I looking for a way to get it to come up with the londonarea options when the page loads. I have tried this sort of approach where I give londonarea as the value
Code:
<select name="county" onFocus="populateBorough(document.form1,document.form1.coun  ty.options[document.form1.county.selectedIndex].value == "londonarea")">

But it does not seem to work. Could someone please give me the correct approach?
PS I know what you might be thinking, "why does he want js in the first place?" well, after this is solved, I'll php to select the County option carried over as a variable from previous page!

Reply With Quote
  #2  
Old August 5th, 2006, 07:56 PM
colton22's Avatar
colton22 colton22 is offline
\ ^_^ / - *Local Friend*
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jun 2006
Location: near chicago, Illinois
Posts: 469 colton22 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 Days 1 h 36 m 37 sec
Reputation Power: 12
Send a message via AIM to colton22 Send a message via MSN to colton22 Send a message via Yahoo to colton22
hey again sry i didnt get your emails till now, i think i know what u ment now.

try:

function _populate() {
window.document.form1.county.selectedIndex=1;
populateBorough(document.form1,document.form1.coun ty.options[document.form1.county.selectedIndex].value);
}
<body onload="_populate()">

that should do it.

colton22

Reply With Quote
  #3  
Old August 5th, 2006, 07:56 PM
colton22's Avatar
colton22 colton22 is offline
\ ^_^ / - *Local Friend*
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jun 2006
Location: near chicago, Illinois
Posts: 469 colton22 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 Days 1 h 36 m 37 sec
Reputation Power: 12
Send a message via AIM to colton22 Send a message via MSN to colton22 Send a message via Yahoo to colton22
(ps: keep the ONCHANGE!)

colton22

Reply With Quote
  #4  
Old August 6th, 2006, 02:04 PM
SnapCracker's Avatar
SnapCracker SnapCracker is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jan 2005
Location: Kent, United Kingdom
Posts: 165 SnapCracker User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 Days 21 h 22 m 31 sec
Reputation Power: 14
Thanks Colton22

I have reading about calling the index of the form before and not quite understanding it, but now I know: it starts from 0, 1, 2 etc right? Now I can steam ahead and play about with it using php!
Cheers

Reply With Quote
  #5  
Old August 6th, 2006, 03:28 PM
colton22's Avatar
colton22 colton22 is offline
\ ^_^ / - *Local Friend*
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jun 2006
Location: near chicago, Illinois
Posts: 469 colton22 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 Days 1 h 36 m 37 sec
Reputation Power: 12
Send a message via AIM to colton22 Send a message via MSN to colton22 Send a message via Yahoo to colton22
yea, in a select...

--_____________________
-/---------SELECTED--------\
|----------OPTION1----------| - Index of: 0
|----------OPTION2----------| - Index of: 1
|----------OPTION3----------| - Index of: 2
|----------OPTION4----------| - Index of: 3
|----------OPTION5----------| - Index of: 4
|----------OPTION6----------| - Index of: 5
|----------OPTION7----------| - Index of: 6
```````````````````````

hope this helps

colton22

ps like my drawing?? lolol
Comments on this post
MadCowDzz agrees: I like the drawing

Reply With Quote
  #6  
Old August 10th, 2006, 07:23 PM
colton22's Avatar
colton22 colton22 is offline
\ ^_^ / - *Local Friend*
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jun 2006
Location: near chicago, Illinois
Posts: 469 colton22 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 Days 1 h 36 m 37 sec
Reputation Power: 12
Send a message via AIM to colton22 Send a message via MSN to colton22 Send a message via Yahoo to colton22
are you there?

Reply With Quote
  #7  
Old August 10th, 2006, 07:33 PM
SnapCracker's Avatar
SnapCracker SnapCracker is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jan 2005
Location: Kent, United Kingdom
Posts: 165 SnapCracker User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 Days 21 h 22 m 31 sec
Reputation Power: 14
yeah, hows it goin'?

Reply With Quote
  #8  
Old August 11th, 2006, 03:51 PM
colton22's Avatar
colton22 colton22 is offline
\ ^_^ / - *Local Friend*
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jun 2006
Location: near chicago, Illinois
Posts: 469 colton22 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 Days 1 h 36 m 37 sec
Reputation Power: 12
Send a message via AIM to colton22 Send a message via MSN to colton22 Send a message via Yahoo to colton22
pretty good, lol, so i guess that worked ah?

Reply With Quote
  #9  
Old August 11th, 2006, 06:59 PM
SnapCracker's Avatar
SnapCracker SnapCracker is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jan 2005
Location: Kent, United Kingdom
Posts: 165 SnapCracker User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 Days 21 h 22 m 31 sec
Reputation Power: 14
No need to guess, have a look on parentpages.co.uk ...the homepage has been done again and your js code has been used to copy the selections to the new window, where one can make new selections/searches. It's content is pretty boring stuff for you, sorry, but it works the way I had originally wanted. So thanks very much again.
BTW how is your's getting on, downloading music from the menu I seem to remember..maybe downloading DOS script files!

Reply With Quote
  #10  
Old August 11th, 2006, 09:07 PM
colton22's Avatar
colton22 colton22 is offline
\ ^_^ / - *Local Friend*
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jun 2006
Location: near chicago, Illinois
Posts: 469 colton22 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 Days 1 h 36 m 37 sec
Reputation Power: 12
Send a message via AIM to colton22 Send a message via MSN to colton22 Send a message via Yahoo to colton22
lol, im glad your website is up and running the way you wanted it now, if you have any more questions ask alright?

anyway i havnt really worked on my website much lately, i do have a question about that though, and its "How would i get <objects> to work in all, IE, NN, FF, OPERA, EXC??" thats it, but after that, ill start working on what is left of my website and then, there we are, send me a logo of you website, ill see if i can put a link from my website to yours, email it, g2g c ya l8r

colton22

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingJavaScript Development > Adapting existing js drop-down menu.


Developer Shed Advertisers and Affiliates


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.

© 2003-2018 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap