Categories > TinyButStrong general >

HTML Select and Empty Values

The forum is closed. Please use Stack Overflow for submitting new questions. Use tags: tinybutstrong , opentbs
By: Anthony
Date: 2012-04-10
Time: 21:46

HTML Select and Empty Values

How does one get TBS to not make a selection and leave select blank when the field is empty? The first way I did it selects one of the options although the field from the database is empty. The second way I tried does not work either. The third way works but puts an empty selection in the dropdown, which I don't want.

First Way:
select id="genre" name="genre">
    <option>[songblock.genre;ope=html;select]</option>
    <option value="Sacred">Sacred</option>
    <option value="Christmas">Christmas</option>
</select>

Second Way:
select id="genre" name="genre">
    <option>[songblock.genre;ope=html;select; magnet=option]</option>
    <option value="Sacred">Sacred</option>
    <option value="Christmas">Christmas</option>
</select>


Third Way:
select id="genre" name="genre">
    <option>[songblock.genre;ope=html;select; magnet=option]</option>
    <option value=""></option>
    <option value="Sacred">Sacred</option>
    <option value="Christmas">Christmas</option>
</select>
By: Skrol29
Date: 2012-04-10
Time: 23:48

Re: HTML Select and Empty Values

Hi Anthony,

If the value is not found, then the plug-in does not select any option in the template.
If you can the the first item selected, it is probably because of the navigator. But if you check the HTML source of the result, it should be no selected item.
By: Anthony
Date: 2012-04-11
Time: 04:57

Re: HTML Select and Empty Values

You are correct that in the html source there is no selected item, but only the third way I spoke of above allows me to have no selection showing when the field from the DB is empty. It appears that is the way to provide for a blank selection.
By: Skrol29
Date: 2012-04-11
Time: 15:22

Re: HTML Select and Empty Values

You can also use parameter "addmissing" like this : [songblock.genre;ope=html;select;addmissing]
Then the empty item will be added (and selected by the way) only if the value is empty.

http://www.tinybutstrong.com/plugins.php?help#plugin_html
By: Anthony
Date: 2012-04-11
Time: 16:26

Re: HTML Select and Empty Values

Thanks!