/    Sign up×
Community /Pin to ProfileBookmark

problem about checkbox

Hi friends,
I wish successes to everybody!

My question is such:

When i change the value of the following code (value=”0″) that is shown in the situation to checked
But when i click the submit button nothing is generated so how to get my page on checked state?

[U]JSP side:[/U]
<html-el:checkbox name=”scriptGeneratorForm”
property=”classPropertyList[${ctr}].selected”
styleId=”classPropertyList[${ctr}].selected” value=”1″
tabindex=”1″/>

[U]Program side:[/U]
List<ClassProperty> mainList = new ArrayList<ClassProperty>();
for (int i = 0; i < classPropertyList.size(); i++) {
ClassProperty classProperty = (ClassProperty) classPropertyList.get(i);
if (classProperty.getSelected() == 1) {
mainList.add(classProperty);
}
}

Thanks beforehand!

to post a comment
JavaScript

4 Comments(s)

Copy linkTweet thisAlerts:
@FangJan 14.2009 — Post the generated html and valid JavaScript code
Copy linkTweet thisAlerts:
@RizvanauthorJan 14.2009 — Dear [B]Fang[/B] - Thanks a lot for your reply,

[U][B]Here's my generated HTML code:[/B][/U]
[code=php]
.........................................
<input type="hidden" name="classPropertyList[0].propertyName" value="fkPersonId" id="classPropertyList[0].propertyName">
<tr>

<td width="50" align="center">
<input type="checkbox" name="classPropertyList[0].selected" tabindex="1" value="0" checked="checked" id="classPropertyList[0].selected">
</td>
<td width="250">
fkPersonId
</td>
<td width="300">
<input type="text" name="classPropertyList[0].propertyOracleName" maxlength="255" size="50" tabindex="3" value="FK_PERSON_ID" id="classPropertyList[0].propertyOracleName">
</td>

<td width="100">
<select name="classPropertyList[0].oracleType.id" tabindex="4" id="classPropertyList[0].oracleType.id" class="x-form-text x-form-field"><option value="-1">Se&#231;in</option>
<option value="1">VARCHAR2</option>
<option value="2" selected="selected">NUMBER</option>
<option value="3">INTEGER</option>
<option value="4">DATE</option>
<option value="5">DOUBLE</option>
<option value="6">REAL</option>

<option value="7">DECIMAL</option>
<option value="8">SMALLINT</option>
<option value="9">CLOB</option>
<option value="10">BLOB</option>
<option value="11">RAW</option></select>
</td>
<td width="50" align="center">
<input type="text" name="classPropertyList[0].oracleType.defaultWidth" maxlength="4" size="4" tabindex="5" value="0" id="classPropertyList[0].oracleType.defaultWidth">
</td>

<td width="50" align="center">
<input type="text" name="classPropertyList[0].priority" maxlength="5" size="5" tabindex="6" value="1" id="classPropertyList[0].priority">
</tr>


<input type="hidden" name="classPropertyList[1].propertyName" value="fkEmployeeId" id="classPropertyList[1].propertyName">
<tr>
<td width="50" align="center">
<input type="checkbox" name="classPropertyList[1].selected" tabindex="1" value="0" checked="checked" id="classPropertyList[1].selected">
</td>
<td width="250">

fkEmployeeId
</td>
<td width="300">
<input type="text" name="classPropertyList[1].propertyOracleName" maxlength="255" size="50" tabindex="3" value="FK_EMPLOYEE_ID" id="classPropertyList[1].propertyOracleName">
</td>
<td width="100">
<select name="classPropertyList[1].oracleType.id" tabindex="4" id="classPropertyList[1].oracleType.id" class="x-form-text x-form-field"><option value="-1">Se&#231;in</option>
<option value="1">VARCHAR2</option>
<option value="2" selected="selected">NUMBER</option>

<option value="3">INTEGER</option>
<option value="4">DATE</option>
<option value="5">DOUBLE</option>
<option value="6">REAL</option>
<option value="7">DECIMAL</option>
<option value="8">SMALLINT</option>
<option value="9">CLOB</option>
<option value="10">BLOB</option>
<option value="11">RAW</option></select>

