function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Aurora Ganguly 10Aurora Ganguly 10 

script in vf page(salesforce)

Hi All, 
as you can see i used this code : '<input type="radio" name="type" value="exp"> <label>Bill to Room</label>'+
                                '<select>'+
                                '<option> --- </option>'+
                                '<option> Room 1 </option>'+
                                '<option> Room 2 </option>'+
                                '<option> Room 3 </option>'+
                                '<option> Room 4 </option>'+
                                '<option> Room 5 </option>'+
                                '<option> Room 6 </option>'+
                                
                                  '</select>'+
                                '<input type="radio" name="type" value="fresher"> PAY NOW'+
                                '<br/>'+
                                '<br/>'+
since i have two radio button , and fro this i used the script , this code: $(document).ready(function(){
                  
     $('select').hide();

     $('input').on('change', function(){
      $('select').show();
     })
});
but the thing is , i want when i will click on the first radio button it will populate the dropdown options and onclick of the second radio button it should hide, but its not happening, whenever i click on anyone of the radio button it is showing the dropdown menu , how to restrict that , can anyone share your views based on my coding parts
thanks
 
Best Answer chosen by Aurora Ganguly 10
Shruti SShruti S
It works well for me. Have a look - 

User-added image

Would you mind posting the entrire source code so that I can take a look?

All Answers

Shruti SShruti S
You have used the input tag selector and applied onchange to it. So it applies to both the input tags. Instead you can give ids to each input tags and select just one radio button and then apply onchange to it.

Try this and you should be golden - 
<apex:page>
    <input type="radio" id="radioBillToRoom" name="type" value="exp" /> <label for="radioBillToRoom">Bill to Room</label>
    <select id="slctRooms" style="display:none">
        <option> --- </option>
        <option> Room 1 </option>
        <option> Room 2 </option>
        <option> Room 3 </option>
        <option> Room 4 </option>
        <option> Room 5 </option>
        <option> Room 6 </option>
    </select>
    <input type="radio" id="radioPayNow" name="type" value="fresher" /> <label for="radioPayNow">PAY NOW</label>
    
    <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.1.0/jquery.min.js"></script>
    <script type="text/javascript">
    $( document ).ready(
        function() {
            $( "#slctRooms" ).hide();
        
            $( "#radioBillToRoom" ).on(
                "change", 
                function() {
                    $( "#slctRooms" ).show();
                }
            );
            
            $( "#radioPayNow" ).on(
                "change", 
                function() {
                    $( "#slctRooms" ).hide();
                }
            );
        }
    );
    </script>
</apex:page>
Aurora Ganguly 10Aurora Ganguly 10
Thanks Shruti, anyway its not working , dn know why , no such different effect after giving that code Thanks and regards, Aurora Ganguly Salesforce Developer [1483530955164_vs.png] e: aurora.ganguly@veneratesolutions.com m:8050319438/8697406601 BANGALORE LinkedIn : https://www.linkedin.com/in/aurora-ganguly-5326626a
Shruti SShruti S
It works well for me. Have a look - 

User-added image

Would you mind posting the entrire source code so that I can take a look?
This was selected as the best answer
Aurora Ganguly 10Aurora Ganguly 10
'
'+ '
'+ '

'+ '

'+ '
'+ 'Close Order    '+ 'Close Later    '+ 'CLOSE' + '
'+ '

'+ '


'+ ''+ '
'+ 'Bill to Room'+ ''+ ' --- '+ ' Room 1 '+ ' Room 2 '+ ' Room 3 '+ ' Room 4 '+ ' Room 5 '+ ' Room 6 '+ ''+ ' PAY NOW'+ '
'+ '
'+ '
'+ '
'+ '
'+ '
'+ '

CHECKOUT   CLOSE'+ ''+ '
'+ '
'+ ''+ '
'+ '
'+ '' + '' + '' ); $(document).ready(function(){ $('.filters-hide').hide(); $('.filters-btn').on('click', function(){ $('.filters-panel').toggle('show'); }); $('.filters-btn2').on('click', function(){ $('.filters-panel2').toggle('show'); }); }); $(document).ready(function(){ $('select').hide(); $('input').on('change', function(){ $('select').show(); }) }); Thanks and regards, Aurora Ganguly Salesforce Developer [1483530955164_vs.png] e: aurora.ganguly@veneratesolutions.com m:8050319438/8697406601 BANGALORE LinkedIn : https://www.linkedin.com/in/aurora-ganguly-5326626a
Shruti SShruti S
Thanks Aurora. I think you are replying via email instead of posting it directly on the thread back on the forum. Please try to reply directly on the forum instead of replies to mail.

Also, I still think that you are only revealing portions of some big code. I understand you probably will not be in a position to share the whole stuff but still remember it is quite difficult to troubleshoot by looking at only a piece of the code. We need to look into the entire code in order to understand the problem.

Please do post the entire stuff and I am pretty sure I can help you fix it.
Aurora Ganguly 10Aurora Ganguly 10
Thnks Shruti , 
can we setup a call so that i can take you through the entire code since you need to look into the entire code inorder to understand the problem .
just let me know when is the good time to have a call with you .
 
Aurora Ganguly 10Aurora Ganguly 10
and one more thing am not using this inside directly apex page , am doing this inside script tag,
 
Aurora Ganguly 10Aurora Ganguly 10
hi shruti , am unable to share the whole code in the forum, so thats why am sharing via note pad, and one more thing am using script , am not doing simply inside apex page as u did, so may be thats y am having problem . u just go through if possible and let me know . Thanks and regards, Aurora Ganguly Salesforce Developer [1483530955164_vs.png] e: aurora.ganguly@veneratesolutions.com m:8050319438/8697406601 BANGALORE LinkedIn : https://www.linkedin.com/in/aurora-ganguly-5326626a
Aurora Ganguly 10Aurora Ganguly 10
Hi Shruti , Thanks , I did it , it worked atlast , 
actualy i was placing the code in wrong place , and atlast it worked , thanks for ur help .
Aurora Ganguly 10Aurora Ganguly 10
sure, :)