Hello all,

I have a dialog window with a jqgrid. Wihin the jqgrid I have. multiple dropdows, one for each of the 50 states. And each state takes a different row. Depending on what is going on from output in a database each one of those states is to have a different option selected in their respective dropdown.

My problem is both, the select box it self has an id, and each option within the select box has its own id. Is there any function within jquery that will allow to me access the id of the selectbox and alter an attribute of an option with a different id. All in a single command?

I have tried using PHP to sovle this problem but have failed.

Any help would be apreciated.

Id post the code, but its in an MVC framework and ITS A LOT!!!

but a basic break down of how it looks goes as such:

<table>
  <tr>
     <td> New York</td>
     <td>    
        <select id ='State'>
        <option id='tax_code' value='tax_code'> </option>
      </td>
    </tr>
    </table> 

    //this is done once for each of the states!! 

I don't entirely understand the description. So you have a drop down with 50 states and another drop down with another list of options that you want to alter depending on which state was chosen from the first drop down?

@pixelsoul;i think he is refering to change one drop down vaue on the basis of another drop down value.
@soapyillusion:- yes it is possible by doing ajax call.
Onchange event of first drop down make an ajax call to php page with selected value(using document.getElementById('id').value) and then in that php page on the basis of input ,get data and return back data and then populate data in second drop down.
Eg:-this

Sorry I wasnt descriptive, enough its kinda hard to describe.

There is table, each row represents a state and within each row is a drop down with a list of codes. Once the page is loaded, information from a database is pulled. depending upon what the database results say, the option selected in individual drop downs will change. While ones not in the database will remain on a default value.

So for instance, say the database says the state of new york is set to tax_code_2 and Texas is set to tax_code_3. SO in the table, the new york row, and texas row will have the options set respectivly. While the rest of the 48 states are still set to the default.

Im trying to figure out away to select the parent selectbox with the correct state_id and its child option. In the same command.

The best I can get is selecting either just the selectbox or its option.

Yes I have given solution for the same thing. You have to make ajax call on change of first select box value and populate second select box from the response of ajax call. Just check the links provided above.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.