0

I have two drop down list on a form:

<select id="slctFirm">
<?php
$firmObj = new dbFirm($myDB);
echo $firmObj->DropdownOptions();
?> 

<select id="slctPerson">
<?php
$personObj = new dbPerson($myDB);
echo $personObj ->DropdownOptions();
?> 

the PHP code is calling an object I have created to generate the lists for the two drop downs. The second list is populated with the people belonging to the firm selected in the first drop down. Now the problem is that the first list retrieve only the firms' name and order them in alphabetical order as I don't want the firms IDs to appear in the first drop down list. In order to filter the second list I need the IDs but I don't know how to store this ids in the first drop down without them appearing in the list? Hope this makes sense.

Ry-
  • 218,210
  • 55
  • 464
  • 476
user1956370
  • 55
  • 1
  • 1
  • 5
  • See this - http://stackoverflow.com/questions/877328/jquery-disable-select-options-based-on-radio-selected-need-support-for-all-brow/878331#878331 – web-nomad Feb 06 '13 at 08:13
  • Ajax would be a much better fit for this...selectively populate the second dropdown based on first's selection. – web-nomad Feb 06 '13 at 08:16

1 Answers1

3

each Firm could have a value on it's option tag that can store the id

<option value="10">Firm Name</option>

So you can get it using jQuery easily

alert($("#slctFirm").val());
Omid
  • 4,575
  • 9
  • 43
  • 74
  • If this is the answer the QA was asking for, i was clearly overthinking this :) I was on the path of using ajax to keep the id's from being client side. But yes :) I think the QA just doesn't want to show the id's in the select list. Nice. +1 – Damien Overeem Feb 06 '13 at 08:16