</td>
<td width="50" align="center">
<input type="text" name="classPropertyList[1].oracleType.defaultWidth" maxlength="4" size="4" tabindex="5" value="0" id="classPropertyList[1].oracleType.defaultWidth">
</td>
<td width="50" align="center">
<input type="text" name="classPropertyList[1].priority" maxlength="5" size="5" tabindex="6" value="2" id="classPropertyList[1].priority">
</tr>


<input type="hidden" name="classPropertyList[2].propertyName" value="fkEducationLevelId" id="classPropertyList[2].propertyName">
<tr>

<td width="50" align="center">
<input type="checkbox" name="classPropertyList[2].selected" tabindex="1" value="0" checked="checked" id="classPropertyList[2].selected">
</td>
<td width="250">
fkEducationLevelId
</td>
<td width="300">
<input type="text" name="classPropertyList[2].propertyOracleName" maxlength="255" size="50" tabindex="3" value="FK_EDUCATION_LEVEL_ID" id="classPropertyList[2].propertyOracleName">
</td>

<td width="100">
<select name="classPropertyList[2].oracleType.id" tabindex="4" id="classPropertyList[2].oracleType.id" class="x-form-text x-form-field"><option value="-1">Se&#231;in</option>
<option value="1">VARCHAR2</option>
<option value="2" selected="selected">NUMBER</option>
<option value="3">INTEGER</option>
<option value="4">DATE</option>
<option value="5">DOUBLE</option>
<option value="6">REAL</option>

<option value="7">DECIMAL</option>
<option value="8">SMALLINT</option>
<option value="9">CLOB</option>
<option value="10">BLOB</option>
<option value="11">RAW</option></select>
</td>
<td width="50" align="center">
<input type="text" name="classPropertyList[2].oracleType.defaultWidth" maxlength="4" size="4" tabindex="5" value="0" id="classPropertyList[2].oracleType.defaultWidth">
</td>

<td width="50" align="center">
<input type="text" name="classPropertyList[2].priority" maxlength="5" size="5" tabindex="6" value="3" id="classPropertyList[2].priority">
</tr>
.................................................
[/code]

[U][B]

And JavaScript code:[/B]
[/U]

[code=php]
......................................................
<td width="50" align="center">
<html-el:checkbox name="scriptGeneratorForm"
property="classPropertyList[${ctr}].selected"
styleId="classPropertyList[${ctr}].selected" value="0"
tabindex="1"/>
</td>
......................................................
[/code]

[U][B]

And program side:[/B]
[/U]

[code=php]
....................................
List<ClassProperty> mainList = new ArrayList<ClassProperty>();
for (int i = 0; i < classPropertyList.size(); i++) {
ClassProperty classProperty = (ClassProperty) classPropertyList.get(i);
if (classProperty.getSelected() == 1) {
mainList.add(classProperty);
}
}
..................................
[/code]


Thanks again!
Copy linkTweet thisAlerts:
@RizvanauthorJan 14.2009 — Dear friends,

[B]I also want to add about my JavaScript code therefore sorry which i did not write at first:[/B]

<logic-el:iterate id="classProperty"

name="<&#37;=AdminConstantKeys.CLASS_PROPERTY_LIST_SESSION_KEY%>"

type="az.admin.model.ClassProperty" indexId="ctr">

<html-el:hidden property="classPropertyList[${ctr}].propertyName"
styleId="classPropertyList[${ctr}].propertyName"/>
<tr>
<td width="50" align="center">
[B]<html-el:checkbox name="scriptGeneratorForm"
property="classPropertyList[${ctr}].selected"
styleId="classPropertyList[${ctr}].selected" value="0"
tabindex="1"/>[/B]
</td>

I don't understand that why it isn't generated with checked state...?

Thanks again.
Copy linkTweet thisAlerts:
@FangJan 14.2009 — The [I]value[/I] has nothing to do with the checked state.

The generated code is invalid; the hidden controls can not be placed between <tr> elements.

The form must validate for name/value pairs to be returned correctly.

There is no JavaScript in your code, only server side coding.
×

Success!

Help @Rizvan spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 4.29,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,

tipper: @Samric24,
tipped: article
amount: 1000 SATS,
)...