|
|
|||||||||
|
|||||||||
|
|||||||||
| |
|||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
hi all,
i have searched forums but not found what i need. I have a drop down multiple select box which the users must choose at least one option. Once the form is processed it calls itself dispplaying all the details the user has filled in. Now the drop down list is populated froma db but once the user has already selected values before the page calls its self a check must be done to highlight the values they previously selected. (HOPE THIS IS MAKING SENSE!) I have this accomplished but it the only value to be selected is the is the second choice ie if a user selects golf and tennins only the tennins would be selected. the below code is what i have used. echo " <select name="selectCylinderType[]" multiple> echo" <option value='0'>Please Select</option>"; while($row=mysql_fetch_array($result)) { //code to check if the user has made a previous chose in the db //and if so highlight it in the drop down first check that the passed values // the $strFKeyValue is a string holding the values the user selected used the foreach... string1,string2, to fill the variable $arraybreakdown = explode(",", $strFKeyValue); $arrayLength= count($arraybreakdown); //echo "<br>the length is $arrayLength"; for($p=0; $p < $arrayLength-1; $p++) { //echo "<br>the break down is $arraybreakdown[$p]"; this works fine and prints out the users choice if ($row[$strPrimaryKey] == $arraybreakdown[$p]) { // set the variable $selected to selected if records match $strSelected ="selected"; } else { // leave it blank if records not found $strSelected=""; } } //end of for //print to screen the options in the drop down menu //the value is the primary key and the option is the fieldname (passed to the function). echo "<OPTION VALUE=".$row[$strPrimaryKey]." $strSelected> ".$row[$strFieldName]."</OPTION>"; } //end of while please help i think i need some php similar to javascripts control.selected to go in the variable strSelected but need php |
|
#2
|
|||
|
|||
|
is anyone going to reply
will someone please help!!!
|
|
#3
|
|||
|
|||
|
i didnt get the problem actually.
do you want to get what all values were selected by the user? just check out the following site. if u still dont get any solution,just send what the problem is. http://www.onlinetools.org/tricks/using_multiple_select.php |
|
#4
|
|||
|
|||
|
The problem looks like it's within the for loop, try this one:
PHP Code:
|
![]() |
| Viewing: Dev Articles Community Forums > Programming > PHP Development > selected value problem with multiple select box |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|