Jump to content

Conditional Input / Cascading "text" boxes


Recommended Posts

I am not a programmer so I will need some help with what I am trying to achieve. Caspio currently does cacading relationships for listbox and dropdowns… But what I am interested in is:

Let’s say I have a parent field which is a drop-down menu style, I would like this to be connected to its child field (which will be a text box). So when the parent field is activated… the child text field becomes activated so text can be typed into it. If not then it stays grayed out or disabled.

Hypothetical example:

Parent (Dropdown): Do you have children? (Dropdown/Checkbox saying: Yes/No)

Child (Textbox): How many? (text box) – this should become activated only if the user selects Yes in the parent field.

Sample code I have written so far:

var Selection=document.getElementByld("InsertRecordSelection");

var Value=document.getElementByld("InsertRecordValue");

function fun_conditional()

if (Selection.checked){

Value.style.display='';

}

else

{

Value.style.display='none';

}

Selection.onclick=fun_conditional;

When I cut and paste the above code into the footer section of my datapage, it does not work. Any suggestions or ideas please help. Do I have to add any other code into this to make it work?

Thank you in advance for your help.

Regards.

Link to comment
Share on other sites

Hello,

You could write something like the following:

Setting up the child value with a div to hide by default

=============================================

Insert an HTML block right above the child field and insert the following

=============================================

Insert an HTML block right below the child field and insert the following

==============================================

JavaScript to Hide/Display child based on selection value - inserted in footer

============================================================

var selection=document.getElementById("InsertRecordSelection");

var value=document.getElementById("cb_child");

function show() {

if (selection.checked) {

if (selection.value == 1) {

value.style.display="block";

}

}

else {

value.style.display="none";

}

}

selection.onclick = show;

Hope this helps.

Best,

-SO

Link to comment
Share on other sites

  • 10 years later...

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.

Guest
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.

Loading...
×
×
  • Create New...