How to run js on client side using JSScript?

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

How to run js on client side using JSScript?

squeakman
Hello,

I have a dropdownList using an "html select". When the user clicks on an
item in the list, I would like to know the index of the selected item.

I am using the callback:value: method to try and get the value of the
selected index but what I am getting back is the literal string of the
javascript code.

What do I have to do to get the code
document.getElementById('listItems').selectedIndex
to be run on the client side and have the results returned to me?


Thanks,
Frank

----- code follows ----


| javaScriptCode |

javaScriptCode := Javascript.JSScript new add:
     'document.getElementById(''listItems'').selectedIndex'; yourself.

(html select)
     id: 'listItems';
     list: dropDownListChoices;
     callback: [:v | ];

     onClick: ((html scriptaculous request)
         triggerForm: (html scriptaculous element up: 'form');
         callback: [:v | self halt]
         value: javaScriptCode )







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

Re: How to run js on client side using JSScript?

Paul DeBruicker
I think you should use onChange.  I'm not familiar with scriptaculous
but using jQuery rather than scriptaculous it'd look like this:

html select
        list: dropDownListChoices
        onChange:html jQuery ajax serializeThis;
        callback:[:val | self halt.].





On 09/20/2011 10:57 AM, squeakman wrote:

> Hello,
>
> I have a dropdownList using an "html select". When the user clicks on an
> item in the list, I would like to know the index of the selected item.
>
> I am using the callback:value: method to try and get the value of the
> selected index but what I am getting back is the literal string of the
> javascript code.
>
> What do I have to do to get the code
> document.getElementById('listItems').selectedIndex
> to be run on the client side and have the results returned to me?
>
>
> Thanks,
> Frank
>
> ----- code follows ----
>
>
> | javaScriptCode |
>
> javaScriptCode := Javascript.JSScript new add:
> 'document.getElementById(''listItems'').selectedIndex'; yourself.
>
> (html select)
> id: 'listItems';
> list: dropDownListChoices;
> callback: [:v | ];
>
> onClick: ((html scriptaculous request)
> triggerForm: (html scriptaculous element up: 'form');
> callback: [:v | self halt]
> value: javaScriptCode )
>
>
>
>
>
>
>
> _______________________________________________
> 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