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

Question

Question

Is it possible to populate dropdown from query with attached values?

asked on October 22, 2014

I have learned how to populate dropdowns from a view or Stored Procedure, and I have found out how to populate a single line field from a value that is assigned to a dropdown using javascript.  What I need to do is to populate a dropdown with understandable options like Dell D-600, iPad Mini-Slate, Apple TV and have values assigned to each option that are their serial numbers.  So that I can use the serial number to populate the single line field and perform an additional look up off that to bring up the repair history of the item assigned to a teacher into a table.

Any Ideas?  Is it possible?

0 0

Answer

SELECTED ANSWER
replied on October 23, 2014

I can give you some advice on how you can manage the dropdown list programmatically using Javascript. The actual dropdown is created using HTML elements, a <select> object with a collection of <option> objects nested below it. They have the following syntax:

<select id="Field20" class="form-item-field cf-medium" vo="e" name="Field20">
    <option value="1">choice 1</option>
    <option value="2">choice 2</option>
    <option value="3">choice 3</option>
</select>

Notice that the value of each choice is a "value" attribute of the option element, and the option text is between the opening and closing tags. You need to modify the HTML of the page to change the list. For instance, if I wanted to remove all these options from my dropdown (id=q20) and replace them with new ones, I could do the following:

var target = $('#q20 select');
target.find('option').remove();
$('<option value="1">1 Point</option>').appendTo(target);
$('<option value="3">3 Points</option>').appendTo(target);
$('<option value="5">5 Points</option>').appendTo(target);

If you want to read the text or values, you need to find the ':selected' option associated with your dropdown. This will display both the text and value of the dropdown any time it changes:

$('#q20 select').change( function () {
      alert("Value: "+$('#q20 :selected').val()+"    Text: "+$('#q20 :selected').text());
});

Perhaps you can integrate this with Ken's suggestion of using hidden fields to get the end result you're looking for.

Also, as a beginniner with Javascript, I strongly recommend using a browser with good developer tools, like Firefox or IE which have a DOM inspector. It'll really help you understand the structure of the HTML, how the CSS rules apply to the elements, and how to find and select the right properties to modify with JS.

0 0

Replies

replied on October 22, 2014

It is currently not possible. It has been requested though.

1 0
replied on December 3, 2014

Any idea when this will be possible?  I've upgrade to 9.2 hoping that it would be there.  It is a very critical feature that is holding me back from scheduling any form development with this product.

0 0
replied on October 22, 2014

populate a hidden field and use javascript to trigger a change that does the lookup. 

1 0
replied on October 23, 2014 Show version history

I have been considering that but having difficulty finding the "value" string in the web form.  My line of thought is to populate it similar to that of a radio button but instead of using the .checked use the equivalent such as .value if it exists.  I am so new that I just don't know where to look to see what the field of the dropdown are in the actual form code.  I imagine that I need to have the assign values check box checked so that the system creates a holder for those values.  Any ideas on where to look or the syntax of the javascript to reference that location?  I am recently new to Javascript as well, I did obtain a book and am studying ;-).  Which might not be a good thing.

Thought Map:

     Populate Dropdown 1 with make-model info as readable choices. (class: dropdown)

     Populate Dropdown 2 with serial numbers (Hidden with class:  fillableField)

     Javascript using case (dropdown option a).field = (fillableField option a).value

                                         (dropdown option b).field = (fillableField option b).value

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

Sign in to reply to this post.