Developer forum

Forum » Development » Database Publishing - Multiselect

Database Publishing - Multiselect


Reply

Hi there

 

Just wanted to hear, if anyone had an suggestion to how I can make a Multiselectbox in Database Publishing.

 

I need it in the "edit" template - so it's possible to select more values for one field, and for each selection there will be subitted a post.

 

Example

 

Row:

| Selection1         |  <-

| Selection2         |

| Selection3         |  <-

| Selection4         |

 

I've selected 1 and 3 - and when I click submit I need to have two posts.

 

Anyone have an idea?


Replies

 
Nicolai Høeg Pedersen
Reply
kim@occinnovation.dk wrote:

Hi there

 

Just wanted to hear, if anyone had an suggestion to how I can make a Multiselectbox in Database Publishing.

 

I need it in the "edit" template - so it's possible to select more values for one field, and for each selection there will be subitted a post.

 

Example

 

Row:

| Selection1         |  <-

| Selection2         |

| Selection3         |  <-

| Selection4         |

 

I've selected 1 and 3 - and when I click submit I need to have two posts.

 

Anyone have an idea?


 

So you would need a statement like with "select from table where Field in (Selection1, Selection3)". Don't know if it is possible with DB pub.

 
Reply

You could post it twice using Javascript.
 

 

<script language="javascript">

document.form1.select1.selectedIndex = value1;

document.form1.submit();

document.form1.select1.selectedIndex = value2;

document.form1.submit();

</script>

 

 

You might want to do it using xmlhttp so the posting is done in the "background".

 
Reply

Hi again

Thank you for your fast respond. But I don't think I've described my question well enough.

If I make a box like this:

 

SELECT MULTIPLE SIZE=5

OPTION VALUE=Option 1

OPTION VALUE=Option 2

OPTION VALUE=Option 3

OPTION VALUE=Option 4

OPTION VALUE=Option 5

OPTION VALUE=Option 6

SELECT

 

And I select two posts, and click submit.

Would it be possible to make two records in the Database?

 

I considered something with a Javascript that "checks" after selections and opens pop-up windows which runs the "submit-function". But I would like to see that as my last resort :)

 
Reply

If you insist on using DBPub for this, you'd have to submit the form once for each selected option This code could work as inspiration for what you need:

<script language="javascript">
function multi(){
 for (i=0;i<document.form1.multiselect.options.length;i++){
  if (document.form1.multiselect.options[i].selected == true){
   alert(document.form1.multiselect[i].value);
  }
 }
 
}
</script>

 

If you're using your own code, do note that the multiple values selected are submitted as a comma separeted value that you can spit up and do with what you like.

 

Hope this helps:)

 

You must be logged in to post in the forum