This forum is closed to new posts and responses. Individual names altered for privacy purposes. The information contained in this website is provided for informational purposes only and should not be construed as a forum for customer support requests. Any customer support requests should be directed to the official HCL customer support channels below:

HCL Software Customer Support Portal for U.S. Federal Government clients
HCL Software Customer Support Portal



Mar 21, 2012, 1:11 PM
13 Posts

Capturing results of radio buttons

  • Category: Dojo and Client Side JavaScript
  • Platform: All
  • Release: 8.5.2
  • Role: Developer
  • Tags: radio button,radio button grooup
  • Replies: 1
I need to access the results of a radio button group in client side javascript.  The two button choices are "full text search" and "field search". When I do a partial refresh as a result of the selection (onclick event or onchange event)  (which is needed to hide one panel or another, depending on which is clicked) it reset the buttons to their initial values.
 
I've tried:
 
- explicitly building 2 radio buttons (no group).
 
Eclipse sets up a dummy group, ("radiogroup1") but radiogroup1 can't be found by the client side script. 
 
I then tried explicitly naming the group in each of the radio buttons, but that didn't do any good. 
 
In addition it appears the 2 buttons get reset when the partial refresh occurs, since their values, no matter which one gets clicked, show up on the client side as the initial values.
 
- building a group
 
I built a radio button group that had the two entries in it. 
 
Does anyone know how to get the value of the clicked selection in the radio button group?  It seems like this should be a simple var srchType = window.document.getElementById("#{id:radiogroup1}"); but apparently not.  Any suggestions?
Mar 21, 2012, 2:53 PM
56 Posts
Re: Capturing results of radio buttons
Hello Robert,
 
this is not that easy, but I build something a while ago for a combobox.
 
I think your problem is, that you want to acces radioGroup1 directly. Well, this element doesn't exist in the output html. You have to use "#{id:radioGroup1}" as the id, because XPages renders the ids anew when the XPage is rendered.
 
I built something similar a while ago. The bold text described how I accessed the data of the comboBox. Maybe this helps you, if you have further questions, please ask.
 
var urlString = "#{javascript:facesContext.getExternalContext().getRequestContextPath()}" + "/createSomething";
                           
var values = new Array();
values['fd_LastName']     = document.getElementById("#{id:lastName}").value;
values['fd_FirstName']     = document.getElementById("#{id:firstName}").value;
values['fd_Title']         = document.getElementById("#{id:Title}").value;

var xhrArgs = {
    url  : urlString,
    handleAs: "json",
    content: values,
    sync: "true",
    load: function(response,ioArgs) {
    
        XSP.partialRefreshGet("#{id:box}", {
            params: {'valmode': 0},
            onComplete: function(){
                var cbx = document.getElementById("#{id:comboBox}");
                var cbxname = cbx.name;
                var count = document.forms[0].elements[cbxname].length;                                  
               
                for (var i = 0; i < count; ++i) {
                    if (document.forms[0].elements[cbxname].options[i].value == response['item']) {
                        document.forms[0].elements[cbxname].options[i].selected = true;
                    }
                }
                var dialogId = '#{id:dialog}';
                dialogId = dialogId.replace(":callbackDialogContainer", "");
                dijit.byId(dialogId).hide();
                refreshId();
            }
        });                                              
    },
    error: function(error) {
        alert("An error has occured: " + error)
    }
}

var deferred = dojo.xhrPost(xhrArgs);

This forum is closed to new posts and responses. Individual names altered for privacy purposes. The information contained in this website is provided for informational purposes only and should not be construed as a forum for customer support requests. Any customer support requests should be directed to the official HCL customer support channels below:

HCL Software Customer Support Portal for U.S. Federal Government clients
HCL Software Customer Support Portal