Jump to content

Automatically Add To An Array


Recommended Posts

Hi. I need to collect data from several different drop-downs, then combine the results into a single array in my data table. How would I do that?

 

Example:

If I collect 5 as the value for dropdown_1, and 3 for the value of dropdown_2, and 4 for the value of dropdown_3, I would need to be able to use that to create an array in another field (dropdown_values) such as:  5, 3, 4

 

I'm guessing this is a javascript thing. Any idea how to do that?

 

Thanks for any help.

Link to comment
Share on other sites

Hello abitaquest,

 

As far as I know, there is an article how Concatenate/Combine two fields into one field.

In your case, if I understand correctly, dropdowns will be dynamic fields.

I have edited the script:



<SCRIPT LANGUAGE="JavaScript">


function concatenate()
{
   var elems = document.getElementsByTagName("*");
   for (var i=0, m=elems.length; i<m; i++)
      {
         if (elems[i].id && elems[i].id.indexOf("InsertRecorddropdown_1") != -1)
            {
                var position1 = elems[i].value;
            } 
      }

   var elems = document.getElementsByTagName("*");
   for (var i=0, m=elems.length; i<m; i++)
      {
         if (elems[i].id && elems[i].id.indexOf("InsertRecorddropdown_2") != -1)
            {
               var position2 = elems[i].value;
            }
      }

   var allpositions = position1 + ", " + position2;
   document.getElementById("InsertRecorddropdown_values").value = allpositions;
}

document.getElementById("caspioform").onsubmit=concatenate;
</SCRIPT>


I hope it helps.

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