redio id

Confluence User - 03 Sep, 2018

community,

joget generate radio name "email_wp_employee" by

<div class="form-cell">
    <label class="label">Send email to Employee <span class="form-cell-validator"></span></label>
    <div class="form-cell-value" id="email_wp_employee2147132">
        <label>
            <input grouping="" id="email_wp_employee" name="email_wp_employee" value="Yes" type="radio">
            Yes
        </label>
        <label>
            <input grouping="" id="email_wp_employee" name="email_wp_employee" value="No" checked="checked" type="radio">
            No
        </label>
    </div>
    <div style="clear:both;"></div>
</div>

when used jquery select by

$('#email_wp_employee').length

it return 1

and when used

$('input:#email_wp_employee').lengt

it return 2

FormUtil.getField('email_wp_employee').length

it return 2

reference standart from https://www.w3.org/WAI/UA/TS/html401/cp0101/0101-RADIO.html

<form action="../action/return.html" method="post" enctype="application/x-www-form-urlencoded">
  <label for="button1">Button 1: </label>
  <input id="button1" type="radio" value="1" name="radio-input" checked="checked"></input>
  <br clear="none"></br>
  <label for="button2">Button 2: </label>
  <input id="button2" type="radio" value="2" name="radio-input"></input>
</form>

each input have same name but dfferance id.

https://www.w3.org/TR/2011/WD-html5-20110525/elements.html#the-id-attribute

The id attribute specifies its element's unique identifier (ID). The value must be unique amongst all the IDs in the element's home subtree and must contain at least one character. The value must not contain any space characters.

i think better if joget generate redio by same name but dfferance id for prevent bug and keep standart.

respect

pitt phunsanit
form;jquery;radio;javascript;templates

1


04 Sep, 2018
confluenceUser
confluenceUser

Hi, if several HTML elements have the same ID and you need select a specific one, in jquery you could use the :eq selector https://api.jquery.com/eq-selector/. So for example to get first input you could use $('input#email_wp_employee:eq(0)')

RELATED QUESTIONS

Your answer


To answer a question you'll need an account.

Print