Jump to content

help with dropdown list


gudfry

Recommended Posts

hi all;

    Sory for disturbanced, Im just newbie in PHP really needed your help :), basically i have created three dropdown list. but I got a problem to display the value on selected category. here is my problem,

     

    I create a three dropdown list which is passing each parameter, when I select the first dropdown list, the second and the third dropdown list is going to change base on the parameter I inputed, and alo it display the value base on get the id, which is i have no problem in my first selection, my problem is, when i select the value on second dropdown list I cannot display the value on for the  second selector and desame with the third dropdown list.

 

here is my code..

 

<p>     

<select name="select" style="width:200px" onchange="myRegion()">

 

<option value="all">Region</option>

 

<?php

$ForRegion=region::getAllRegion();

if (!isError($ForRegion)){

foreach ($ForRegion as $element => $value) {

echo '<option value="'.$value->Region_id.'"';

if ($value->Region_id==@$region)

echo ' selected="selected"';

echo '>'.$value->displayName.'</option>';

}

}

?>

</select>

 

<input type="hidden" name="menu" value="region"></input>

</p>

</form>

<form id="myProvince" method="get" action="index.php">

<p>     

<select name="select" style="width:200px" onchange="myProvince()">

 

<option value="all">Province</option>

 

<?php

 

$ForProvince=province::getProvinceById($region);

if (!isError($ForProvince)){

foreach ($ForProvince as $element => $value) {

echo '<option value="'.$value->Province_id.'"';

if ($value->Province_id==@$province)

echo ' selected="selected"';

echo '>'.$value->displayName.'</option>';

}

}

 

?>

</select>

<input type="hidden" name="menu" value="province"></input>

</p>

</form>

<form id="myForm" method="get" action="index.php">

<p>     

<select name="select" style="width:200px" onchange="formS()">

<option value="all">All cities</option>

<?php

$cities=city::getCitiesById($region);

if (!isError($cities)){

foreach ($cities as $element => $value) {

echo '<option value="'.$value->City_id.'"';

if ($value->City_id==@$city)

echo ' selected="selected"';

echo '>'.$value->displayName.'</option>';

}

}

?>

</select>

 

<input type="hidden" name="menu" value="city"></input>

</p>

</form>

 

hope anyone can help me. because I lost my power

Link to comment
Share on other sites

I hate to be the barer of bad news, but it looks like you are going to have to delve into the world of Javascript to get the drop down lists to do your bidding.  I personally do NOT know how to handle your request, but I have seen some people do what you are asking.

 

If you try to do it with PHP you're going to run into the problem of having to refresh the page and use a submit button with each drop down.  That gets cumbersome and annoying to the end user.  My suggestion is to Google js drop-down changing.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.