Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New Coder
    Join Date
    Jun 2007
    Posts
    25
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Making Checkbox selected after returning java script.

    Hi,

    I'm having the following javascript code,after all the checkboxes are unslected,i'll display the alert to user saying that "Atleast one must be selected",but the checkbox is becoimng unselected,how to make check box selected after throwing this alert.

    var checkSelected = false;
    for (i = 0; i < planForm.locationOptions.length; i++) {
    if (planForm.locationOptions[i].checked) {
    checkSelected = true
    document.planForm.action='refreshPlanView.do';document.planForm.submit();
    document.getElementById("refreshing").style.display="block";
    }
    }
    if (!checkSelected) {
    alert("At least ONE Location must be selected!");
    return false;
    }
    return true;
    }

    Thanks,
    Anil

  • #2
    Senior Coder shyam's Avatar
    Join Date
    Jul 2005
    Posts
    1,563
    Thanks
    2
    Thanked 163 Times in 160 Posts
    Code:
    if (!checkSelected) {
    alert("At least ONE Location must be selected!");
    setSelected(urCheckbox);
    return false;
    }
    You never have to change anything you got up in the middle of the night to write. -- Saul Bellow

  • #3
    New Coder
    Join Date
    Jun 2007
    Posts
    25
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Hi,

    Thanks for ur reply.

    I've used setSelected(locationOptions[i]);

    but it is not setting the checkbox as selected after throwing the alert,it is unchecking the checkbox.

    please advise.

    Thanks,
    Anil


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •