#1
  1. A Change of Season
    Devshed Frequenter (2500 - 2999 posts)

    Join Date
    Mar 2004
    Location
    Next Door
    Posts
    2,660
    Rep Power
    171

    Update div onchange


    Hi;

    I have 2 drop downs, the one under changes based on whats selected on the one on top.

    I want to send the value of selected city to the function and it reloads a new page in the div. But it doesn;t work and I don't see any errors in Fire Bug.

    Please guide.

    Thanks
    javascript Code:
     
        <script type="text/javascript">
                function update_suburb_dd()
                    {
                        $.post('page.php/'+city, { city: document.form.city},function(output){$('#suburbs').html(output).show();});
                    }
                </script>


    And this is the html
    html Code:
     
        <select name="city" class="select_1" id="city" onchange="update_suburb_dd();"> 
     
        <option value="0">Select a city</option> 
     
        <option value="beaudesert">Beaudesert</option> 
     
        <option value="brisbane">Brisbane</option> 
     
        <option value="gold coast">Gold Coast</option> 
     
        </select>


    Thanks
  2. #2
  3. A Not To Shabby Code Smurf
    Devshed Beginner (1000 - 1499 posts)

    Join Date
    Aug 2008
    Posts
    1,153
    Rep Power
    183
    Try this and see what happens:
    Code:
    <script type="text/javascript">
                function update_suburb_dd()
                    {
                        $.post('page.php/'+city, { city: document.form.city.value},function(output){$('#suburbs').html(output).show();});
                    }
                </script>
  4. #3
  5. A Change of Season
    Devshed Frequenter (2500 - 2999 posts)

    Join Date
    Mar 2004
    Location
    Next Door
    Posts
    2,660
    Rep Power
    171
    Originally Posted by web_loone08
    Try this and see what happens:
    Code:
    <script type="text/javascript">
                function update_suburb_dd()
                    {
                        $.post('page.php/'+city, { city: document.form.city.value},function(output){$('#suburbs').html(output).show();});
                    }
                </script>
    Doesn't work!


    Alerts though. But doesn;t update the div:
    javascript Code:
    <script type="text/javascript">
                function update_suburb_dd()
                    {
    			      alert('s');
                      $.post('suburbs.php', { city: document.form.city.value},function(output){$('#suburbs').html(output).show();});
                    }
                </script>
    html Code:
    <select name="city" class="select_1" id="city" onchange="update_suburb_dd();">
    <option value="0">Select a city</option>
    <option value="beaudesert">Beaudesert</option>
    <option value="brisbane">Brisbane</option>
    <option value="gold coast">Gold Coast</option>
    </select>
  6. #4
  7. --
    Devshed Expert (3500 - 3999 posts)

    Join Date
    Jul 2012
    Posts
    3,959
    Rep Power
    1014
    Is this some kind of weird guessing game between you two?

    "Guess my problem!"
    "No, guess what I tried to solve it!"

    But, yeah, keep going. Let's see how many "Try this -- No, don't work" iterations you're willing to go through.

    Comments on this post

    • web_loone08 agrees : Of course it is; it's fun... wanna join?
    The 6 worst sins of security ē How to (properly) access a MySQL database with PHP

    Why canít I use certain words like "drop" as part of my Security Question answers?
    There are certain words used by hackers to try to gain access to systems and manipulate data; therefore, the following words are restricted: "select," "delete," "update," "insert," "drop" and "null".
  8. #5
  9. A Change of Season
    Devshed Frequenter (2500 - 2999 posts)

    Join Date
    Mar 2004
    Location
    Next Door
    Posts
    2,660
    Rep Power
    171
    Fixed. Sorry it was because of XSS protection I was told before!

    What I wonder is that why FireBug deosn't show any errors!
    Last edited by English Breakfast Tea; December 21st, 2013 at 07:29 PM.

IMN logo majestic logo threadwatch logo seochat tools logo