You are viewing limited content. For full access, please sign in.

Question

Question

Forms drop down list - database populated AND manual entry?

asked on April 18, 2017

Is it possible to have a drop down list that is configured with a lookup rule that also have items configured on the list itself inside the form?


Example - I have a field that is populated with each of our work locations. I also wanted to add in (without modifying the database tables) an option for "unknown" and "analytical only"... how could I best achieve this?

0 0

Replies

replied on April 19, 2017

With Forms 10.2, you are able to do it by check the "Append choices to lookup results" checkbox when configure the drop-down field:

1 0
replied on April 18, 2017 Show version history

If you add this to JavaScript it will do it on the user-end. Not sure how Laserfiche will handle it on submit. Replace ".myselect" with your drop-down class name.

There might be a better way to combine the two also.

  $('.myselect select').append($('<option>', {value: 1,text: 'unknown'}));
  $('.myselect select').append($('<option>', {value: 2,text: 'analytical only'}));

 

replied on April 18, 2017 Show version history

If you try something like this it will show on the user-end. The 4 second delay is so that the Lookup Rule does not override the new appended values. Not sure how Laserfiche will handle it on submit though. 

I'm sure that there is a better way to combine the two values as well; just threw this example out to get it started.

setTimeout(function(){ 
      
      $('.myselect select').append($('<option>', {value: 1,text: 'unknown'}));
      $('.myselect select').append($('<option>', {value: 2,text: 'analytical only'}));

      }, 4000);

Or a combined way

setTimeout(function(){ 
  
	var dataArr = [{'value':'unknown','text':'unknown'},
               {'value':'analytical only','text':'analytical only'}];


// .each loops through the array
$.each(dataArr, function(i){
    $('.myselect select').append($("<option></option>")
                    .attr("value",dataArr[i]['value'])
                    .text(dataArr[i]['text']));
});
  
  
    }, 4000);

 

0 0
You are not allowed to follow up in this post.

Sign in to reply to this post.