2

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!

1 Answer 1

2

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

Sign up to request clarification or add additional context in comments.

1 Comment

W3C requires there to be a left and right hand. Instead of 'selected' it should be 'selected="selected"'.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.