Jump to content

Display Text Field ONLY When Checkbox is Checked


Recommended Posts

OBJECTIVE:

On DataPage 1 (embedded deploy), the user is presented with a check box (Question_1).

After clicking Sumbit on DataPage 1, user is directed to DataPage 2 (embedded deploy).

If the user checked the checkbox on DataPage 1, then DataPage 2 should display a hidden text field.

ISSUE:

I cannot get the text field to display on DataPage 2.

CASPIO DESIGN:

My table has a YES/NO field called "Question_1"

On DataPage 1 (update existing record, embedded deploy), Question_1 is included as a Checkbox form element and is set to pass the field value to the next page.

On DataPage 2, (update existing record, embedded deploy), Enable Advanced Options and Enable Parameters are both enabled. A Unique Field ID and Parameter Name are defined [@InsertRecordxxxx].An HTML block is defined in the header (I've also tried it in a body HTML block) that contains the following:

window.onload=function visibleInvisible()

function visibleInvisible()

{

if("[@Question_1]"="YES")

{

form.visibleTxtBox1.style.visibility="visible"

}

else

{

form.visibleTxtBox1.style.visibility="hidden"

}

}

Any help you could provide would be appreciated. Thanks.

Link to comment
Share on other sites

Hi,

I merely explained how to read a Caspio parameter within javascript.

There are several other issues with your script:

1) window.onload=function visibleInvisible()

My guess is that you are trying to call the visibleInvisible function when the form loads. In this case try:

window.onload = visibleInvisible;

2) always end a line with a ";"

3) form.visibleTxtBox1.style.visibility - that's not how you reference an object in Caspio. Try getElementByID or getElementsByName.

4) you are using nested forms:

Caspio forms are forms themselves and nested forms are not allowed in HTML.

You can find information about javascript syntax and semantics as well at http://www.w3schools.com and many other sites. In addition, using the firebug add-on on Firefox, will greatly help you in debugging your code.

sbelini.

Link to comment
Share on other sites

Again, thanks for the info and the help. My script still is not working. The current version is:

script type="text/javascript">

var q1;

q1 = "[@Question_1]";

window.onload = visibleInvisible(q1)

function visibleInvisible(q1){

if (q1 =="Y")

{document.getElementById("EditRecordQuestion_1_info").style.visibility="visible";}

else

{document.getElementById("EditRecordQuestion_1_info").style.visibility="hidden";}

}

Link to comment
Share on other sites

  • 2 weeks later...

I see some syntax errors on the code, for example "

I suggest you using Firefox browser where you can add on Firebug tool. Firebug enables you to see the errors in your page when the page runs and this way you can debug your code as it tells you which line is problematic.

Caspio also has Professional Services department for the custom development purposes. If you are interested to get a quote you can fill out the custom development form at http://www.caspio.com/services/custom-a ... opment.asp.

Another note, I recommend using a Caspio input field instead of putting using custom input field in your code as in .

Hope this helps.

Bahar M.

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.

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

×
×
  • Create New...