ASP Checkbox and on click

Discussion in 'Software' started by alag20, Oct 26, 2006.

  1. alag20

    alag20 Private E-2

    Hi,
    I am a newbie developing a form which has a number of checkbox and have 3 main category,
    Approve all, Reject all, Query.

    My main problem is that once I click any of these 3 then the other two should be unchecked and all elements under there should be checked. If you remove a check for any bottom element then the All element is removed.

    I have attached a simple pic of the form. I would be grateful if someone could tell me the code in asp for the above form sample along with any javascript!

    Many thanks in advance!
    :confused:
     

    Attached Files:

  2. Mada_Milty

    Mada_Milty MajorGeek

    I believe you will have to set the 'value' property of each checkbox to false.

    Ex.

    Code:
    private sub [COLOR="Red"]TEXT1_APPROVE[/COLOR]_OnClick ()
         [COLOR="Red"]TEXT1_REJECT[/COLOR].Value = false
         [COLOR="Red"]TEXT1_QUERY[/COLOR].Value = false
    end sub
    
    Where everything highlighted in red is the actual name of your checkboxes.

    edit: Just read Kodo's response in your other thread...am I leading you down the wrong path here?
     
  3. alag20

    alag20 Private E-2

    Well most browsers dont support vbscript specially thoese commands for onclick. So I would be more inclined to a javascript solution. I tried to create a similar javascript but then when the button is clicked i start getting errors on page!

    Any help please?
     
  4. goldfish

    goldfish Lt. Sushi.DC

    I don't have much time so it'll be breif.

    To check the status of a checkbox, you must use the DOM.
    Code:
    document.getElementById("approved1").value
    
    Will return the state of the checkbox with the ID approved1, as such...
    Code:
    <input type="checkbox" id="approved1" />
    
    A more complete example.

    Code:
    <script>
    
    function checkInput() {
    if (document.getElementById("approved1").value) {
        alert('The item is checked')
    } else {
         alert('The item is NOT checked');
    }
    }
    </script>
     
    ....
    
    <input type="checkbox" id="approved1" />
    <input type="button" value="Submit" onclick="checkInput()" />
    
    
     
  5. Kodo

    Kodo SNATCHSQUATCH

    additionally , Approve all, Reject all, and Query all should be radio buttons with the same name and id

    <input type="radio" name="radMainOptions" id="radMainOptions" value="Approve All" />
    ...
    ...

    That will place the radio buttons in the same logical group so when you can only have one selected at any given time.
     
  6. alag20

    alag20 Private E-2

    Thanks for the above. However, I was wondering if there was any dynamic way of doing the same> Eg as soon as i click on approveall the rario / checkbox below gets highlighted, without clicking the submit!
     
  7. alag20

    alag20 Private E-2

    Done Thanks for all your help!
     

MajorGeeks.Com Menu

Downloads All In One Tweaks \ Android \ Anti-Malware \ Anti-Virus \ Appearance \ Backup \ Browsers \ CD\DVD\Blu-Ray \ Covert Ops \ Drive Utilities \ Drivers \ Graphics \ Internet Tools \ Multimedia \ Networking \ Office Tools \ PC Games \ System Tools \ Mac/Apple/Ipad Downloads

Other News: Top Downloads \ News (Tech) \ Off Base (Other Websites News) \ Way Off Base (Offbeat Stories and Pics)

Social: Facebook \ YouTube \ Twitter \ Tumblr \ Pintrest \ RSS Feeds