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!
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
Hi,
I have two drop down box. Depending on the value selected in 1st drop down menu box, values in the 2nd drop down box should change.I am not able to get values in the 2nd box to change when selected from the 1st box.
But i am getting the values from the database!!!!
Please help
Thanks in advance............
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
SCRIPT language=JavaScript>
function reload(form)
{
var val=form.cat.options[form.cat.options.selectedIndex].value; <--- This doesn't look right.
self.location='Hotels.php?cat=' + val ;
}
</script>
Try this instead:
var val = document.getElementById('cat').value;
and add an id="cat" to the select line.
That said, you may want to look at using AJAX for a better client side experience. Updating one form element from another would be perfect for learning about it. There's a number of tool kits out there that make it easier to implement.
To have try thing accessable to non javascript users you are likely to have to have a form anyway and a button "GO" if javascript is disabled. If you have a form anyway all you need is for javascript submit the form containing the first select. That way you are not hardcoding the direction and you don't have to get any value.
(If you want to use Ajax, search for chained select on these forums.)