A Flash Developer Resource Site

Results 1 to 8 of 8

Thread: Need radio button value passed to SharedOjbet

  1. #1
    Junior Member
    Join Date
    Apr 2002
    Location
    Chicago
    Posts
    13

    Need radio button value passed to SharedOjbet

    I am under a tight deadline. Friday Aug.22!!! I am trying to store the value of a radio button (in a group for yes/no) when a 'Next" button is pressed. I have a nextBtn.addEventListener(...) to contain a function which holds code to store the value of each radio button on the page into its own SharedObject. As such:
    _so.data.DrugName1 = DrugName1.selected;

    I do not know the AS3.0 code to get the value of the selected radio button in a grouping and then to use that value and store it into the SharedObject _so.data I have been banging my head for days. I fear I keep trying to use AS2 code for an AS3 project. AAAAAhhhhhhhh!

    Can someone please help me determine the value or data of a radio button or radio button group. Is it "selected" or "selectedData" or "getValue()" or "value" or "data" or what ?????? I don't know where else to turn.

    alexdove at comcast.net
    Please email direct if you can help. I'll be sure to re-post a solution once I get it.

    Thank you in advance.
    Alex Dove
    Alex Dove
    A Web Development Company
    www.pivotalsolution.com
    alex.dove@pivotalsolution.com

  2. #2
    Senior Member cancerinform's Avatar
    Join Date
    Mar 2002
    Location
    press the picture...
    Posts
    13,449
    I don't know any details, but this is the AS for holding the label, when a radiobutton is clicked:

    nextBtn.label="yes";
    nextBtn.addEventListener (Event.CHANGE, changeHandler);
    function changeHandler (event:Event):void
    {
    trace (event.currentTarget.label);
    }
    - The right of the People to create Flash movies shall not be infringed. -

  3. #3
    Junior Member
    Join Date
    Apr 2002
    Location
    Chicago
    Posts
    13
    Ok, possibly a useful item if there is a way to force the value of the SharedObject the label value if the label value can be set to the same reserved word for a radio button being selected. And that is one of my problems is that I cant determine how to grab the value of a selected radio button. Hmmmm. Ahhhhhhhhh.

    Thanks
    Alex
    Alex Dove
    A Web Development Company
    www.pivotalsolution.com
    alex.dove@pivotalsolution.com

  4. #4
    Senior Member cancerinform's Avatar
    Join Date
    Mar 2002
    Location
    press the picture...
    Posts
    13,449
    Here is an example for two radiobuttons:

    r1.label="yes";
    r1.value="y";
    r2.label="no";
    r2.value="n";
    r1.addEventListener(MouseEvent.CLICK, cHandler);
    r2.addEventListener(MouseEvent.CLICK, cHandler);
    function cHandler(event:MouseEvent):void
    {
    trace(event.currentTarget.value);
    _so.data.DrugName1 = event.currentTarget.value;
    }
    - The right of the People to create Flash movies shall not be infringed. -

  5. #5
    Junior Member
    Join Date
    Apr 2002
    Location
    Chicago
    Posts
    13
    Ok, super. So are you saying that the "value" of the button takes a name:value pair of value = "yes" or value = "no"? And that would be instead of the value being, say, "selected", "checked", or a "1" or "0"?

    So if a radio button is pressed then its value equal "y", otherwise it is a "n", correct? And this is a constant name:value association in AS3?

    Thanks
    Alex
    Alex Dove
    A Web Development Company
    www.pivotalsolution.com
    alex.dove@pivotalsolution.com

  6. #6
    Senior Member cancerinform's Avatar
    Join Date
    Mar 2002
    Location
    press the picture...
    Posts
    13,449
    You are in charge and need to set what you want as a value. I am just showing an example.
    - The right of the People to create Flash movies shall not be infringed. -

  7. #7
    Junior Member
    Join Date
    Apr 2002
    Location
    Chicago
    Posts
    13
    I was able to fix the problem with your help cancerinform. Thank you. Here is the modification of the code you suggested and how I was able to implement it.

    Step 1: When the page loads is runs this code to check for the existance of values either populating the YES or NO radio buttons and IF NO then it forces the hidden default radio button in the group to be selected.

    if(_so.data.HumiraY_Row1 == "y"){HumiraY_Row1.selected = true;}else if(_so.data.HumiraN_Row1 == "n"){HumiraN_Row1.selected = true;}else{HumiraNS_Row1.selected = true;}



    Step 2: Add individual radiobutton listeners and target the value coming in to save as a SharedObject and then forcing the OPPOSITE radio button in the group to be NULL

    HumiraY_Row1.addEventListener(MouseEvent.CLICK, myHumiraY_Row1);

    function myHumiraY_Row1(event:MouseEvent):void
    {
    _so.data.HumiraY_Row1 = event.currentTarget.value;
    _so.data.HumiraN_Row1 = null;
    }

    HumiraN_Row1.addEventListener(MouseEvent.CLICK, myHumiraN_Row1);

    function myHumiraN_Row1(event:MouseEvent):void
    {
    _so.data.HumiraN_Row1 = event.currentTarget.value;
    _so.data.HumiraY_Row1 = null;
    }
    Alex Dove
    A Web Development Company
    www.pivotalsolution.com
    alex.dove@pivotalsolution.com

  8. #8
    Junior Member
    Join Date
    Apr 2002
    Location
    Chicago
    Posts
    13
    Thank you Thank you Thank you
    Alex Dove
    A Web Development Company
    www.pivotalsolution.com
    alex.dove@pivotalsolution.com

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