开发者

Converting checkbox to select (perl)

开发者 https://www.devze.com 2023-01-06 02:04 出处:网络
Before: <input type=\'checkbox\' name=\'killerFeature\' id=\'killerFeature\' <%= param(\'killerFeature\') ? \' checked\' : \'\'%>

Before:

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

Now:

<select name="killerFeature" id="killerFeature" class="selec开发者_JAVA百科t">
    <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!


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:)

0

精彩评论

暂无评论...
验证码 换一张
取 消