Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Javascript > making checkbox non-editable

Reply
Thread Tools

making checkbox non-editable

 
 
biswaranjan.rath
Guest
Posts: n/a
 
      04-28-2006
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

 
Reply With Quote
 
 
 
 
biswaranjan.rath
Guest
Posts: n/a
 
      04-28-2006
Also I can get the IDs of the checkboxes in java script function.

Biswaranjan

 
Reply With Quote
 
 
 
 
RobG
Guest
Posts: n/a
 
      04-28-2006
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>
 
Reply With Quote
 
biswaranjan.rath
Guest
Posts: n/a
 
      04-28-2006
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

 
Reply With Quote
 
Evertjan.
Guest
Posts: n/a
 
      04-28-2006
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)
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
ASPNET CheckBox and a CheckBox in a TemplateField Jason Huang ASP .Net 0 06-29-2007 12:35 AM
DataGrid and embeded Checkbox..How to find if checkbox clicked =?Utf-8?B?RG90TmV0RGV2?= ASP .Net 1 10-06-2006 04:11 PM
disable checkbox list checkbox Vikram ASP .Net 1 01-25-2006 02:59 PM
Howto bind CheckBox to the datagrid/ Then update the database field when the checkbox is clicked. Joey Pang ASP .Net Datagrid Control 4 06-13-2005 02:29 AM
Text on Checkbox below the checkbox tshad ASP .Net 0 04-14-2005 11:26 PM



Advertisments