I would appreciate some insight here:

I am used to drop downs being bound to database fields

I have a select drop down on a form used to populate the insert/update query sent to the server.

<td><select required id="position" name="position" onChange="changeFla +g(1)" > <option value="0">Select <option value="1">Board Member <option value="2">Administration <option value="3">General Member </select></td>

When I repopulate the form field with JSON

$('form').loadJSON(data);

, I expect the data from the database field to be displayed. All the other form input fields are populated correctly.

By the way, this: onChange="changeFlag(1) is not calling anything. A dummy

In reading:

Populating form element Form is populated with JSON object using the following JavaScript call: $('form').loadJSON(data); This call matches object properties with the form elements by name and depending on the type of the form element populates value. Following rules are used while the form elements are populated:

Multiple selection lists

When plugin matches property with multiple selection list element, it expect that property is array of values that should be selected in the list. Plugin selects all values in the multi selection list that exist in the property of the JavaScript object.

Assuming that a "select" control comes under the definition of "Multiple selection lists", it sounds as if it would work and display the applicable JSON content.

I set up a test with a select where I use a button to change the "value" of the select index and that works fine.

Evidently, $('form').loadJSON(data), does not address the indexing as implied above.


In reply to Re^2: JSON Return Values by tultalk
in thread JSON Return Values by tultalk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.