Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    New Coder
    Join Date
    May 2012
    Posts
    25
    Thanks
    4
    Thanked 1 Time in 1 Post

    Drop down not working

    Hi all,

    I'm trying to get a page to update the URL based on what gets selected in a drop down menu.

    In the head I have the following:

    Code:
         $(document).ready(function(){
    		$(".monthselect").change(function(){
    			var selected;
    			selected = $(document.getElementById("monthselect").value);
    			window.location = "?mon=" + selected;
    		});
    	 });
    The select box is called monthselect but when I change the drop down nothing happens.

    Thanks in advance

  • #2
    Master Coder felgall's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, Australia
    Posts
    6,640
    Thanks
    0
    Thanked 649 Times in 639 Posts
    Are you certain that you have

    <select class="monthselect" ...

    in the HTML?
    Stephen
    Learn Modern JavaScript - http://javascriptexample.net/
    Helping others to solve their computer problem at http://www.felgall.com/

    Don't forget to start your JavaScript code with "use strict"; which makes it easier to find errors in your code.

  • #3
    New Coder
    Join Date
    May 2012
    Posts
    25
    Thanks
    4
    Thanked 1 Time in 1 Post
    I was missing a " which was why it wasn't doing anything!!

    Problem I have not is it is making the URL calendar.php?mon=[object%20Object]
    instead of putting the value across.

    Any ideas as this is really frustrating me now.

  • #4
    New Coder
    Join Date
    May 2012
    Posts
    25
    Thanks
    4
    Thanked 1 Time in 1 Post
    I've finally managed to sort it!

    Thanks anyway.


  •  

    Posting Permissions

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