A Flash Developer Resource Site

Results 1 to 2 of 2

Thread: How to store values activated by buttons

  1. #1
    Member
    Join Date
    Sep 2000
    Posts
    85

    How to store values activated by buttons

    Hi,

    I have several buttons. When clicked, the buttons will have some values attached to them. When unclicked, they will reset to empty.

    This is so that when I hit a "Submit" button, the values in the earlier button will be populated at the end of the below statement:

    abc.asp?subcd=

    the values have to be separated by commas.
    (this statement will be passed on to an asp file that will read the values)

    eg.
    abc.asp?subcd=john,nancy,sean,leon

    do I need to use arrays?
    I am not familiar with arrays, please help.

    Would appreciate very much for any help rendered.
    Thanks in advance.

    Lawrence

  2. #2
    Senior Member
    Join Date
    Apr 2005
    Location
    FL, USA
    Posts
    442
    I assume you mean a checkbox not a button. If you're using the chekbox component then you check its value like this...
    Code:
    if(checkBox.selected) trace("selected");
    where "checkBox" is the instance name. Since you'll probably have several checkboxes, though, you might want to use a loop instead of lots of ifs. Maybe something like....
    Code:
    queryString = "";
    numberCheckBoxes = 4;//checkBoxes named checkBox1, checkBox2, etc.
    submitButton.onRelease = function() {
    for(n=1; n<numberCheckBoxes; n++) {
    if(eval("checkBox"+n).selected) {
    if(queryString == "") queryString += eval("checkBox"+n).label;
    else queryString += ","+eval("checkBox"+n).label;
    }
    }
    getURL("abc.asp?subcd="+queryString , "");
    }

Posting Permissions

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




Click Here to Expand Forum to Full Width

HTML5 Development Center