Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I can think of two options.</p> <p>Option 1: have hidden elements with the "real text", let's say:</p> <pre><code>&lt;input type="option1" value="Real text1" /&gt; &lt;input type="option2" value="Real text2" /&gt; </code></pre> <p>Then, when onchange is detected, repopulate select list (similar as you have, but instead for one element, apply the real text for all), then apply your code for selected (the '...').</p> <p>Option 2: before change the text to '...', save the state, I guess you only would need two javascript variables, let's say:</p> <pre><code>var actualOption = 0; var realText = ''; </code></pre> <p>Before apply the '...', set the actual state to those variables when onchange detected, something like: 1 - before change, set realText on actualOption (the option that is actually with '...') 2 - save realText plus actualOption with the new option (that is going to be changed) 3 - apply the '...'</p> <p>When new onchange detected, it should restore the text of the option previously selected, and set the new one.</p> <p>Hope you understand...</p> <p>EDIT: Long time that I don't work purely JS, but I'll try.</p> <p>At some point on your code, declare 2 global vars:</p> <pre><code>var actualOption = 0; var realText = ''; </code></pre> <p>On your onchange function apply something like:</p> <pre><code>(...) if (actualOption!=0) option[actualOption].text = realText; (...) </code></pre> <p>On your if(option[selectedIndex....., apply something like:</p> <pre><code>var val = option[selectedIndex].text; realText = val; actualOption = selectedIndex; option[selectedIndex].text = option[selectedIndex].text.substr(0,N) + "..."; </code></pre> <p>In Resume: Save the state of your selected option before change. When new onchange detected, restore previous selected option, and save the new selected option state.</p> <p>I think it should work.</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.
    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