SitePoint Sponsor

User Tag List

Results 1 to 22 of 22
  1. #1
    SitePoint Addict mserms's Avatar
    Join Date
    Jun 2001
    Location
    Scotland
    Posts
    230
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Dynamic altering of drop-down menus

    Not sure if this msg belongs here, but here goes:

    I'm trying to write a page with a form that includes 2 drop-down menus. I want the data in the second menu to change depending on what is selected in the first menu. I've not really got much of an idea about how to do this. Perhaps it's got someting to do with the no-refresh links article?

    Any ideas? Thanks,

    Mark

  2. #2
    SitePoint Zealot Marek Bereza's Avatar
    Join Date
    Sep 2001
    Location
    London
    Posts
    129
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    What language are you going to do it in? Are the menu items going to be pictures?
    of the brethren of disco metal
    Disco metal tunes at www.wikid.co.uk

  3. #3
    SitePoint Addict mserms's Avatar
    Join Date
    Jun 2001
    Location
    Scotland
    Posts
    230
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I'm writing the pages in PHP.Perhaps I'm in the wrong forum after all...?

    The menus are only going to be text that changes depending on the other selection.

    Thanks,

    Mark

  4. #4
    SitePoint Zealot Marek Bereza's Avatar
    Join Date
    Sep 2001
    Location
    London
    Posts
    129
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I haven't got a clue about PHP, so I can't help at all. Good luck. This is a really good forum though and if you talk to one of those mentor guys, you'll definitel get an answer
    of the brethren of disco metal
    Disco metal tunes at www.wikid.co.uk

  5. #5
    SitePoint Addict mserms's Avatar
    Join Date
    Jun 2001
    Location
    Scotland
    Posts
    230
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I think that it's really an HTML/JavaScript(?) problem. I'll probably only use the PHP to grab then info for the drop-down menus from a DB. Practically the same thing could be achieved without using PHP.

    Mark

  6. #6
    SitePoint Zealot Marek Bereza's Avatar
    Join Date
    Sep 2001
    Location
    London
    Posts
    129
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You could definitely do it in JavaScript. Maybe you could do it so every menu item on the first menu is connected to a function which changes the string variables in the second menu...etc
    of the brethren of disco metal
    Disco metal tunes at www.wikid.co.uk

  7. #7
    SitePoint Addict mserms's Avatar
    Join Date
    Jun 2001
    Location
    Scotland
    Posts
    230
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Sounds promising. I've never used JavaScript before so I'd better swot up...

  8. #8
    SitePoint Zealot Marek Bereza's Avatar
    Join Date
    Sep 2001
    Location
    London
    Posts
    129
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    http://www.w3schools.com/js/default.asp
    Go here it's really good, and it's got this thing where you can try out the scripts - just have a look. It will definitely start you off
    of the brethren of disco metal
    Disco metal tunes at www.wikid.co.uk

  9. #9
    SitePoint Addict mserms's Avatar
    Join Date
    Jun 2001
    Location
    Scotland
    Posts
    230
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quite a neat site, Marek. I like the way you can play with the code and see the effects.

    Any idea if I could create an empty drop-down menu and then call a function after the page has loaded which will load the values into the menu?

    Should be able to call the appropriate function then...

    Mark

  10. #10
    SitePoint Zealot Marek Bereza's Avatar
    Join Date
    Sep 2001
    Location
    London
    Posts
    129
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I think what you've got to do is make your drop down menu

    <select name="???">
    <option value="1"><script language="JavaScript" >document.write(variable1)</script></option>

    <option value="2"><script language="JavaScript" >document.write(variable2)</script></</option>

    etc...
    </select>
    Then make the menu submit itself somehow. I don't really know much about Javascript, but Flash I could help you with that. Maybe you should ask someone who knows what they're doing. I only use Javascript to make things align in the right way. I think flash is the best way to do everything and it looks nice too.
    of the brethren of disco metal
    Disco metal tunes at www.wikid.co.uk

  11. #11
    SitePoint Addict mserms's Avatar
    Join Date
    Jun 2001
    Location
    Scotland
    Posts
    230
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks Marek - you've been a help.

    Anyone expand on what Marek is saying?

    Thanks a lot,

    Mark

  12. #12
    ALT.NET - because we need it silver trophybronze trophy dhtmlgod's Avatar
    Join Date
    Jul 2001
    Location
    Scotland
    Posts
    4,836
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Ok, I can't post the whole code right now, mainly cos I'm a work, but I will give a few pointers, and if you want, I'll post the code when I get home.

    The quickest and easiest way, to me, is to use the innerHTML command, its really easy to use.

    Simple create a few javascript variable's holding the different frop down menus, and depending on what option is selected in the first drop down, the script would make the actualy HTML for the second drop down change. This can easily be accomplished without having to refresh the page.

    So, I would read up on innerHTML and the onChange command. The onChange command would trigger off the innerHTML function... if that makes sense...

    I'll post full solution later if you want.

  13. #13
    SitePoint Addict mserms's Avatar
    Join Date
    Jun 2001
    Location
    Scotland
    Posts
    230
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Excellent. Without wanting to seem too lazy (honest), the whole code would be great. I find it helps to read up along with the code to get an understanding of how it all works.

    Meanwhile I'll get reading up on some JavaScript functions.

    Mark

  14. #14
    SitePoint Addict mserms's Avatar
    Join Date
    Jun 2001
    Location
    Scotland
    Posts
    230
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    dhtmlgod: did you get the code?

    I'm having trouble finding a good innerHTML tutorial. Anyone wknow where?

    Thanks,

  15. #15
    ALT.NET - because we need it silver trophybronze trophy dhtmlgod's Avatar
    Join Date
    Jul 2001
    Location
    Scotland
    Posts
    4,836
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Sorry, I didn't get hoem till late, I'll post it in a lil bit.

    BTW, just noticed yout from Scotland, so am I! Where abouts are you?

  16. #16
    SitePoint Addict mserms's Avatar
    Join Date
    Jun 2001
    Location
    Scotland
    Posts
    230
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    That'd be great, thanks. I'm working in Edinburgh at the moment, but living in Haddington, east of the city. Where are you based? Not sure why but I though you were from the US. Odd...

  17. #17
    ALT.NET - because we need it silver trophybronze trophy dhtmlgod's Avatar
    Join Date
    Jul 2001
    Location
    Scotland
    Posts
    4,836
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I'm based in Dunoon right now, but we'll be moving offices soon to Greenock.

  18. #18
    SitePoint Addict mserms's Avatar
    Join Date
    Jun 2001
    Location
    Scotland
    Posts
    230
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I'm hoping to get to Dunoon next weekend! Despite it being the wettest place on the earth, I quite like it.

    If you're interested/bored there's a little bouldering guide to Glen Massan (just outside Dunoon) on my site:

    http://www.scottishclimbs.com/guidepage.php?guideid=4

  19. #19
    ALT.NET - because we need it silver trophybronze trophy dhtmlgod's Avatar
    Join Date
    Jul 2001
    Location
    Scotland
    Posts
    4,836
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Why would you want to come to Dunoon?! Crazy!

    I won't be here then, as I'll be away on holiday, so I can't offer to go out for a pub. My mom works in Sinbads, if you know where that is.

    The company I work for has this site (www.argyllonline.co.uk) as a side project, its just about to go in for a major redesign & development if you'ld be intersted in advertising.

  20. #20
    SitePoint Addict mserms's Avatar
    Join Date
    Jun 2001
    Location
    Scotland
    Posts
    230
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Dunoon has some of the nicest hardly touched boulders in Scotland! Just not the nicest weather :-(

    My mate's mum lives in Dunoon and works somewhere in the town centre, I'll try to find out where. Could be some sort of spooky your-mum-knows-my-mates-mum thing going on.

  21. #21
    ALT.NET - because we need it silver trophybronze trophy dhtmlgod's Avatar
    Join Date
    Jul 2001
    Location
    Scotland
    Posts
    4,836
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    lol, could be.

  22. #22
    SitePoint Addict mserms's Avatar
    Join Date
    Jun 2001
    Location
    Scotland
    Posts
    230
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    did you manage to find the code dhtmlgod?


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •