Jump to content

[SOLVED] selected value problem


shadiadiph

Recommended Posts

I have a section which the value is definately Yes in the database but it keeps showing No as the selected value I already did a print $clientview; value statement to make sure the value is Yes.

butthe select part isn't working isn't looks fine to me??

 

<?
$clientview = $row["clientview"]; *// this is in the head the value is Yes //
?>


<?
if ($action == modify)
{
echo'<tr>
<td id="t_clientview" class="head">CLIENT VIEW</td></tr>
<tr>
<td class="norm">
<select name="clientview" >
<option value="No"  if('.$clientview.'==No){selected}>No 
<option value="Yes" if('.$clientview.'==Yes){selected}>Yes 
</select>
</td>
</tr>';
}
?>

 

Link to comment
https://forums.phpfreaks.com/topic/141070-solved-selected-value-problem/
Share on other sites

Break up your code some... so you can see what you're echo'ing and what you're not.  Instead of the above, do this:

<?php
if ($action == modify)
{
?>
<!-- HTML HERE -->
<?php } ?>

 

... and for checking the selected part (as an example), do:

<option value="No" <?php if($clientview=='No'){echo 'selected'; }?>>No</option>

i change li'l bit in ur code, try this

<?php
$clientview = "Yes"; 

if($action == modify)
{
echo"<tr><td id=\"t_clientview\" class=\"head\">CLIENT VIEW</td></tr>
<tr>
<td class=\"norm\">
<select name=\"clientview\" >
<option value=\"No\"";
if($clientview=="No"){echo "selected";}
echo ">No
<option value=\"Yes\"";
if($clientview=="Yes"){echo "selected";}
echo ">Yes
</select>
</td>
</tr>";
}
?>

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.