Categories > TinyButStrong general >

non-English characters with conditional

The forum is closed. Please use Stack Overflow for submitting new questions. Use tags: tinybutstrong , opentbs
By: Jaime
Date: 2003-09-09
Time: 22:01

non-English characters with conditional

Hello

I am trying to create a simple form with a "select", a "text field" and a submit button with the following functionalities:
-When user selects an option from the "select" menu, this option must appear into "text field"
-When the user press submit, the same page must be launched with the last chosen option selected in the "select" an the same text into the "text field"
To achieve this, I have tried with the following template:
<code>
<select name="secciones" onChange="nombreSeccion.value = this.value;>
<option value="[secciones_opt.seccion]" [var. nombreSeccion;selected]> [secciones_opt.seccion;block=opt]</option>
</select>
<input type="text" name="nombreSeccion" value="[var.nombreSeccion]">
</code>
This works fine with English characters, but I need to work with non English characters, as á or ú or even ñ, and then the "select" always shows the first option selected, while the "text field still works fine.
Does anybody know how to fix this?
I have solved it by changing the "value" attribute to a numerical value, and  adding some dynamically generated JavaScript, but it does not seem like an elegant solution to me...

Thank you

Jaime

note: sorry for my poor English...
By: Skrol29
Date: 2003-09-10
Time: 04:04

Re: non-English characters with conditional

Hello Jaime,

I've tried your code with the characters you've given as example, and it works fine for me.

Could you send or post the Html you've got after the merge ?
By: Jaime
Date: 2003-09-10
Time: 17:24

Re: non-English characters with conditional

Hello

I do not understand what is happening. I thought that if the condition was true, it will show "enabled" (only once) and if it was false, it will show nothing or just some spaces, but this is what I am getting:
When it works, html looks like this:

<option value="Con nombre propio" Con nombre propio selected selected selected selected selected>Con nombre propio</option><option value="Ciencia y tecnolog&iacute;a" Con nombre propio     >Ciencia y tecnolog&iacute;a</option><option value="Arag&oacute;n" Con nombre propio     >Arag&oacute;n</option><option value="Gastronom&iacute;a" Con nombre propio     >Gastronom&iacute;a</option><option value="Zaragoza" Con nombre propio     >Zaragoza</option>

and when it does not work:

<option value="Con nombre propio" Arag&oacute;n     >Con nombre propio</option><option value="Ciencia y tecnolog&iacute;a" Arag&oacute;n     >Ciencia y tecnolog&iacute;a</option><option value="Arag&oacute;n" Arag&oacute;n     >Arag&oacute;n</option><option value="Gastronom&iacute;a" Arag&oacute;n     >Gastronom&iacute;a</option><option value="Zaragoza" Arag&oacute;n     >Zaragoza</option>

Do you guess what is happening?

Thanks

Jaime
By: Skrol29
Date: 2003-09-11
Time: 10:58

Re: non-English characters with conditional

Hello Jame,

I think I understant what happens.
In the <select> block, you have to define one <option> line to be merged with you data source and wich will dipplay all the items.
And another different <option> line that will reprsente the value to be selected.

<select name="secciones" onChange="nombreSeccion.value=this.value;">
<option value="[secciones_opt.seccion]">[secciones_opt.seccion;block=opt]</option>
<option>[var.nombreSeccion;selected]</option>
</select>
By: Jaime
Date: 2003-09-11
Time: 16:25

Re: non-English characters with conditional

Hello

Well, results are more predictable now, but still it does not work with non-english characters. Here it is the results I am getting now:
When it works:
<option value="Con nombre propio" selected>Con nombre propio</option><option value="Ciencia y tecnolog&iacute;a" >Ciencia y tecnolog&iacute;a</option><option value="Arag&oacute;n" >Arag&oacute;n</option><option value="Gastronom&iacute;a" >Gastronom&iacute;a</option><option value="Zaragoza" >Zaragoza</option>
And when it does not work (the selected option is "Ciencia y tecnología, but it does not show selected, instead, it shows duplicated):
<option value="Con nombre propio" >Con nombre propio</option><option value="Ciencia y tecnolog&iacute;a" >Ciencia y tecnolog&iacute;a</option><option value="Arag&oacute;n" >Arag&oacute;n</option><option value="Gastronom&iacute;a" >Gastronom&iacute;a</option><option value="Zaragoza" >Zaragoza</option>
          <option >Ciencia y tecnolog&iacute;a</option>

Thank you for your time

Jaime
By: Skrol29
Date: 2003-09-11
Time: 17:08

Re: non-English characters with conditional

Hello Jaime,

I confirm that is a bug of TBS :(
That's a problem of Html conversion.
The 'select' feature compares each item's value with the variables value converted in Html. But it should compare it with the value not converted.

It will be corrected in the next version, but waiting for the next version, you can choose on of the 2 following issues:

1: Use a numric identifier for the option values. Like :
<option value="123">Ciencia y tecnolog&iacute;a</option>

or

2: Change a TBS line in the tbs_calss.php file.
In the function  tbs_Html_MergeOptionList(), replace
strcasecmp($Val,htmlentities($Value))==0
by
strcasecmp($Val,$Value)==0
But that's not all.
In you Html template use:
<option>[var.x;selected;htmlconv=no]</option>
instead of:
<option>[var.x;selected]</option>
And it should work (I've tested it).

Enjoy,

By: Jaime
Date: 2003-09-11
Time: 18:41

Re: non-English characters with conditional

Hello again

I have tried the first option and, as I said in my first post, it does not seem to be an elegant solution to me, because I have to deal with some dynamically generated javascript.
Your second option works fine, but I suppose that you have some security reasons to use the htmlentities() function, so, what about changing you code line like this?
strcasecmp(htmlentities($Val),htmlentities($Value))==0
It seems to work and it does not require to make any changes in the Html template.
Do you think it could cause any malfunction?

Thanks

Jaime
By: Skrol29
Date: 2003-09-11
Time: 19:20

Re: non-English characters with conditional

Hello Jaime,

That was not a security reason and both our new code are similar.
The reason was : I supposed that the value to find in the option list came from a database. But in your case, the value comes from a posted value chosen in a Html option list. So the Html conversion is a bad choice.