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!

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

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

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>
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.