- Create Account

Checktree returned checked values

Forums > "Miscellaneous" Scripts > Checktree returned checked values
Author
Message

1) devxon Group: Members
Posts: 3 Joined: 1 Jan 2005 Location: Venezuela IP: 146.23.--.--
Hello everybody!
It was a long time since I wrote here. :)

Well,  I am concern about how to get the checked items from the CheckTree component. I am a noob javascript developer.

The way I am trying to get these checked is assigning an ID to every single checkbox and then loop through them. I don't know whether there is a better way to do it, sure there will be!

Hearing comments... Thanks in advance.
Fernando Peluffo

2) devxon Group: Members
Posts: 3 Joined: 1 Jan 2005 Location: Venezuela IP: 146.23.--.--
Ok guys.

I workaround my problem using this code:

function getValues(){
   var code
   var sCCNs = ""

   chkGroup  = document.forms[0].chkATs

   for (i=0;  i < chkGroup.length ; ++ i){
      if (chkGroup[i].checked){
code = chkGroup[i].id.split("-",3)
         sCCNs += code[1]  + ";"
         sCCNs += code[2] + "|"
}
   }

   sCCNs  = sCCNs.substr(0, sCCNs.length - 1)
   window.opener.document.getElementById('hidCCNs').value = sCCNs
self.close()
}

I  just needed one nested level that's why I used the ";" and the "|" symbols to later split the string returned using server side script.

If someone know how to do this using regular expression (if it's possible), let me know so I can learn more.

P.D: Angus, great job man! I am learning from your code eventhough it seems a bit abstract to me as javascript is not my strong skill. xD
Fernando Peluffo

3) Angus Turnbull Group: Moderators
Posts: 4042 Joined: 7 Dec 2003 Location: New Zealand IP: 222.154.--.--
Good to hear that you're having fun :).

Yes,  any standard JS form-processing code will do. Put an ID on all elements and you might find the document.getElementsByTagName('input') function handy to retrieve a list of all INPUT elements then check their TYPE.

Good luck - Angus.

Post a Reply:

You are not logged in, and will be posting anonymously as a guest. If you want to post using an account, please login at the top of this page.