SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    Non-Member
    Join Date
    Oct 2006
    Posts
    77
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Javascript and dropdown menu

    Hello,


    Im am trying to create a drop down menu script. Once they select the item from the drop down box, it used javascript to update a div.

    I am also using PHP, to get the items from a database to build the form.

    My Code:

    Code:
    <?
    $listrooms = mysql_query("SELECT * FROM `chat_rooms` WHERE `title` != ''") or die(mysql_error()); 
    
            ?>
    		<form name="pickroom">
    		<select name="chooseform" onchange="UpdateRoom(document.pickroom.chooseform);">
    		<?
    		while($chatroom=mysql_fetch_array($listrooms)){ 
    		
    		if(!$chatroom[title]) { } else {
    		
    		echo '<option value="'.$chatroom[id].'">'.$chatroom[title].'</option>';
    		//echo '<a href="#" onclick="UpdateRoom('.$chatroom[id].'); return false;"  title="Add to Favorites">'.$chatroom[title].'</a> <br />';
    		} }
    		
    		?>
    		
    		</select>
    		</form>
    How would I upadte the room?

    I tried onchange as you can see.

    Any help? Thanks?

  2. #2
    SitePoint Addict ALL's Avatar
    Join Date
    Oct 2005
    Location
    South Dakota
    Posts
    215
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    well you need to supply us with all the code if you want good help...

    onchange="UpdateRoom(document.pickroom.chooseform);"

    that will work (not in all browsers though) aslong as UpdateRoom() actually is a function defined somewhere else.

    Supply us with either a link to the site in action or all the code... even just an html dump would work fine.

    -ALL
    Did I help you?
    You can repay me, support one of my projects (no money needed):
    JavaScript Wiki, Another Web Forum, Paranormal Site

  3. #3
    SitePoint Addict ALL's Avatar
    Join Date
    Oct 2005
    Location
    South Dakota
    Posts
    215
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    your problem is here:

    Code:
    var uRoomurl="room.php?id="+room
    and here:

    Code:
    ...onchange="UpdateRoom(document.pickroom.chooseform);"...
    You are passing:document.pickroom.chooseform which is the same as "this" which is an object... objects are like arrays they hold multiple values and functions not a single value. You should beable to fix this by changing the bottom snipit of code too:

    Code:
    ...onchange="UpdateRoom(this.value);"...
    -ALL
    Did I help you?
    You can repay me, support one of my projects (no money needed):
    JavaScript Wiki, Another Web Forum, Paranormal Site


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
  •