javascript - How to make element not to choose first option as selected by default? -
javascript - How to make <select> element not to choose first option as selected by default? -
i'm using jquery interdependencies library building complex form (when show fields depend on values other fields).
so, have <select>
element
<select placeholder="select product id type" id="form_product_id_type" name="form_product_id_type"> <option label="01 - proprietary" value="01">01 - proprietary</option> <option label="02 - isbn-10" value="02">02 - isbn-10</option> <option label="03 - gtin-13" value="03">03 - gtin-13</option> <option label="04 - upc" value="04">04 - upc</option> <option label="05 - ismn-10" value="05">05 - ismn-10</option> ... </select>
if user selects alternative "01" should show field "typedescription" user can describe proprietary id scheme. if user selects other options select -"typedescription" field not appear.
the thing first alternative
<option label="01 - proprietary" value="01">01 - proprietary</option>
is selected default when open page , hence field "typedescription" shown always.
are there ways unselect options <select>
element? goal when user open page should not see field "typedescription".
attached jsfiddle
the way add together empty option.
<select placeholder="select product id type" id="form_product_id_type" name="form_product_id_type"> <option selected value="">select product id type</option> <option label="01 - proprietary" value="01">01 - proprietary</option> <option label="02 - isbn-10" value="02">02 - isbn-10</option> <option label="03 - gtin-13" value="03">03 - gtin-13</option> <option label="04 - upc" value="04">04 - upc</option> <option label="05 - ismn-10" value="05">05 - ismn-10</option> ... </select>
a <select>
has selected; if user hasn't interacted control, , none of <option>
elements have "selected" attribute, first 1 selected.
i'm pretty sure "placeholder" nil on <select>
elements.
javascript jquery html
Comments
Post a Comment