Forums

Home » Liferay Portal » English » 3. Development

Combination View Flat View Tree View
Threads [ Previous | Next ]
l ll
<aui:input type=checkbox
December 19, 2011 12:14 AM
Answer

l ll

Rank: Junior Member

Posts: 71

Join Date: December 12, 2011

Recent Posts

1
2<aui:input name="check" label="1" type="checkbox" value="1"></aui:input>
3<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?

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


1
21
32
Mayur Patel
RE: <aui:input type=checkbox
December 19, 2011 1:18 AM
Answer

Mayur Patel

Rank: Expert

Posts: 341

Join Date: November 17, 2010

Recent Posts

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
l ll
RE: <aui:input type=checkbox
December 19, 2011 3:29 AM
Answer

l ll

Rank: Junior Member

Posts: 71

Join Date: December 12, 2011

Recent Posts

Please example?
Atin Agarwal
RE: <aui:input type=checkbox
August 30, 2012 1:21 AM
Answer

Atin Agarwal

Rank: Junior Member

Posts: 84

Join Date: February 19, 2012

Recent Posts

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