Hi,
I'm trying to make a Province and City form with select lists.
For example, based on the Province selection.. will change the available values in City list.
I have the lists boxes pulling from SQL backend .. I just dont know how to apply the criteria.. I understand I have to use an onchange event to call the javascript that will repopulate and apply the criteria to the second box..
I was hoping that you guys could help me with the java part?
Here is my code:
Produce List:
I'm trying to make a Province and City form with select lists.
For example, based on the Province selection.. will change the available values in City list.
I have the lists boxes pulling from SQL backend .. I just dont know how to apply the criteria.. I understand I have to use an onchange event to call the javascript that will repopulate and apply the criteria to the second box..
I was hoping that you guys could help me with the java part?
Here is my code:
Produce List:
Code:
$eclassf_Provincelist = "<select class='tbox' name='eclassf_province' onchange='repopulateAvailability()'>";
$eclassf_arg = "select Distinct Country, Province from `rbidder_cities` where Country = 'Canada'";
if ($sql->db_Select_gen($eclassf_arg, false))
{
$eclassf_current = "";
while ($eclassf_row = $sql->db_Fetch())
{
if ($eclassf_current != $eclassf_row['Province'])
{
$eclassf_current = $eclassf_row['Province'];
//$eclassf_Provincelist .= "<option value='0' disabled='disabled'>" . $eclassf_row['Province'] . "</option>";
}
$eclassf_Provincelist .= "<option value='" . $eclassf_row['Province'] . "'";
if ($eclassf_row['Province'] == $eclassf_province)
{
$eclassf_Provincelist .= " selected='selected'";
}
$eclassf_Provincelist .= ">" . $eclassf_row['Province'] . "</option>";
# print "<br>".$eclassf_current. "- " . $eclassf_row['eclassf_subname'] ;
} // while
$eclassf_Provincelist .= "</select>";
}
else
{
$eclassf_Provincelist .= "<option value='0' >".ECLASSF_51."</select>";
}
$eclassf_Citylist = "<select class='tbox' name='eclassf_City'>";
$eclassf_arg = "select Province, City from `rbidder_cities` where Province = '$eclassf_province'";
if ($sql->db_Select_gen($eclassf_arg, false))
{
$eclassf_current = "";
while ($eclassf_row = $sql->db_Fetch())
{
if ($eclassf_current != $eclassf_row['City'])
{
$eclassf_current = $eclassf_row['City'];
//$eclassf_Citylist .= "<option value='0' disabled='disabled'>" . $eclassf_row['City'] . "</option>";
}
$eclassf_Citylist .= "<option value='" . $eclassf_row['City'] . "'";
if ($eclassf_row['City'] == $eclassf_City)
{
$eclassf_Citylist .= " selected='selected'";
}
$eclassf_Citylist .= ">" . $eclassf_row['City'] . "</option>";
# print "<br>".$eclassf_current. "- " . $eclassf_row['eclassf_subname'] ;
} // while
$eclassf_Citylist .= "</select>";
}
else
{
$eclassf_Citylist .= "<option value='0' >".ECLASSF_51."</select>";
}