Categories > TinyButStrong general >

empty <select>

The forum is closed. Please use Stack Overflow for submitting new questions. Use tags: tinybutstrong , opentbs
By: clasen
Date: 2005-04-12
Time: 07:33

empty <select>

<select name="[selectVars.selectName]">
    <option>[selectVars.selected;magnet=option;selected]</option>
    <option value="[srcSelect.id;block=option;magnet=select]">[srcSelect.nombre]</option>
</select>

Hi skrol29!
Your template engine is great!

I tell you mi problem...
When the content (srcSelect) is empty i want an empty out, then i use the attribute "magnet=select" buy i donĀ“t have an empty out.

I get that
<select name="testTest">

</select>
What i'am doing wrong?

Thank you in advance
By: Skrol29
Date: 2005-04-12
Time: 10:43

Re: empty <select>

hi Clasen,

Parameter 'magnet' deletes the <option> tag when the fiedl is empty, I that is not what you need..
I suggest that you use a nodata section instead. 
<select name="[selectVars.selectName]">
  <option value="[srcSelect.id;block=option]">[srcSelect.nombre]</option>
  <option>[srcSelect;block=option;nodata]</option>
</select>
By: clasen
Date: 2005-04-12
Time: 16:28

Re: empty <select>

With your template model, i get that
<select name="testTest">
  <option></option>
</select>
I want to get an empty string, or nothing... when srcSelect is empty.

bye bye
By: Skrol29
Date: 2005-04-12
Time: 16:32

Re: empty <select>

What do you mean by empty string or nothing ?
What Html code do you whant when the data source has no record?
By: clasen
Date: 2005-04-12
Time: 16:58

Re: empty <select>

i want an empty out, nothin

if the data source has no record
else
<select name="test">
<option>rsValTest</option>
<option>rsValTest</option>
</select>

Thanks
By: Skrol29
Date: 2005-04-12
Time: 17:05

Re: empty <select>

Ok, so you have to define a magnet feature on the <select> tag.
For example:
<select name="[selectVars.selectName]">
  <option value="[srcSelect.id;block=option]">[srcSelect.nombre]</option>
  [srcSelect.#;if [val]=0;then '';else ' ';magnet=select]
</select>
By: clasen
Date: 2005-04-19
Time: 07:07

Re: empty <select>

Yeah!! It's works!
Thanks
By: Ignacio
Date: 2005-04-19
Time: 07:45

Re: empty <select>

<table width="100%" border="0" cellpadding="0" cellspacing="3">
<tr>
<td><input type="checkbox" ></td>
<td><p>[eq.equipamiento;block=tr]</p></td>
<td>
<p>
<select name="id_equipamiento_op">
<option value="[eqop.id;block=option;p1=[eq.id]]">[eqop.opcion]</option>
[eqop.#;if [val]=0;then '';else ' ';magnet=select]
</select></p></td>
</tr>
</table>

Server Side:
$mmmd->setMySqlLink();

mysql_select_db($mmmd->mySqlDb,$mmmd->_mySqlLink);

$tbs->MergeBlock('eq',$mmmd->_mySqlLink,'SELECT '.$tabla12.'.equipamiento,'.$tabla12.'.id FROM '.$tabla12.'');

$tbs->MergeBlock('eqop',$mmmd->_mySqlLink,'SELECT '.$tabla13.'.opcion,'.$tabla13.'.id FROM '.$tabla13.' WHERE '.$tabla13.'.id_equipamientos=%p1%');


i'm using sub blocks (working perfect), but i want when the query is '' delete the <select>, i try with your code but don't work.

Thanks.
By: Skrol29
Date: 2005-04-19
Time: 14:23

Re: empty <select>

Hi Ignacio,

In your case, [eqop.#] doesn't return 0 when there is no data because of the sub-block mode. In fact [eqop.#] returns the total number of merged lignes over all sub-blocks.

You can work around this problem by using a 'nodata' section instead of the [eqop.#] field. Example:
<select name="id_equipamiento_op">
  <option value="[eqop.id;block=option;p1=[eq.id]]">
    [eqop.opcion]
  </option>
  [eqop;block=begin;nodata][onshow;magnet=select][eqop;block=end]
</select>

It's important to use an [onshow] tag instead of an [onload] tag because it has to be processed after the MergeBlock() call in order to delete the <select> tag only if there is no data.
By: Ignacio
Date: 2005-04-19
Time: 17:32

Re: empty <select>

wowowoooooo is very nice! working perfect!! every day this being prettier

sorry about my questions infitiny, I am wanted to learn well TBS
sorry my english! jeje

PD: skrol29, you're a genius!!