/    Sign up×
Community /Pin to ProfileBookmark

Dynamic enable disable…

I’m gathering a list of values from a SQL database and creating checkboxes and text fields that store the values in an array… I want to be able to dynamically have the user either check, or uncheck the checkbox so that the corrisponding checkbox will be enabled or disabled..

here is the javascript I’m using:

[CODE]<SCRIPT LANGUAGE=”JavaScript”><!–
function enabledisable(whatNum) {
if(document.frmUpdateUser.chkType[whatNum].checked) {
document.frmUpdateUser.numMonth[whatNum].disabled=false;
} else {
document.frmUpdateUser.numMonth[whatNum].disabled=true;
document.frmUpdateUser.numMonth[whatNum].text=””;
}
}
//–>
</SCRIPT>[/CODE]

And here is an example of part of the form that I want it to enable and disable.. this is AFTER the ASP has displayed the the check boxes and text boxes:

[CODE]<tr>
<td><input class=”checkBoxes” name=”chkType[]” type=”checkbox” value=”1″ onClick=”enabledisable(1)” checked />&nbsp;&nbsp;Driving Record<br></td>
<td valign=”top”>Allowed Per Month: <input name=”numMonth[]” type=”text” class=”checkBoxes” style=”width:20px” value=”5″ /></td>
</tr>

<tr>
<td><input class=”checkBoxes” name=”chkType[]” type=”checkbox” value=” 2″ onClick=”enabledisable(2)” />&nbsp;&nbsp;Vehicle Registration<br></td>
<td valign=”top”>Allowed Per Month: <input name=”numMonth[]” type=”text” disabled class=”checkBoxes” style=”width:20px” /></td>
</tr>

<tr>
<td><input class=”checkBoxes” name=”chkType[]” type=”checkbox” value=” 3″ onClick=”enabledisable(3)” />&nbsp;&nbsp;Credit Records<br></td>
<td valign=”top”>Allowed Per Month: <input name=”numMonth[]” type=”text” disabled class=”checkBoxes” style=”width:20px” /></td>
</tr>

[/CODE]

to post a comment
JavaScript

0Be the first to comment 😎

×

Success!

Help @djanim8 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.14,
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,
)...