Jump to content

Recommended Posts

I'm trying to set the value of a YES/NO Option from a recordset so that the end user can edit the field if needed.

 

Just reaching out for some solution... this didn't work.

 

<select size="1" name="pol_mortgage" tabindex="32" class="form-inputitem"></option>
<option value="<?php echo htmlentities($row_rstocdetail['mortgage'], ENT_COMPAT, 'utf-8'); ?>"><?php echo htmlentities($row_rstocdetail['mortgage'], ENT_COMPAT, 'utf-8'); ?></option>
<option value="Y">YES</option>
<option value="N">NO</option></select>

is the field 'pol_mortgage' or 'mortgage' ?

heres two options

<select size="1" name="pol_mortgage" tabindex="32" class="form-inputitem"></option>

<?php
if(strtolower($row_rstocdetail['pol_mortgage'])=="y")
{
echo "<option value=\"Y\" selected=\"selected\">YES</option>";
echo "<option value=\"N\">NO</option>";
}else{
echo "<option value=\"Y\">YES</option>";
echo "<option value=\"N\" selected=\"selected\">NO</option>";
}
?>
</select>

OR

<select size="1" name="pol_mortgage" tabindex="32" class="form-inputitem"></option>

<select size="1" name="pol_mortgage" tabindex="32" class="form-inputitem"></option>

<?php
$sel = (strtolower($row_rstocdetail['pol_mortgage'])=="y")
?>
<option value="Y" <?php echo ($sel)?"selected=\"selected\"":"";?>>YES</option>";
<option value="N" <?php echo (!$sel)?"selected=\"selected\"":"";?>>NO</option>";
</select>
?>

It also has an empty/null option.. is that feasible to add into that?

Just add a blank one at the top

<option value=""></option>";

is neither are selected then its the default

 

So there really no need for a single line - I see. Can you also perform a CASE statement similarly?

 

You could do this in a case statement but its only 2 options this or that! so if seams better

of course you could do this

<option value="" <?php echo ($row_rstocdetail['pol_mortgage']="")?"selected=\"selected\"":"";?>></option>"
<option value="Y" <?php echo ($row_rstocdetail['pol_mortgage']="Y")?"selected=\"selected\"":"";?>>YES</option>";
<option value="N" <?php echo ($row_rstocdetail['pol_mortgage']="N")?"selected=\"selected\"":"";?>>NO</option>"
<option value="M" <?php echo ($row_rstocdetail['pol_mortgage']="M")?"selected=\"selected\"":"";?>>MayBe</option>"

Since the Option has a blank option the field in the DB can be ISNULL which when using the following gives me "NO" as opposed to a blank?

 

<option value="" <?php echo ($row_rstocdetail['pol_mortgage']="")?"selected=\"selected\"":"";?>></option>"
<option value="Y" <?php echo ($row_rstocdetail['pol_mortgage']="Y")?"selected=\"selected\"":"";?>>YES</option>";
<option value="N" <?php echo ($row_rstocdetail['pol_mortgage']="N")?"selected=\"selected\"":"";?>>NO</option>"
<option value="M" <?php echo ($row_rstocdetail['pol_mortgage']="M")?"selected=\"selected\"":"";?>>MayBe</option>"

 

Can I actually test for ISNULL and set the option to be blank?

 

Thanks.

 

A JM,

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.