user2110365
user2110365

Reputation: 1

how do i make a select box populate div on change

so, I have read just about every question on this subject, but the solutions don't work for my project, it seems that when I change the dropdown, it does the first event, but when I change to a different element it doesn't do anything else, but when I do this with an alert message it changes every time.

here is what I have to demonstrate what I mean

I tried .post it works great until I add php and all the dynamic functions, is it because I used $('#updateDiv').html(url);

I also hide and showed the div based on the change of the dropdown, but all that did was hid and show the div, I want the div to show the content based on a list of categories.

the PHP side will be dynamic, but if I do .html() none of the php renders properly.

http://fiddle.jshell.net/LrxUS/

Upvotes: 0

Views: 249

Answers (3)

Gaurav Pandey
Gaurav Pandey

Reputation: 2796

Ok, lets make it the simplest so that there is no room for mistake in the client side script. Use $.load method defined here.

AS:

$("#updateDiv").load(url);

And don't forget to check what your firebug, chrome inspector or fiddler says about your request in case if you don't get the required result.

Upvotes: 0

Eggplant
Eggplant

Reputation: 2013

$.post(url, function(data) {
    $("#updateDiv").html(data);
});

Upvotes: 1

Sudip
Sudip

Reputation: 2051

As per the fiddle, you have specified

var mydropdown = $('#mydropdown');

but in the change function, you have specified $(mydropdown), either define only id in the variable or the object. Like,

var mydropdown = '#mydropdown';
$(mydropdown).change(function() {}

After that use $.ajax to get the dynamic content.

Upvotes: 0

Related Questions