Categories > TinyButStrong general >

'if' 'then' 'else' troubles within a block

The forum is closed. Please use Stack Overflow for submitting new questions. Use tags: tinybutstrong , opentbs
By: red
Date: 2004-04-03
Time: 13:38

'if' 'then' 'else' troubles within a block

hi there
i tried to get some information from a database and make it selectable: the template looked like this:

<form name="chooser" id="chooser" action="[sys.script_name]" method="get">
  <select name="id" size="30" onchange="document.chooser.submit();">
    <option value="[chooser.id;block=option]" [tbs_check.id;block=option;if [val]=[var.id];then selected='selected';else '']>
      [chooser.title;block=option]
    </option>
  </select>
</form>

but [val]=[var.id] seems always to be false even if i know they are equal. i tried this to be shure:

<form name="chooser" id="chooser" action="[sys.script_name]" method="get">
  <select name="id" size="30" onchange="document.chooser.submit();">
    <option value="[chooser.id;block=option]" [tbs_check.id;block=option;if [val]=[var.id];then selected='selected';else f[val]f[var.id]f]>
      [chooser.title;block=option]
    </option>
  </select>
</form>

which resultet in this output
<form name="chooser" id="chooser" action="index.php" method="get">
     <select name="id" size="30" onchange="document.chooser.submit();">
      <option value="1" f1f1f>
         1-test
      </option>
     </select>
</form>

so, i'm absolutly shure [val] and [var.id] are both '1' (without some spaces!)... why then [val]=[var.id] still seems to be false?

any suggestions?
thank you very much
red
By: red
Date: 2004-04-03
Time: 13:46

Re: 'if' 'then' 'else' troubles within a block

oops, sorry, there was a fault in my post i didn't mean
[tbs_check.id;block=option;if [val]=[var.id];then selected='selected';else '']
this was only for my own testing
it shurly was
[chooser.id;block=option;if [val]=[var.id];then selected='selected';else '']

:)
By: red
Date: 2004-04-03
Time: 13:58

Re: 'if' 'then' 'else' troubles within a block

found the solution:

<form name="chooser" id="chooser" action="[sys.script_name]" method="get">
      <select name="id" size="30" onchange="document.chooser.submit();">
        <option value="[chooser.id;block=option]">
          [chooser.title;block=option]
        </option>
        <option>[var.id;selected]</option>
      </select>
    </form>
thank you! ;)
By: red
Date: 2004-04-03
Time: 22:11

Re: 'if' 'then' 'else' troubles within a block

well yes, found a solution... but still would like to know why my first version didn't work... it would be more what i expected (i don't need a new entry when the selected value wasn't found)...

thanks!