Submit checkbox parameters to .asp page

I have 5 checkboxes inside a movieclip, each representing a sub section of an e-learning module. The user cherrypicks the sections they want to view and submits the info to a server. I found some code that enabled me to pass the label name of each selected box in the form of an array to the .asp page. (Current code included)

My developer however has asked me to pass checkbox ID's to the .asp page instead of the checkbox label name, eg,  
moduleID=1 subsection=1, moduleID=1 subsection=2,  etc. (<----probably bad syntax). I know how to pass name value pairs to an .asp page, I now need to pass multiple pairs via checkboxes, into an array and submit this to an asp page.




/

current code
 
///code on movieclip///
   onClipEvent(load)
   {
      _global.checkboxArray = new Array();
   
      _global.testIfSelected = function (t) 
      {
         for(i=0;i<checkboxArray.length;i++)
         {
            if(checkboxArray[i]==t)
            {
               return i;
            }
         }
         return -1;
      }
   }
 
///code on every checkbox///
on (click) {
      var pos=testIfSelected(this.label);
   
      if(this.selected == true)
      {      
         if(pos == -1) checkboxArray.push(this.label);
      } 
      else 
      {
         if(pos >=0) checkboxArray.splice(pos,1);
      }
   }
 
/
 
///code on submit button///
 
on (release)
   {      
      var selectedCheckboxes=checkboxArray.join(",");
         
      sendData = new LoadVars();
   
      sendData.checkboxes= selectedCheckboxes;
   
      sendData.send("http://localhost/filename.asp","_blank","GET");
   }

Open in new window

BrianJC67Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

BrianJC67Author Commented:
Thanks in advance btw !
0
b0lsc0ttIT ManagerCommented:
BrianJC67,

I am not a Flash expert (I know the ASP part) but what about just using the Query string.  For example your url would be ...

http://localhost/filename.asp?check1=value1&check2=value2 ...

That is a common way to do what you want.  If Flash can make cookies then it may also be an option.  If Flash can create the Post part of the header (i.e. manufacturer the form post) then that could also work.  I can't help with those details though.

Let me know if you have any questions or need more information.

b0lsc0tt
0
Aneesh ChopraCommented:
Hi BrainJC67,

we can't send arrays, objects as querystring whether use GET or POST.
data can be send only as string variables,

but you can send multiple varaibles using same code, below is the example to expand your code more more variables:

//////////
on (release)
   {      
      var selectedCheckboxes=checkboxArray.join(",");
         
      sendData = new LoadVars();
   
      sendData.checkboxes= selectedCheckboxes;
      sendData.anotherVariable= "somevlaue";
      sendData.var3= "var3value";
      sendData.fourthVar= "varvalue";
      //similarly you can add more variables to send back to ASP

      sendData.send("http://localhost/filename.asp","_blank","GET");
   }


///////////
0
The Ultimate Tool Kit for Technolgy Solution Provi

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy for valuable how-to assets including sample agreements, checklists, flowcharts, and more!

BrianJC67Author Commented:
If I understand right, these are just new variables to send to the asp page right?

 What I really need is some sort of listener which tells the .asp page which checkboxes were clicked, in the form of a string of ID's for each clicked checkbox. eg if I check boxes 2 and 4 I want to send this info to the asp page: checkbox= M1S2, M1S4 etc

Hope I'm making sense
0
b0lsc0ttIT ManagerCommented:
Are you looking for script for the ASP page or the Flash movie or both?  Mentioning a listener has confused this for me.  When is the ASP page called?

If the code you have is passing the label and you need the id then how about ...

///code on every checkbox///
on (click) {
      var pos=testIfSelected(this.label);
   
      if(this.selected == true)
      {      
         if(pos == -1) checkboxArray.push(this.id);
      }
      else
      {
         if(pos >=0) checkboxArray.splice(pos,1);
      }
   }
 
/

With the on release code suggested above this should pass the field's id (if I am reading the script, etc right).

bol
0
BrianJC67Author Commented:
Thanks for that bol, I should have been more specific. My Developer is taking care of the asp end, I was just worrried about passing the right kind of parameter to his script. This is a great soloution & very simple, thanks. To answer your question the asp is called on a button release (see below).


I have one more problem though. When the parameters are passed via a url, they are all in this format:
http://localhost/filename.asp?checkboxes=1%2C2%2C3   whereas I really need the parameters to be checkboxes=1,2,3. Do you know of any way to encode this in actionscript so that a clean string is sent to the asp?

Many thanks again

on (release)
   {      
      var selectedCheckboxes=checkboxArray.join(",");
         
      sendData = new LoadVars();
   
      sendData.checkboxes= selectedCheckboxes;
	
   
      sendData.send("http://localhost/filename.asp","_blank","POST");
   }

Open in new window

0
b0lsc0ttIT ManagerCommented:
You don't want to "fix" that.  The comma character is reserved in the URL so you can't use it as a literal character in the URL.  Instead it needs to encoded.  In the case of a comma that is %2C.

This should not be an issue though.  The ASP script can unencode it.  I have seen cases where a specific character can be hard to unencode but then you just use a different character.  Check with the developer and he may choose to have you use something instead of the comma which will not be URL unsafe or reserved.

Let me know if you have a question about this.

bol
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
BrianJC67Author Commented:
Thanks again,

on the character subject, would you know where this is defined by looking at my code??
I guess this is a worry for another day however.

Cheers
0
b0lsc0ttIT ManagerCommented:
Your welcome!  I'm glad I could help.

>> would you know where this is defined by looking at my code?? <<

If you are asking about where the comma is defined then that is in the line with the join I believe.  You could just replace the comma in that line with some URL safe character.  If you do have more questions about that and post a new question for it then feel free to post that question's URL here to get out attention.

Thanks for the grade, the points and the fun question.

bol

p.s.  It seems to me the other expert helped too.  If that is the case then a split would've been appropriate.  Let us know about this.  If you meant to do that then let me know and I can reopen this.  I might be wrong about what did answer this but wanted to point this out in case you meant to or should've split.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Adobe Flash

From novice to tech pro — start learning today.