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