Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Let's say you do a <code>$.post</code> to your server, with the selected company. Let's say the user selected company 1. Then, on the server, you want to a query like:</p> <pre><code>SELECT position.level, position.name FROM position JOIN company_position ON position.id = company_position.pid JOIN company ON company.id = company_position.cid WHERE company.id = ? </code></pre> <p>Now, you should have a result set with <code>(1, SE), (2, SE1), (3, SE2)</code> given your data above. I would send this back as a JSON object (I don't know what server environment you have, so building this structure is up to you):</p> <pre><code>{ "min": 1, "max": 3, "positions": { "1": "SE", "2": "SE1", "3": "SE2" } } </code></pre> <p>Alternately, if there are few positions, you could let the client calculate max and min, just sending JSON:</p> <pre><code>{ "1": "SE", "2": "SE1", "3": "SE2" } </code></pre> <p>And calculating max, min with javascript:</p> <pre><code>var max = Math.max.apply(null, Object.keys(response)) , min = Math.min.apply(null, Object.keys(response)); </code></pre> <p>In your javascript, given the object</p> <pre><code>var result = { "min": 1, "max": 3, "positions": { "1": "SE", "2": "SE1", "3": "SE2" } }; </code></pre> <p>You can query that object like this: <code>positions["1"] == "SE"</code>. So, if you want to show the labels for min and max, you would find the values for min and max like so:</p> <pre><code>var min = result.min, max = result.max </code></pre> <p>And you find their labels like this:</p> <pre><code>var minLabel = result.positions[result.min] , maxLabel = result.positions[result.max]; </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload