Jump to content
  • 0

Multi-Select List Box In Submission Form


JayGuarnieri

Question

Hi, 

 

I'm using a submission form as a search form (auto submit with virtual fields) but cannot get the multi-select to work. The only reference I could find to it was here. 

 

http://forums.caspio.com/index.php/topic/3148-js-select-multiple-values-from-a-listbox-in-a-webform/?hl=%2Bselect+%2Bmultiple+%2Bvalues+%2Bfrom+%2Blistbox+%2Bwebform#entry9870

 

I've followed these simple instructions but still can't multi-select. Not sure where I can be going wrong.

 

Any help appreciated.

Thanks

Link to comment
Share on other sites

9 answers to this question

Recommended Posts

  • 0
I think I have code blindness  :blink: . Can you spot anything obvious as to why the second parameter isn't returning any records even if a single selection is made? The first field works like a charm.

 

<script type="text/javascript">

   var fieldName1 = "cbParamVirtual1";

   var fieldName2 = "cbParamVirtual2";

   var x1=document.getElementsByName(fieldName1);

   var x2=document.getElementsByName(fieldName2);

  x1[0].multiple=true;

  x2[0].multiple=true;

   

function splitAndParse()

{

var result1 = "";

var result2 = "";

var cleanResult1 = "";

var cleanResult2 = "";

 

for (var i = 0; i < x1[0].length; i++) { 

if (x1[0].options.selected) { 

result1 += "\""+x1[0].options.value+"\"" + " OR " ; }} 

if (x1[0].length > 4) { cleanResult1 = result1.substring(0,(result1.length-4)); }

document.getElementById("cbParamVirtual7").value = cleanResult1;

 

for (var i = 0; i < x2[0].length; i++) { 

if (x2[0].options.selected) { 

result2 += "\""+x1[0].options.value+"\"" + " OR " ; }} 

if (x2[0].length > 4) { cleanResult2 = result2.substring(0,(result2.length-4)); }

document.getElementById("cbParamVirtual8").value = cleanResult2;

 

}

 

document.getElementById("caspioform").onsubmit=splitAndParse;

</script>

Link to comment
Share on other sites

  • 0

Hi,

 

Maybe, here:

 

for (var i = 0; i < x2[0].length; i++) { 
if (x2[0].options.selected) { 
result2 += "\""+x1[0].options.value+"\"" + " OR " ; }} 
if (x2[0].length > 4) { cleanResult2 = result2.substring(0,(result2.length-4)); }
document.getElementById("cbParamVirtual8").value = cleanResult2;

 

Probably, should be x2

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...
×
×
  • Create New...