[Select Tag] setting option text

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

[Select Tag] setting option text

sergio_101
I am creating a select for options like:

- 25 miles
- 50 miles
- 75 miles
- 100 miles

The miles part, i don’t want, i just want the value..

i am currently setting list: for an array of the above values..

i get:

<select id="selectDistance" class="form-control" name="2”>
<option value="1">25 Miles</option>
<option value="2">50 Miles</option>
<option value="3">75 Miles</option>
<option value="4">100 Miles</option>
</select>

i am wondering if i could do something that would allow me to set the value and the text.. 

so the value would be 25 or 50, etc..
and the text in the option would be 25 miles, 50 miles, etc..

so i would  get:

<select id="selectDistance" class="form-control" name="2”>
<option value=“25">25 Miles</option>
<option value=“50">50 Miles</option>
<option value=“75">75 Miles</option>
<option value=“75">100 Miles</option>
</select>

so setting the selected: 50 would mark the appropriate option as selected.

Thanks!

Thanks!

----
peace,
sergio
photographer, journalist, visionary


_______________________________________________
seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
Reply | Threaded
Open this post in threaded view
|

Re: [Select Tag] setting option text

Johan Brichau-2
Hi Sergio,

You can render options directly. Here’s the gist of it:
- use WAHtmlCanvas>>option brush nested in a ’select’.
- use #dispatchCallback to ‘dispatch’ the callback from the select tag to the nested option tags.

html select
dispatchCallback;
with: [ 
  html option
value: 50;
callback: [ aBlock value: 50 ];
label: ‘500 Miles’.

html option
value: 100;
callback: [ aBlock value: 100 ];
label: ‘100 Miles’ ]

Cheers
Johan

On 26 Jan 2019, at 07:32, sergio ruiz <[hidden email]> wrote:

I am creating a select for options like:

- 25 miles
- 50 miles
- 75 miles
- 100 miles

The miles part, i don’t want, i just want the value..

i am currently setting list: for an array of the above values..

i get:

<select id="selectDistance" class="form-control" name="2”>
<option value="1">25 Miles</option>
<option value="2">50 Miles</option>
<option value="3">75 Miles</option>
<option value="4">100 Miles</option>
</select>

i am wondering if i could do something that would allow me to set the value and the text.. 

so the value would be 25 or 50, etc..
and the text in the option would be 25 miles, 50 miles, etc..

so i would  get:

<select id="selectDistance" class="form-control" name="2”>
<option value=“25">25 Miles</option>
<option value=“50">50 Miles</option>
<option value=“75">75 Miles</option>
<option value=“75">100 Miles</option>
</select>

so setting the selected: 50 would mark the appropriate option as selected.

Thanks!

Thanks!

----
peace,
sergio
photographer, journalist, visionary

_______________________________________________
seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside


_______________________________________________
seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
Reply | Threaded
Open this post in threaded view
|

Re: [Select Tag] setting option text

Sven Van Caekenberghe-2
Wow, never heard of #dispatchCallback ;-)

Can this also not be done simply with #labels:

        html select
                list: #(25 50 75 100);
                labels: [ :each | each asString , ' miles' ];
                callback: [ :value | ... ]

?

> On 26 Jan 2019, at 09:18, Johan Brichau <[hidden email]> wrote:
>
> Hi Sergio,
>
> You can render options directly. Here’s the gist of it:
> - use WAHtmlCanvas>>option brush nested in a ’select’.
> - use #dispatchCallback to ‘dispatch’ the callback from the select tag to the nested option tags.
>
> html select
> dispatchCallback;
> with: [
>   html option
> value: 50;
> callback: [ aBlock value: 50 ];
> label: ‘500 Miles’.
>
> html option
> value: 100;
> callback: [ aBlock value: 100 ];
> label: ‘100 Miles’ ]
>
> Cheers
> Johan
>
>> On 26 Jan 2019, at 07:32, sergio ruiz <[hidden email]> wrote:
>>
>> I am creating a select for options like:
>>
>> - 25 miles
>> - 50 miles
>> - 75 miles
>> - 100 miles
>>
>> The miles part, i don’t want, i just want the value..
>>
>> i am currently setting list: for an array of the above values..
>>
>> i get:
>>
>> <select id="selectDistance" class="form-control" name="2”>
>> <option value="1">25 Miles</option>
>> <option value="2">50 Miles</option>
>> <option value="3">75 Miles</option>
>> <option value="4">100 Miles</option>
>> </select>
>>
>> i am wondering if i could do something that would allow me to set the value and the text..
>>
>> so the value would be 25 or 50, etc..
>> and the text in the option would be 25 miles, 50 miles, etc..
>>
>> so i would  get:
>>
>> <select id="selectDistance" class="form-control" name="2”>
>> <option value=“25">25 Miles</option>
>> <option value=“50">50 Miles</option>
>> <option value=“75">75 Miles</option>
>> <option value=“75">100 Miles</option>
>> </select>
>>
>> so setting the selected: 50 would mark the appropriate option as selected.
>>
>> Thanks!
>>
>> Thanks!
>>
>> ----
>> peace,
>> sergio
>> photographer, journalist, visionary
>>
>> Public Key: http://bit.ly/29z9fG0
>> #BitMessage BM-NBaswViL21xqgg9STRJjaJaUoyiNe2dV
>> http://www.codeandmusic.com
>> http://www.twitter.com/sergio_101
>> http://www.facebook.com/sergio101
>> _______________________________________________
>> seaside mailing list
>> [hidden email]
>> http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
>
> _______________________________________________
> seaside mailing list
> [hidden email]
> http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside

