making checkbox non-editable

B

biswaranjan.rath

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
 
B

biswaranjan.rath

Also I can get the IDs of the checkboxes in java script function.

Biswaranjan
 
R

RobG

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.disabled = !rGroup.checked;
}
}

function enableRadios(rGroup)
{
var i = rGroup.length;
while (i--){
rGroup.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>
 
B

biswaranjan.rath

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
 
E

Evertjan.

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/>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,432
Messages
2,571,680
Members
48,796
Latest member
Greg L.

Latest Threads

Top