Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Setting Checkbox clientside

Reply
Thread Tools

Setting Checkbox clientside

 
 
tshad
Guest
Posts: n/a
 
      12-02-2005
I am trying to set and clear my checkboxes using client-side validation.

I have some Javascript to set my checkboxes:

<script language=javascript>
function validate(){
Medical.checked = 1;
}
</script>

I get an error that says:

"Medical" is undefined

Here is my asp code:

<asp:CheckBox id="Medical" Text="Medical" Checked="false"
runat="server"/>

and when I look at my page from view source:

<input id="Medical" type="checkbox" name="Medical" /><label
for="Medical">Medical</label>

There is the name "Medical" - so why is Javascript saying it is undefined?

Thanks,

Tom


 
Reply With Quote
 
 
 
 
CK
Guest
Posts: n/a
 
      12-02-2005
function validate()
{
var Medical = document.getElementById('Medical');
//alert(Medical.checked);
Medical.checked = true; //I think it's something like this
}

Hope this helps.
CK

"tshad" <(E-Mail Removed)> wrote in message
news:%(E-Mail Removed)...
>I am trying to set and clear my checkboxes using client-side validation.
>
> I have some Javascript to set my checkboxes:
>
> <script language=javascript>
> function validate(){
> Medical.checked = 1;
> }
> </script>
>
> I get an error that says:
>
> "Medical" is undefined
>
> Here is my asp code:
>
> <asp:CheckBox id="Medical" Text="Medical" Checked="false"
> runat="server"/>
>
> and when I look at my page from view source:
>
> <input id="Medical" type="checkbox" name="Medical" /><label
> for="Medical">Medical</label>
>
> There is the name "Medical" - so why is Javascript saying it is undefined?
>
> Thanks,
>
> Tom
>



 
Reply With Quote
 
 
 
 
tshad
Guest
Posts: n/a
 
      12-02-2005
"CK" <(E-Mail Removed)> wrote in message
news:cy3kf.26631$q%(E-Mail Removed) om...
> function validate()
> {
> var Medical = document.getElementById('Medical');
> //alert(Medical.checked);
> Medical.checked = true; //I think it's something like this
> }


Works perfectly.

Would this be the same for all browsers?

I am mainly worried about IE, but there are others that may use other
browsers.

Thanks,

Tom
>
> Hope this helps.
> CK
>
> "tshad" <(E-Mail Removed)> wrote in message
> news:%(E-Mail Removed)...
>>I am trying to set and clear my checkboxes using client-side validation.
>>
>> I have some Javascript to set my checkboxes:
>>
>> <script language=javascript>
>> function validate(){
>> Medical.checked = 1;
>> }
>> </script>
>>
>> I get an error that says:
>>
>> "Medical" is undefined
>>
>> Here is my asp code:
>>
>> <asp:CheckBox id="Medical" Text="Medical" Checked="false"
>> runat="server"/>
>>
>> and when I look at my page from view source:
>>
>> <input id="Medical" type="checkbox" name="Medical" /><label
>> for="Medical">Medical</label>
>>
>> There is the name "Medical" - so why is Javascript saying it is
>> undefined?
>>
>> Thanks,
>>
>> Tom
>>

>
>



 
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
Clientside CheckBox validation oakura_ape ASP .Net 1 11-02-2006 09:05 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
Text on Checkbox below the checkbox tshad ASP .Net 0 04-14-2005 11:26 PM



Advertisments