Note that there are some explanatory texts on larger screens.

plurals
  1. POwrong html output from the javascript
    primarykey
    data
    text
    <p>I wrote a script for populating a selectbox with a bunch of options.</p> <p>Initially the <code>data</code> is in the form of string of a format "key=value;key2=value2;etc...":</p> <pre><code>//split the string to distinguish between different options to populate a selectbox with var values = data.split(';'); //reset the length of the selectbox to be populated document.getElementById(child).options.length = 0; //create first default option document.getElementById(child).options[0] = new Option('all', '0'); for(var i = 0; i &lt; values.length; i++){ //check for and remove unnecessary characters values[i].replace(/\s+/g, ''); //split the option to get the key and value separately var options = values[i].split('='); if(!isEmpty(options[0]) &amp;&amp; !isEmpty(options[1])){ //insert a new element to the selectbox document.getElementById(child).options[i+1] = new Option(options[1], options[0]); } } </code></pre> <p>The example above populates a selectbox with the given html output:</p> <pre><code>&lt;option value="0"&gt;all&lt;/option&gt; &lt;option value=" 7"&gt;Bermuda&lt;/option&gt; &lt;option value="10"&gt;British Virgin Islands&lt;/option&gt; &lt;option value="15"&gt;Cayman Islands&lt;/option&gt; &lt;option value="42"&gt;Jamaica&lt;/option&gt; &lt;option value="74"&gt;St. Lucia&lt;/option&gt; &lt;option value="79"&gt;Trinidad Tobago&lt;/option&gt; </code></pre> <p>As you can notice above the second option in the selectbox has a corrupted string value. I need to fix that value because because of that cake cannot save this value properly.</p> <p>If you have any other questions please ask.</p>
    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. 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