Jump to content

Comma separated values to new record in table


Recommended Posts

Hi there,

I've built a page that has a grid of images, allowing users to click on these images to make a selection ... and then I want these selections to all be saved to a table as separate entries along with their user information.

So far, I can get only 1 selection to pass to the table.  If they click on one of the images, that is sent to the table, fine.  I've set it up so that each selection is added to the string, separated by a comma, but then this passes to the table as a single entry with the comma separated string.

This is my code:

function SelDatasource1() {
    document.getElementById("Datasource1").className = "SELECTED";
    document.getElementById("InsertRecordDatasource").value += "Datasource1,";
    document.getElementById("InsertRecordProject").value += "[@authfield:User_info_Project],";
    document.getElementById("InsertRecordDatasource").multiple = true;
}

function SelDatasource2() {
    document.getElementById("Datasource2").className = "SELECTED";
    document.getElementById("InsertRecordDatasource").value += "Datasource2,";
    document.getElementById("InsertRecordProject").value += "[@authfield:User_info_Project],";
    document.getElementById("InsertRecordDatasource").multiple = true;
}

...etc etc ... there are over 30 of these.

If somebody selects Datasource1, Datasource5, Datasource12, it shows up in the table like this:

PROJECT                                         DATASOURCE

Project1,Project1,Project1          Datasource1,Datasource5,Datasource12

I am using a Submission form datapage at present, and have added my code using html blocks and footer.

2 things I need help on:

1. I know there is a better way to add a comma to the string, other than putting it in like this (i.e. value +="Datasource1,").  This way, a comma is added for a single entry and at the end of a long string, which I don't want to do - can anybody help me with this?

2. Can I pass this comma separated string so that it shows up in my table like this:

PROJECT                                         DATASOURCE

Project1                                          Datasource1

Project1                                          Datasource5

Project1                                          Datasource12

Any help would be greatly appreciated!

Many thanks

Nikki

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