Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 1 of 1
  1. #1
    New to the CF scene
    Join Date
    May 2012
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    radio button prompt using js

    I am ignorant in java scripting. I want to use the following java script to create the radiobutton in obiee reporting. This java script will change the regular prompt to radio button,however I do not know how to debug if it is working.

    Waiting for kind reply.

    Anil
    PHP Code:
    <script type="text/javascript">

    function 
    getElementsByClass(searchClass,node,tag) {
        
        var 
    classElements = new Array();
        if ( 
    node == null )
            
    node document;
        if ( 
    tag == null )
            
    tag '*';
        var 
    els node.getElementsByTagName(tag);
        var 
    elsLen els.length;
        var 
    pattern = new RegExp("(^|\\s)"+searchClass+"(\\s|$)");
        
        for (
    00elsLeni++) {
            if ( 
    pattern.test(els[i].className) ) {
                
    classElements[j] = els[i];
                
    j++;
            }
        }
        return 
    classElements;
    }

    var 
    tables getElementsByClass('DashboardPromptViewTable',null'table');

    for (var 
    table 0table tables.lengthtable++){

        var 
    stringFunc '';
        var 
    selects tables[table].getElementsByTagName('select');
        
        if ( 
    selects.length == undefined || selects.length == || selects[0].name === 'Match'){
            if (
    debug === 1) { document.write("No selects found.  Continue to next record."+"<BR>");}
            continue;  
    // This DB Prompt doesn't have any select statements
        
    }
        
        var 
    spans getElementsByClass('minibuttonOn',tables[table],'span');
        
        
    spans[0].style.display="none";
        
    stringFunc String(spans[0].getElementsByTagName('a')[0].onclick);
        
    stringFunc stringFunc.substr(stringFunc.indexOf('{')+1stringFunc.length stringFunc.indexOf('{'));
        
        for (var 
    =0selects.lengths++){
            var 
    new_form document.createElement('form');
            var 
    options  selects[s].getElementsByTagName('option');
            
    new_form.name selects[s].name+"_radio"
            
    new_form.id   selects[s].id+"_radio";
            for (var 
    o=0o<options.lengtho++) {
                var 
    new_input       document.createElement('input');
                
    new_input.type      'radio';
                
    new_input.value     options[o].value;
                
    new_input.name      selects[s].name+"_radio";
                if(
    selects[s].selectedIndex == o){
                    
    new_input.checked true;
                }
                var 
    onClickStringFunc "var sel = document.getElementById(this.name.substr(0,this.name.length-6));" +
                                        
    "if ( sel == null){"+
                                            
    "return;"+
                                        
    "}"+
                                        
    "var opts = sel.getElementsByTagName('option');"+
                                        
    "for( var opt = 0; opt < opts.length; opt++){"+
                                            
    "if( opts[opt].value == this.value){"+
                                                
    "sel.selectedIndex = opt;"+
                                            
    "}"+
                                        
    "}";                                
                
    new_input.onclick = new Function(onClickStringFunc stringFunc);
                var 
    new_text        document.createTextNode(options[o].innerHTML);
                
    new_form.appendChild(new_input);        
                
    new_form.appendChild(new_text);
            } 
    // end options for loop
            
    selects[s].parentNode.insertBefore(new_form,selects[s]);
            
    selects[s].style.display="none";
        } 
    // end selects for loop
    // end table foor loop
    </script> 
    Last edited by VIPStephan; 05-15-2012 at 08:35 PM. Reason: added code BB tags


 

Posting Permissions

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