Tuesday, July 14, 2015

Show/Hide Input Text Box based on Dropdown Selection using Jquery

Using Jquery we can show/hide the input box based on the Spotfire Drop Down selection.

Lets assume we have created a Drop-Down Property control with Fixed Values
as Enable and Disable as below



  
Also, create a Input property control.






Drop -Down Property Control ID: 163473c4bab648778b3e64c40463e3f  
Input Text Box Control ID:  c8b6b12144864ec5889005c6260a4b08

Now our aim is to show/hide the Input Text box based on the Drop down selection.


The default HTML would look like below:-
 

Click on JSscript Button and create below script as below:-
 

  
JScript will triggered whenever the Drop Down selection is changed.

Below is the Script.

//Triggering the script if Drop Down selection is varied
$("#163473c4bab648778b3e64c40463e3fc").change(function()

{
    var value = $("#163473c4bab648778b3e64c40463e3fc").val();  //To capture the index
    var vt = $("#163473c4bab648778b3e64c40463e3fc option:selected").text(); //To Capture the  selected text
    if(vt== "Enable")   //If the Drop Down selected value is Enable
    {
        $("#c8b6b12144864ec5889005c6260a4b08").show(); //Making the Input Box visible
    }
    else
    {
        $("#c8b6b12144864ec5889005c6260a4b08").hide(); //Making the Input box element hidden
    }
}
);




6 comments:

  1. Hey for me its not working properly.... its hiding again its showing the text box....

    ReplyDelete
  2. which version of Spotfire you are using?

    ReplyDelete
  3. it's working...superb example for me...

    ReplyDelete
  4. This solution is not working with Spotfire 7.5 and higher. Can anyone help on this?

    ReplyDelete
    Replies
    1. Spotfire is not recognising the change event :(

      Delete
  5. I really enjoyed while reading your article, the information you have mentioned in this post is really good. I am waiting for your upcoming post.

    Best Career in SAS Training Course with Highly package
    Want to Learn Python Programming Training with Placement Support

    ReplyDelete