Forums de discussion

<aui:input type=checkbox

ildar i, modifié il y a 12 années.

<aui:input type=checkbox

Regular Member Publications: 158 Date d'inscription: 12/12/11 Publications récentes

<aui:input name="check" label="1" type="checkbox" value="1"></aui:input>
<aui:input name="check" label="2" type="checkbox" value="2"></aui:input>


The form sends both parameters, regardless of which fields are marked. What is wrong?


int[] selectedColours = ParamUtil.getIntegerValues(actionRequest, "check");
        for (int wer : selectedColours){
        	System.out.println(wer);
        }



1
2
thumbnail
Mayur Patel, modifié il y a 12 années.

RE: <aui:input type=checkbox

Expert Publications: 358 Date d'inscription: 17/11/10 Publications récentes
Right now you've provided values into value field that will select check-box by default,Give it as blank if you don't want to select as checked on load of Page.

aui:input is using the value attribute to set the checked flag,

Refer this link to see how its working,
http://www.liferay.com/community/forums/-/message_boards/message/4231543

Regards,
Mayur
ildar i, modifié il y a 12 années.

RE: <aui:input type=checkbox

Regular Member Publications: 158 Date d'inscription: 12/12/11 Publications récentes
Please example?
thumbnail
Aditya Rao, modifié il y a 11 années.

RE: <aui:input type=checkbox

Junior Member Publications: 86 Date d'inscription: 20/02/12 Publications récentes
Actually i have encountered this same problem.
Whenever i tried to check if the checkbox is checked or not it was always showing false even if it was checked.
Like i wrote:
<aui:input name="xyz" type="checkbox" />

And in javascript :

function validateCheckBox() {
var status = document.getElementById("<portlet:namespace />xyz").checked;
alert(status); // to see if it is checked or not
}

It was always displaying false even when i checked it, which is wrong.
After some R&D I came to know that in AUI if the input type type is checkbox then it appends "Checkbox" to the name of the field.
like in my case name of the field i gave was "xyz" but it was making : "xyzCheckbox". It automatically adds this redundant string "Checkbox" at the end of the name you give.

So if we want to let it execute we have to write something like :

function validateCheckBox() {
var status = document.getElementById("<portlet:namespace />xyzCheckbox").checked;
alert(status); // now it will display as per our assumption
}

Regards
Atin Agarwal