Hi Scott, 

I may not understand the details of your situation, but it seems you are
quite close to the first part of a solution (I am no expert either). 

Could you just give each of your <select> fields a common class name as well
as the unique id:

<select id="type_1" class="dynamicSelects">
        <!-- options here -->
</select>
<select id="type_2" class="dynamicSelects">
        <!-- options here -->
</select>

And then your jQuery code could look like something this?

    $("select.dynamicSelects").change(function() {
       var type = $(this).val();
       $.post("/ajax/get_material_list.php", {type:type}, function(xml) {

          ... function body to process the xml results here...
          )};
       )};


That would apply your operation to all of the <select> fields that were
assigned class="dynamicSelects". And if you had all of these <select> fields
inside a container such as a <fieldset> tag that had an id), 

<form>
<fieldset id="magicSelectFields"> 
<select id="type_1">
        <!-- options here -->
</select>
<select id="type_2">
        <!-- options here -->
</select>
</fieldset>
</form>

then you could avoid having to add a class to every select field and just
make your jQuery code "select" your select boxes like this:

    $("#magicSelectFields select").change(function() {
       var type = $(this).val();
       $.post("/ajax/get_material_list.php", {type:type}, function(xml) {

          ... function body to process the xml results here...
          )};
       )};

You can Google "CSS Selectors" to learn more about the various ways to
specify particular elements and groups of elements within a document. There
is a lot of flexibility in this department.

This doesn't really help with any of the ajax-y stuff you're trying to do,
but that's a question for someone other than me. :)

Cheers,
-THEO- 




-----Original Message-----
From: Scott Sharkey [mailto:[EMAIL PROTECTED] 
Sent: Friday, November 10, 2006 8:59 AM
To: discuss@jquery.com
Subject: [jQuery] [Fwd: How to Add HTML to a page, and make it "active"?]

I *think* that I can do something like:

    $("#type_1").change(function() {
       var type = $("#type_1").val();
       $.post("/ajax/get_material_list.php", {type:type}, function(xml) {

          ... function body to process the xml results here...
          )};
       )};

except, of course that "#type_1" above needs to be a Javascript variable
string, rather than a constant.  

-Scott




_______________________________________________
jQuery mailing list
discuss@jquery.com
http://jquery.com/discuss/

Reply via email to