Forum

Thread tagged as: Question, Problem

Add a selected attribute to a Perch select

Hi,

Is there any way to add a selected attribute to an option within a Perch <select>?

I've found this post (https://forum.grabaperch.com/forum/07-14-2016-option-disabledselected-in-select-input) with an option to add a disabled attribute, but I can't find anything about a selected attribute.

Is this possible?

Thanks for any help.

Simon Kelly

Simon Kelly 0 points

  • 3 years ago
Hussein Al Hammad

Hussein Al Hammad 105 points
Registered Developer

I think you can achieve this using the value attribute:

<perch:input id="sizes" type="select" options="Small,Medium,Large" value="Medium" />

Technically the first option is selected as long as it has a value

Often I do the following and give the first option no value then make the field required so if someone does not select an option the form will not validate

options=“Choose One|,Yes|1,No|0”