_______________________________________________
seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
Reply | Threaded
Open this post in threaded view
|

Re: [Select Tag] setting option text

sergio_101
Let me try this.. thanks!

On January 26, 2019 at 10:30:40 AM, Sven Van Caekenberghe ([hidden email]) wrote:

html select
list: #(<a href="tel://25 50 75 100" style="word-wrap:break-word;word-break:break-word;font-family:&quot;helvetica Neue&quot;,helvetica;font-size:14px;font-style:normal;font-variant-caps:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px">25 50 75 100);
labels: [ :each | each asString , ' miles' ];
callback: [ :value | ... ]
----
peace,
sergio
photographer, journalist, visionary


_______________________________________________
seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
Reply | Threaded
Open this post in threaded view
|

Re: [Select Tag] setting option text

Johan Brichau-2
In reply to this post by Sven Van Caekenberghe-2
Ha, yes, in this case that’s the easier solution ;)
Directly rendering the options themselves is not required for this case.

Johan

> On 26 Jan 2019, at 16:30, Sven Van Caekenberghe <[hidden email]> wrote:
>
> Wow, never heard of #dispatchCallback ;-)
>
> Can this also not be done simply with #labels:
>
> html select
> list: #(25 50 75 100);
> labels: [ :each | each asString , ' miles' ];
> callback: [ :value | ... ]
>
> ?
>
>> On 26 Jan 2019, at 09:18, Johan Brichau <[hidden email]> wrote:
>>
>> Hi Sergio,
>>
>> You can render options directly. Here’s the gist of it:
>> - use WAHtmlCanvas>>option brush nested in a ’select’.
>> - use #dispatchCallback to ‘dispatch’ the callback from the select tag to the nested option tags.
>>
>> html select
>> dispatchCallback;
>> with: [
>> html option
>> value: 50;
>> callback: [ aBlock value: 50 ];
>> label: ‘500 Miles’.
>>
>> html option
>> value: 100;
>> callback: [ aBlock value: 100 ];
>> label: ‘100 Miles’ ]
>>
>> Cheers
>> Johan
>>
>>> On 26 Jan 2019, at 07:32, sergio ruiz <[hidden email]> wrote:
>>>
>>> I am creating a select for options like:
>>>
>>> - 25 miles
>>> - 50 miles
>>> - 75 miles
>>> - 100 miles
>>>
>>> The miles part, i don’t want, i just want the value..
>>>
>>> i am currently setting list: for an array of the above values..
>>>
>>> i get:
>>>
>>> <select id="selectDistance" class="form-control" name="2”>
>>> <option value="1">25 Miles</option>
>>> <option value="2">50 Miles</option>
>>> <option value="3">75 Miles</option>
>>> <option value="4">100 Miles</option>
>>> </select>
>>>
>>> i am wondering if i could do something that would allow me to set the value and the text..
>>>
>>> so the value would be 25 or 50, etc..
>>> and the text in the option would be 25 miles, 50 miles, etc..
>>>
>>> so i would  get:
>>>
>>> <select id="selectDistance" class="form-control" name="2”>
>>> <option value=“25">25 Miles</option>
>>> <option value=“50">50 Miles</option>
>>> <option value=“75">75 Miles</option>
>>> <option value=“75">100 Miles</option>
>>> </select>
>>>
>>> so setting the selected: 50 would mark the appropriate option as selected.
>>>
>>> Thanks!
>>>
>>> Thanks!
>>>
>>> ----
>>> peace,
>>> sergio
>>> photographer, journalist, visionary
>>>
>>> Public Key: http://bit.ly/29z9fG0
>>> #BitMessage BM-NBaswViL21xqgg9STRJjaJaUoyiNe2dV
>>> http://www.codeandmusic.com
>>> http://www.twitter.com/sergio_101
>>> http://www.facebook.com/sergio101
>>> _______________________________________________
>>> seaside mailing list
>>> [hidden email]
>>> http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
>>
>> _______________________________________________
>> seaside mailing list
>> [hidden email]
>> http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
>
> _______________________________________________
> seaside mailing list
> [hidden email]
> http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside

_______________________________________________
seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
Reply | Threaded
Open this post in threaded view
|

Re: [Select Tag] setting option text

sergio_101
I ended up doing this:

> html select
> list: #(<a href="tel://25 50 75 100" style="font-family:&quot;helvetica Neue&quot;,helvetica;font-size:14px;word-wrap:break-word;word-break:break-word">25 50 75 100);
> labels: [ :each | each asString , ' miles' ];
> callback: [ :value | … ]

works perfectly..

refactored the mess i made to handle al this into just 2 accessors..

thanks!

On January 28, 2019 at 1:22:01 AM, Johan Brichau ([hidden email]) wrote:

Ha, yes, in this case that’s the easier solution ;)
Directly rendering the options themselves is not required for this case. 

Johan
----
peace,
sergio
photographer, journalist, visionary


_______________________________________________
seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside