By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
457,732 Members | 841 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 457,732 IT Pros & Developers. It's quick & easy.

making checkbox non-editable

P: n/a
Hi,

I've few checkboxes in different rows. After selecting appropriate
values, the user should click a button. I wanted to convert those
checkbox values to non-editable(or non-editable textboxes), so that
user cannot change the value again after the needed functionality(this
is in java script) completes. So my problem is that how should i
manipulate the page through java script to set the field noneditable.

Please suggest.

Thanks,
Biswaranjan

Apr 28 '06 #1
Share this Question
Share on Google+
4 Replies


P: n/a
Also I can get the IDs of the checkboxes in java script function.

Biswaranjan

Apr 28 '06 #2

P: n/a
biswaranjan.rath said on 28/04/2006 3:54 PM AEST:
Hi,

I've few checkboxes in different rows. After selecting appropriate
values, the user should click a button. I wanted to convert those
checkbox values to non-editable(or non-editable textboxes), so that
user cannot change the value again after the needed functionality(this
is in java script) completes. So my problem is that how should i
manipulate the page through java script to set the field noneditable.

Please suggest.


Set the disabled attribute of any unchecked radios to true, then the
user can't select any other option.

If scripting is disabled/not available, it won't work. If there's a
reset button, the user can reset the form and clear the selections
anyway. There are probably other ways around it, don't rely on it
working for anything important.

Play with this:

<script type="text/javascript">

function fixSelections(rGroup)
{
var i = rGroup.length;
var j = i;
var oneChecked = false;

// Check that one has been selected
while (j-- && !oneChecked){
oneChecked = rGroup[j].checked;
}

// If one hasn't been selected, ask user to select one
if (!oneChecked) {
alert('Please check an option');
return;
}

// If one has been selected, disable the rest
while (i--){
rGroup[i].disabled = !rGroup[i].checked;
}
}

function enableRadios(rGroup)
{
var i = rGroup.length;
while (i--){
rGroup[i].disabled = false;
}
}

</script>

<form action=""><div>
<input type="radio" name="r1">button 1<br>
<input type="radio" name="r1">button 2<br>
<input type="radio" name="r1">button 3<br>
<input type="radio" name="r1">button 4<br>
<input type="button" value="Fix selection"
onclick="fixSelections(this.form.r1);"><br>
<input type="reset" onclick="enableRadios(this.form.r1);">
</div></form>

--
Rob
Group FAQ: <URL:http://www.jibbering.com/FAQ>
Apr 28 '06 #3

P: n/a
Hi Rob,
This is the solution for one set of radio buttons, still i'm in doubt
that it'll affect the page. Anyway could you have any idea if it is the
case of multiple dropdown lists, since in that case multiple names will
be there. Also i want this to be reflected in the html page.

Thanks,
Biswaranjan

Apr 28 '06 #4

P: n/a
biswaranjan.rath wrote on 28 apr 2006 in comp.lang.javascript:
This is the solution for one set of radio buttons, still i'm in doubt
that it'll affect the page. Anyway could you have any idea if it is the
case of multiple dropdown lists, since in that case multiple names will
be there. Also i want this to be reflected in the html page.


Please quote what you are replying to.

If you want to post a followup via groups.google.com, don't use the
"Reply" link at the bottom of the article. Click on "show options" at the
top of the article, then click on the "Reply" at the bottom of the article
headers. <http://www.safalra.com/special/googlegroupsreply/>

--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Apr 28 '06 #5

This discussion thread is closed

Replies have been disabled for this discussion.