Results 1 to 7 of 7
Like Tree1Likes
  • 1 Post By gokulakannan

Thread: How to get the Selected value of a radio button?

  1. #1
    gokulakannan is offline Sugar Community Member
    Join Date
    Dec 2011
    Location
    India
    Posts
    37

    Default How to get the Selected value of a radio button?

    Hai
    I am using SugarCE6.4.0RC2 and created a custom module. In that i have 5 radio buttons whose values are

    1)Perfect
    2)Good
    3)Poor

    I am going to create a logic hook 'before_save' event, in that, if more than 3 radio buttons have value "Perfect" then a custom text-field should be displayed as "Perfect" otherwise that filed should be "Good".

    How can i get the selected value of a radio button?

    can one any help me to do this

  2. #2
    ashokinsugar is offline Sugar Community Member
    Join Date
    Apr 2011
    Location
    INDIA
    Posts
    198

    Default Re: How to get the Selected value of a radio button?

    Hi gokulakannan,

    why are you using radio button, use check box instaed. And to get the selected value please see w3school tutorial it will help you sure.

    Regards,
    Ashok

  3. #3
    gokulakannan is offline Sugar Community Member
    Join Date
    Dec 2011
    Location
    India
    Posts
    37

    Default Re: How to get the Selected value of a radio button?

    Quote Originally Posted by ashokinsugar View Post
    Hi gokulakannan,

    why are you using radio button, use check box instaed. And to get the selected value please see w3school tutorial it will help you sure.

    Regards,
    Ashok
    Hai Ashok,
    First of all thanks for your reply. If we use check box then user can able to select more than one checkbox at a time. But i want the user to select only one option that why i preferred radio button.

  4. #4
    ldd-silver-ziegler is offline Sugar Community Member
    Join Date
    Aug 2011
    Location
    Voecklabruck/Austria
    Posts
    72

    Default Re: How to get the Selected value of a radio button?

    Quote Originally Posted by gokulakannan View Post
    Hai
    I am using SugarCE6.4.0RC2 and created a custom module. In that i have 5 radio buttons whose values are

    1)Perfect
    2)Good
    3)Poor

    I am going to create a logic hook 'before_save' event, in that, if more than 3 radio buttons have value "Perfect" then a custom text-field should be displayed as "Perfect" otherwise that filed should be "Good".

    How can i get the selected value of a radio button?

    can one any help me to do this
    Use the bean that is passed to the hook to access the value of the radiogroup.

    e.g.
    PHP Code:
    if($bean->radio_c=="Perfect"doStuff(); 
    replace "radio_c" with the name of the custom field (the name that is displayed in studio in the name column of the fields)

  5. #5
    rafael.q.g@hotmail.com's Avatar
    rafael.q.g@hotmail.com is offline Sugar Community Member
    Join Date
    Jun 2011
    Location
    Florianˇpolis - Brazil
    Posts
    795

    Default Re: How to get the Selected value of a radio button?

    With JavaScript radion button values could be got this way:
    var field=document.getElementById("radionfield");
    for(var i=0;i<field.length;i++){
    if(field[i].checked){
    field[i].value; // this is selected
    }
    }
    Rafael Queiroz Gonšalves, MSc.
    Advanced OMG UML Certified Professional
    Sun Certified Enterprise Architect for the Java Platform
    Sun Certified Programmer for the Java 2 Platform
    IBM Certified Advanced Application Developer - Lotus Notes and Domino
    IBM Certified Application Developer - IBM WebSphere Portlet Factory
    Master in Computer Science

  6. #6
    gokulakannan is offline Sugar Community Member
    Join Date
    Dec 2011
    Location
    India
    Posts
    37

    Thumbs up Re: How to get the Selected value of a radio button?

    Hai friends,
    Thank you for your reply and support. I completed the task in another way. Let you explain that,
    First i created a logic_hook for the event 'before_save'. In an array variable i stored the selected values of the radio button.

    After that using the "for" loop and "if" condition i checked whether the selected option is equal to the item name(which is stored in the database). If it is same then i increment a temp variable.

    Then if the value of the "temp" is greater than 3 then i assigned "Perfect" to a new custom text variable.

    I don't know whether the way i done was better one or not? but i achieved the task successfully.
    ashokinsugar likes this.

  7. #7
    ashokinsugar is offline Sugar Community Member
    Join Date
    Apr 2011
    Location
    INDIA
    Posts
    198

    Default Re: How to get the Selected value of a radio button?

    Hi gokulakannan,

    you did it well.

    I misunderstood your requirement....

    Regards,
    Ashok

Thread Information

Users Browsing this Thread

There are currently 3 users browsing this thread. (0 members and 3 guests)

Similar Threads

  1. customcode -> radio button
    By ckd1987 in forum Developer Help
    Replies: 3
    Last Post: 2012-08-23, 03:31 PM
  2. How to get the Selected value of a radio button?
    By gokulakannan in forum Developer Help
    Replies: 3
    Last Post: 2012-03-12, 02:04 PM
  3. populate drom down list on select of radio button
    By dsuvankar in forum Developer Help
    Replies: 3
    Last Post: 2011-04-21, 05:18 PM
  4. Dropdowns based on Radio Button???
    By m3suriya in forum Developer Help
    Replies: 1
    Last Post: 2010-06-30, 07:29 PM
  5. Cannot view custo radio button
    By bathi741 in forum Help
    Replies: 1
    Last Post: 2008-04-11, 09:36 AM

Bookmarks

Posting Permissions

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