Question

Before:

<input type='checkbox' name='killerFeature' id='killerFeature' 
    <%= param('killerFeature') ? ' checked' : ''%> 
/>

Now:

<select name="killerFeature" id="killerFeature" class="select">
    <option value="1">Enable</option>
    <option value="0">Disable</option>
</select>

How do I insert the same checked (should be 'selected' now I guess?) condition in the select now?

This is a perl app, built using Mojolicious web framework.

Many thanks for your help!

Was it helpful?

Solution

Yes, the condition should be selected (selected="selected") but i belive you already figured that out from your other post :)

<select name="killerFeature" id="killerFeature" class="select">
    <option value="1" selected="selected">Enable</option>
    <option value="0">Disable</option>
</select>

Also from what i saw there inst a way to create the select like you can for the input as in the below example:

<%= input 'test', type => 'text' %>

So it would be something like:

<%== param('killerFeature') eq $my_var ? ' selected="selected"' : ''; %>

Ofc you would need to replace the above to your current variables and field names.

GL:)

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top