Jump to content
  • 0

Select multiple values from checkboxes


ppbb123
 Share

Question

3 answers to this question

Recommended Posts

  • 0

It needs extra JS code. Two main steps:

1. If the checkbox is selected, then save the value in a variable.

2. Combine all the saved values into the real field.

For example, there are there Virtual checkboxes, which element id are cbParamVirtual1, cbParamVirtual2, and cbParamVirtual3. When these checkboxes are selected, the selected values will be combined into FieldName and saved in the table after submitting.

<SCRIPT LANGUAGE="JavaScript">
//variables save the values from checkboxes
var community1 = "", community2 = "", community3 = "";  

//when he checkbox is selected, variable is equal to the selected value of checkbox, otherwise variable is blank
function com1()
{
if(document.getElementById("cbParamVirtual1").checked)
community1 = document.getElementById("cbParamVirtual1").value;
else
community1 ="";
}

function com2()
{
if(document.getElementById("cbParamVirtual2").checked)
community2 = document.getElementById("cbParamVirtual2").value;
else
community2 =""; 
}

function com3()
{
if(document.getElementById("cbParamVirtual3").checked)
community3 = document.getElementById("cbParamVirtual3").value;
else
community3 =""; 
}

//whenever the checkbox is clicked, variable value will change.
document.getElementById("cbParamVirtual1").onclick= com1;
document.getElementById("cbParamVirtual2").onclick= com2;
document.getElementById("cbParamVirtual3").onclick= com3;

//Combine all the saved values into the real field
function concatenate()
{
document.getElementById("InsertRecordFieldName").value = community1 + " " + community2 + " " + community3; 
}

//click submit button to call Combine function
document.getElementById("caspioform").onsubmit=concatenate;
</SCRIPT>
Link to comment
Share on other sites

  • 0

@fangjie: I see you mentioned that the virtual checkboxes have element ids of cbParamVirtual1, cbParamVirtual2, etc. Where do you find the element ids for various elements/the naming of various caspio objects? I can't find the right names to get JS to run correctly and want to concatenate data from a listbox into a virtual field. (Also related, do you know if I would need to make the virtual field a listbox as well?)

Thanks for your help!

Link to comment
Share on other sites

  • 0

Hi,

Just to update this post, you may also try to consider using "List-String" data type in your table so that you can select multiple for 1 field. You can refer to this screen shot: http://prntscr.com/mlr541

You just need to set different choices in your table so that they can choose different options. You may check this screen shot: http://prntscr.com/mlr5wv

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