Jump to content

Saving the value in a drop down menu


cdoggg94

Recommended Posts

This is not an easy thing to explain, hopefully someone will understand

 

What I am trying to do is display an image if the "Yes" is selected and get rid of the image if "No" is selected.

 

I have a "Pick one" option, "Yes", and "No".

 

When the form is submitted "Yes" the image displays fine.  My problem is that when the form is submitted with other entries and the selection is left alone the image still disappears.

 

I have tried to save the database information as the value of "Pick One" so that if it is left alone it keeps what ever value it had.

 

this is what the selection code looks like:

 

<td width="37" style="border:1px solid #999;"><div align="center">
           <select name="pack1">
             <option selected="selected" value="
             <?php
		$imageTitle = "<img src='images/check-mark.png' height='10' width='10' />";
		 if($det['check_1']=="Yes"){
		 	$pic = $imageTitle;
		 	echo $pic;
		 }

		 if($det['check_1']=="No"){
		 	$pic = "No";
		 	echo $pic;
		 }
		 ?>
             ">Pick One</option>
             <option value="Yes">Yes</option>
             <option value="No">No</option> 
            
           </select>
          </div></td>
          <td width="205" style="border:1px solid #999;">Package One
           <?php
	   if($det['check_1']=="Yes"){
	    echo $imageTitle;
	   }else{
	   echo $pic;
	   }
	  //if($det['check_1']=="<img src='images/check-mark.png' height='10' width='10' />"){
	  	//echo "<img src='images/check-mark.png' height='10' width='10' />";
	  //}
	  
	  //if($det['check_1']=="" or $det['check_1']=="No"){
	  //	echo "No";
	  //}
	  ?>
          </td>

 

The image that is attached if the complete form.  The code above is for the first row only.

 

post-110186-13482403593268_thumb.jpg

Link to comment
https://forums.phpfreaks.com/topic/264173-saving-the-value-in-a-drop-down-menu/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.