0

Hi, I have have the following code on an aspx page. The code I am trying to create is to display whther a checkbox when it is is clicked on.

<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3/jquery.min.js"></script>

<script>
$(document).ready(function()
{
$("input[title$='HalfDay']").click(function()
{
if ([title$='HalfDay'].checked) {
alert("Checked");
}
else {
alert("Not Checked");
}
});
});
</script>

The line which I think is wrong is this line...

if ([title$='HalfDay'].checked) {

But I'm not sure what it should be?

Thanks for any help!

2
Contributors
3
Replies
4
Views
7 Years
Discussion Span
Last Post by dd501
0

I'm guessing the first part is basically the same problem
$("input[name='HalfDay']"
and the second part should probably be
if this

0

Thanks for your reply, if I change the top part from...

$("input[title$='HalfDay']").click(function()

...to anything different it doesnt recognise that I've clicked the check box, so I think this is correct (or works), I think its this line which is the problem...

if ([title$='HalfDay'].checked) {

It always goes into the else statement, and says that the box is unchecked.

Thanks for your help

Edited by dd501: n/a

0

I managed to get my code to work in a sharepoint aspx page with a check box field using...

<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3/jquery.min.js"></script>

<script>
$(document).ready(function()
{
$("input[title$='CheckBoxName']").click(function()
{
if($("input[title$='CheckBoxName']").is(':checked'))
{
 alert("Checked");
}
else
{
 alert("Not Checked");
}
});
});
</script>
This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.