Go4Expert (http://www.go4expert.com/)
-   Web Design, HTML And CSS Forums (http://www.go4expert.com/forums/web-design-forum/)
-   -   how to do this (http://www.go4expert.com/forums/how-to-do-this-t509/)

prashantSum 16Nov2005 16:29

how to do this
I am using a popup window
in this I may be having n number of input checkboxes(here I have taken 4)
like this <input type='checkbox' name='comments1' value='0' />
so I will be naming it comments1, comments2, and so on.....

and now to return it's values to parent window I am using this function

function Done() {

if (comments1.checked)
MyArgs[1][0] = 1;
MyArgs[1][0] = 0;

if (comments2.checked)
MyArgs[1][1] = 1;
MyArgs[1][1] = 0;

if (comments3.checked)
MyArgs[1][2] = 1;
MyArgs[1][2] = 0;

if (comments4.checked)
MyArgs[1][3] = 1;
MyArgs[1][3] = 0;

window.returnValue = MyArgs;

now can do something like
if ( comments + i . checked) (not exactly like this )
I want to put it in a loop until the length of comments ( that is may be 1 .. 10, length I can determine) .

pradeep 18Nov2005 12:41

Re: how to do this
You can loop through the form elements and use a bit of regular expression to get as many checkbox values you want.


var myArgs[1] = {};
 fucntion Collect(oForm)
  var e=oForm.elements;
  for(var i=0;i<e.length;i++)
        if(e[i].type="checkbox" && e[i].name.match(/^comments([\d]+)$/))
                myArgs[1][RegExp.$1] = 1;
                myArgs[1][RegExp.$1] = 0;
 //calling the function

Hope this is useful.


prashantSum 18Nov2005 17:15

Re: how to do this
thx for reply pradeep,

actually I have completed that task by some other way,

but what you have given is intresting I would like to work on it later...and ask any doubts

one immediate for me when I am looking at script is ( as not aware of RE in java script)
' RegExp.$1' do I need to place it as it is or is there any to I need to replace there..

All times are GMT +5.5. The time now is 02:20.