The following warnings occurred:
Warning [2] Undefined variable $unreadreports - Line: 26 - File: global.php(961) : eval()'d code PHP 8.1.2-1ubuntu2.14 (Linux)
File Line Function
/global.php(961) : eval()'d code 26 errorHandler->error
/global.php 961 eval
/printthread.php 16 require_once



UserSpice
put select in selected mode - Printable Version

+- UserSpice (https://userspice.com/forums)
+-- Forum: Support Center (https://userspice.com/forums/forumdisplay.php?fid=23)
+--- Forum: UserSpice 4.3 and Below (https://userspice.com/forums/forumdisplay.php?fid=26)
+--- Thread: put select in selected mode (/showthread.php?tid=638)



put select in selected mode - marceloatmartins - 07-10-2017

Hi Everybody,

Can someone give me a little example to how to put a field select like 'selected' mode when I return of a post-back?

Thanks




put select in selected mode - mudmin - 07-11-2017

Can you explain a little more?


put select in selected mode - firestorm - 07-11-2017

i presume you want to be able to have a select option as selected ? try something like this:

<pre>
Code:
<select id="recaptcha" class="form-control" name="recaptcha">
    <option value="1" <?php if($settings->recaptcha==1) echo 'selected="selected"'; ?> >Yes</option>
    <option value="0" <?php if($settings->recaptcha==0) echo 'selected="selected"'; ?> >No</option>
</select>
</pre>


hope that helps


put select in selected mode - marceloatmartins - 07-12-2017

Hi Everybody,

First of all thank you for yours helps.

Like Firestorm suggested, I put this in my loop to make the options of my select:

<option value="<?=$u->sg_dom;?>" <?php echo ( Input::get('fg_familia_localizada')==$u->sg_dom ? 'selected' : '');?> > <?=$u->ds_dom;?> </option>

When I back from POSTBACK, always mantain the last selected value

It's work well.

Thanks