Jump to content

Hide Custom Dropdown If Only 1 Value Is Present

Recommended Posts

I have a popup that is used to select values from multiple fields, and then passes that info to a web form. In example, I have two address fields in my table and need them to be in one dropdown. To do this, I had to create my own custom dropdown that takes in both Address 1 and Address 2 fields. Same with Names and Phone Numbers. However, not all accounts have two of each. Sometimes its just one person on the account, with one phone number, and one address. 

Is it possible to Hide these custom dropdowns if there is only one selectable value present? In other words... if the dropdown only contains one value I want it to hide. 

Does anyone know if this is possible with JavaScript? Not having any real fields from the table makes it impossible to hide any of these with the Rules page. Regardless of that, I wouldn't be able to hide if the HTML Dropdown only contained one value. 

If anyone could help me out, I'd appreciate it!


Link to comment
Share on other sites

Here is the JS for the query string value using the HTML blocks. 

function myFunction(x) {

// Getting the value of the first drop-down
var e = document.getElementById(x);
var strUser = e.options[e.selectedIndex].value;

// Getting the value of the second drop-down
var f = document.getElementById('2'+x);
var endUser = f.options[f.selectedIndex].value;

// Getting the value of the third drop-down
var g = document.getElementById('3'+x);
var midUser = g.options[g.selectedIndex].value;

// Getting the value of the third dropdown
var h = document.getElementById('4'+x);
var bUser = h.options[h.selectedIndex].value;

//Getting the value of the fifth dropdown
var j = document.getElementById('5'+x);
var fUser = j.options[j.selectedIndex].value;

window.location.replace("https://xxxxxx.caspio.com/dp/e75050009fd4376eab4b41009535?val=" + strUser + "&val2="+endUser + "&val3="+midUser + "&val4="+bUser + "&val5="+fUser);

And, here is what the custom dropdowns look like. 

<select id='3[@field:CG_Client_ID]'>
  <option value="[@field:Home_Phone]">[@field:Home_Phone]</option>
  <option value="[@field:Primary_Cell_Phone]">[@field:Primary_Cell_Phone]</option>
  <option value="[@field:Additional_Cell_Phone]">[@field:Additional_Cell_Phone]</option>

The fact that the ID is different and changing I think will make this difficult.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...