Jump to content
  • 0

checkbox IF argument


richarde
 Share

Question

Hi,

Upon submit of a WebForm datapage, I want to generate new text for a record depending on whether or not a checkbox on the Webform is checked.

Something like this, I think:

function intersection()

{

if(document.forms[0].CrossStreet.checked){

document.forms[0].InsertRecordaddress.value==\"help\";

} else {

document.forms[0].InsertRecordaddress.value==\"me\";

}

}

document.forms[0].onsubmit=intersection;

My checkbox is called CrossStreet. If it's checked, I'm going to plug in some unrelated data into the [address] field. The script coding is in the footer section of the WebForm datapage. (The address field is hidden and is blank)

Many, many thanks for any ideas on what I'm doing wrong. Something simple, I hope :-)

Richard

Link to comment
Share on other sites

5 answers to this question

Recommended Posts

  • 0

Hi Richard,

If the checkbox is in the webform fields as a checkbox element you need to refer to it as InsertRecordCrossStreet like:

document.getElementById(\"InsertRecordCrossStreet\")

I also suggest you to refer to each element by calling their Id like the code above.

For example you can call Caspio form as:

document.getElementById(\"caspioform\").onsubmit=...

also document.getElementById(\"InsertRecordaddress\").value=...

B.M

Link to comment
Share on other sites

  • 0

Thanks for your help.

I'm not getting any results with this modification. Can you see the problem?

Is this correct, or should I assign (document.getElementById(\"InsertRecordCrossStreet\")) to a variable and then use the variable in the if statement? And is xxx.checked a correct way to refer to the value of the yes/no checkbox?

Thanks again.

function intersection()

{

if(document.getElementById(\"InsertRecordCrossStreet\")).checked){

document.getElementByID(\"InsertRecordaddress\").value==\"help\";

} else {

document.getElementByID(\"InsertRecordaddress\").value==\"me\";

}

}

document.getElementByID(\"CrimeEntryForm\").onsubmit=intersection;

Link to comment
Share on other sites

  • 0

Hello Richard,

Your code has some syntax errors, the correct one would be:

function intersection()

{

if(document.getElementById(\"InsertRecordCrossStreet\").checked){

document.getElementByID(\"InsertRecordaddress\").value=\"help\";

} else {

document.getElementByID(\"InsertRecordaddress\").value=\"me\";

}

}

document.getElementByID(\"CrimeEntryForm\").onsubmit=intersection;

I recommend you to download Firebug so you can see the errors when you run the web page --if you are using Firefox browser---

B.M

Link to comment
Share on other sites

  • 0

Thanks, I actually figured it out earlier today. I just installed Firebug -- thanks for the tip.

Richard

Hello Richard,

Your code has some syntax errors, the correct one would be:

function intersection()

{

if(document.getElementById("InsertRecordCrossStreet").checked){

document.getElementByID("InsertRecordaddress").value="help";

} else {

document.getElementByID("InsertRecordaddress").value="me";

}

}

document.getElementByID("CrimeEntryForm").onsubmit=intersection;

I recommend you to download Firebug so you can see the errors when you run the web page --if you are using Firefox browser---

B.M

Link to comment
Share on other sites

  • 0

This can be achieved by Triggered Actions also. Triggered Actions allow data manipulation, calculations and sending notifications by constructing application logic with a visual interface. They will be executed on specified events to perform actions on data in your tables. Here's a documentation about it: https://howto.caspio.com/tables-and-views/triggered-actions/

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
Answer this question...

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