/    Sign up×
Community /Pin to ProfileBookmark

Urgent, please help!!

hi,

I have a question on how to pass varibales from a form to javascript functions within a for loop in jsp. I have the code below and I want to perform the following. In the beginning, all check boxes are disabled. When the user choose somthing in the select menu, the check boxes are enabled. Then when Check01 is checked and Check02 will be checked as well.

<script language=”javascript”>
function selected(prop) {
for (i=0; i<2; i++)
prop[i].disabled = false;
}
function checked(prop) {
if (prop[0].checked)
prop[1].checked = true;
}
</script>

<form action=”test_action.jsp” method=”post” name=”table”>
<% for (int i=0; i<3; i++) { %>
<select name=”fieldtype<%=i%>” size=1 onChange=”selected(??)”>
<option></option>
<option value=”1″>Option1</option>
<option value=”2″>Option2</option>
</select><br>
<input type=”checkbox” name=”prop<%=i%>” value=”c1″ onClick=”checked(??)” disabled />
Check01<br>
<input type=”checkbox” name=”prop<%=i%>” value=”c2″ disabled/>
Check02<br>
<% } %>
</form>

I try the following methods but not work:
(1)
onChange=”selected(this.form.prop'<%=i%>’)” and onClick=”checked(this.form.prop'<%=i%>’)”
(2)
onChange=”selected(‘this.form.prop<%=i%>’)” and onClick=”checked(‘this.form.prop<%=i%>’)”
(3)
String prop = “this.form.prop” + i; //within the for loop
onChange=”selected(‘<%=prop%>’)” and onClick=”checked(‘<%=prop%>’)”

Please help!

thx very much
ypc

to post a comment
JavaScript

0Be the first to comment 😎

×

Success!

Help @yupong 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 5.18,
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: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

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