[OT] Scriptaculous Slider

classic Classic list List threaded Threaded
10 messages Options
Reply | Threaded
Open this post in threaded view
|

[OT] Scriptaculous Slider

Steven Evans
Good evening....

Sorry if this is a bit OT....but I'm thinking that others have tried  
this.  I am working on online questionaires right now, and my client  
wants some "sliders" in lieu of radio, text, or checkboxes.

I have this working, and multiple on page.  but the problem I am  
having is in showing a text result, rather than an integer result.  My  
solution is working, but it is making a brutal amount of DB calls and  
I'm wondering if there is a better way to do it.   You will notice the  
var: new_loop here because I use multiple sliders on one page.....

In theory, though, everytime the person moves the slider, it makes a  
call to the db to translate the number to what I want the user to see  
(like 1 = Strongly disagree, 2 = Moderately Disagree, etc).  So, I'm  
trying to find a way to not have to call the DB everytime....I really  
want to see an array when I load the question, but I can only seem to  
set numbers instead of the corresponding phrases.

Any ideas?

Thanks!

sqe



          <div id="track[var:'new_loop']" style="width:200px; height:
9px;">
         <div id="track[var:'new_loop']-left"></div><div  
id="handle[var:'new_loop']" style="width:19px; height:20px;"><img  
src="/images/slider-images-handle.png" alt="" style="float: left;" /></
div>
                </div>
                <p id="showresult[var:'new_loop']">&nbsp;</p>


         [noprocess]
             <script type="text/javascript" language="javascript">
      // <![CDATA[
     
      // horizontal slider control
      new Control.Slider('handle[/noprocess][var:'new_loop']',  
'track[var:'new_loop'][noprocess]', {
      range: $R(1,7),
      values: [1,2,3,4,5,6,7],
      onSlide: function(v) {  var url='/findquesttype.lasso?order='  
+ v + '&questiontypeid=' + [/noprocess][field:'type_id'][noprocess];
                                                            var divplacement='showresult'+[/
noprocess][var:'new_loop'][noprocess];
                                                            new Ajax.Updater(divplacement, url,  
{evalScripts:true}); },
      onChange: function(v) { $('showresult[/noprocess]
[var:'new_loop'][noprocess]').innerHTML = 'changed: ' + v }
      });

      // ]]>
      </script>
                [/noprocess]

Steven Q. Evans
Director of Technological Resources
MSI Production Services
http://www.msiprod.com
(858)348-0629 • Mobile (858)344-3351 • (707)215-1032 Fax • [hidden email]





--
This list is a free service of LassoSoft: http://www.LassoSoft.com/
Search the list archives: http://www.ListSearch.com/Lasso/Browse/
Manage your subscription: http://www.ListSearch.com/Lasso/

Reply | Threaded
Open this post in threaded view
|

Re: [OT] Scriptaculous Slider

Gary Clark-2
Hi Steven,

Not sure if it is of any help, but here is a nice example, maybe you  
can backward engineer it to fit your needs.

https://w3-markup.com/order

Maybe you could even get them to help you out.

Gary Clark



On 17 Nov 2008, at 08:28, Steven Evans wrote:

> Good evening....
>
> Sorry if this is a bit OT....but I'm thinking that others have tried  
> this.  I am working on online questionaires right now, and my client  
> wants some "sliders" in lieu of radio, text, or checkboxes.
>
> I have this working, and multiple on page.  but the problem I am  
> having is in showing a text result, rather than an integer result.  
> My solution is working, but it is making a brutal amount of DB calls  
> and I'm wondering if there is a better way to do it.   You will  
> notice the var: new_loop here because I use multiple sliders on one  
> page.....
>
> In theory, though, everytime the person moves the slider, it makes a  
> call to the db to translate the number to what I want the user to  
> see (like 1 = Strongly disagree, 2 = Moderately Disagree, etc).  So,  
> I'm trying to find a way to not have to call the DB everytime....I  
> really want to see an array when I load the question, but I can only  
> seem to set numbers instead of the corresponding phrases.
>
> Any ideas?
>
> Thanks!
>
> sqe
>
>
>
>         <div id="track[var:'new_loop']" style="width:200px; height:
> 9px;">
>        <div id="track[var:'new_loop']-left"></div><div  
> id="handle[var:'new_loop']" style="width:19px; height:20px;"><img  
> src="/images/slider-images-handle.png" alt="" style="float: left;" /
> ></div>
> </div>
> <p id="showresult[var:'new_loop']">&nbsp;</p>
>
>
>        [noprocess]
>            <script type="text/javascript" language="javascript">
>     // <![CDATA[
>    
>     // horizontal slider control
>     new Control.Slider('handle[/noprocess][var:'new_loop']',  
> 'track[var:'new_loop'][noprocess]', {
>     range: $R(1,7),
>     values: [1,2,3,4,5,6,7],
>     onSlide: function(v) {  var url='/findquesttype.lasso?order='  
> + v + '&questiontypeid=' + [/noprocess][field:'type_id'][noprocess];
>                            var divplacement='showresult'+[/
> noprocess][var:'new_loop'][noprocess];
>                            new Ajax.Updater(divplacement, url,  
> {evalScripts:true}); },
>     onChange: function(v) { $('showresult[/noprocess]
> [var:'new_loop'][noprocess]').innerHTML = 'changed: ' + v }
>     });
>
>     // ]]>
>     </script>
> [/noprocess]
>
> Steven Q. Evans
> Director of Technological Resources
> MSI Production Services
> http://www.msiprod.com
> (858)348-0629 • Mobile (858)344-3351 • (707)215-1032 Fax • [hidden email]
>
>
>
>
>
> --
> This list is a free service of LassoSoft: http://www.LassoSoft.com/
> Search the list archives: http://www.ListSearch.com/Lasso/Browse/
> Manage your subscription: http://www.ListSearch.com/Lasso/
>
>


--
This list is a free service of LassoSoft: http://www.LassoSoft.com/
Search the list archives: http://www.ListSearch.com/Lasso/Browse/
Manage your subscription: http://www.ListSearch.com/Lasso/

Reply | Threaded
Open this post in threaded view
|

Re: [OT] Scriptaculous Slider

Tim Taplin
In reply to this post by Steven Evans
a couple of thoughts.

Are the values different for each instance of the slider? Do they  
always have 7 positions? do they all use the same Verbage?  
(1=Strongly Disagree, 2=Moderately Disagree, etc)?

        If the value relationship of numbers to text are always the same,  
you could use the prototype $H hash function to create a hash of the  
potential values and reference that in your onSlide function instead  
of having to perform a database lookup.

        If each question may have different values related to the numbers on  
the slider, then in your query  or inline which looks up the  
questions, I would lookup the possible values and create an array of  
possible values which can then be used to build a javascript variable
( either an array manually associated with the slider values or the  
Hash method) .  Depending on your page structure, you may need to  
insert this value array into an array which can be looped thru in  
your javascript code block to dynamically create the appropriate vars.

Tim Taplin

On Nov 17, 2008, at 1:28 AM, Steven Evans wrote:

> Good evening....
>
> Sorry if this is a bit OT....but I'm thinking that others have  
> tried this.  I am working on online questionaires right now, and my  
> client wants some "sliders" in lieu of radio, text, or checkboxes.
>
> I have this working, and multiple on page.  but the problem I am  
> having is in showing a text result, rather than an integer result.  
> My solution is working, but it is making a brutal amount of DB  
> calls and I'm wondering if there is a better way to do it.   You  
> will notice the var: new_loop here because I use multiple sliders  
> on one page.....
>
> In theory, though, everytime the person moves the slider, it makes  
> a call to the db to translate the number to what I want the user to  
> see (like 1 = Strongly disagree, 2 = Moderately Disagree, etc).  
> So, I'm trying to find a way to not have to call the DB  
> everytime....I really want to see an array when I load the  
> question, but I can only seem to set numbers instead of the  
> corresponding phrases.
>
> Any ideas?
>
> Thanks!
>
> sqe
>
>
>
>          <div id="track[var:'new_loop']" style="width:200px; height:
> 9px;">
>         <div id="track[var:'new_loop']-left"></div><div id="handle
> [var:'new_loop']" style="width:19px; height:20px;"><img src="/
> images/slider-images-handle.png" alt="" style="float: left;" /></div>
> </div>
> <p id="showresult[var:'new_loop']">&nbsp;</p>
>
>
>         [noprocess]
>             <script type="text/javascript" language="javascript">
>     // <![CDATA[
>    
>     // horizontal slider control
>     new Control.Slider('handle[/noprocess][var:'new_loop']',  
> 'track[var:'new_loop'][noprocess]', {
>     range: $R(1,7),
>     values: [1,2,3,4,5,6,7],
>     onSlide: function(v) {  var url='/findquesttype.lasso?
> order=' + v + '&questiontypeid=' + [/noprocess][field:'type_id']
> [noprocess];
>                            var divplacement='showresult'+[/
> noprocess][var:'new_loop'][noprocess];
>                            new Ajax.Updater(divplacement, url,  
> {evalScripts:true}); },
>     onChange: function(v) { $('showresult[/noprocess]
> [var:'new_loop'][noprocess]').innerHTML = 'changed: ' + v }
>     });
>
>     // ]]>
>     </script>
> [/noprocess]
>
> Steven Q. Evans
> Director of Technological Resources
> MSI Production Services
> http://www.msiprod.com
> (858)348-0629 • Mobile (858)344-3351 • (707)215-1032 Fax •  
> [hidden email]
>
>
>
>
>
> --
> This list is a free service of LassoSoft: http://www.LassoSoft.com/
> Search the list archives: http://www.ListSearch.com/Lasso/Browse/
> Manage your subscription: http://www.ListSearch.com/Lasso/
>


--
This list is a free service of LassoSoft: http://www.LassoSoft.com/
Search the list archives: http://www.ListSearch.com/Lasso/Browse/
Manage your subscription: http://www.ListSearch.com/Lasso/

Reply | Threaded
Open this post in threaded view
|

Re: [OT] Scriptaculous Slider

Tim Taplin
In reply to this post by Steven Evans
Here is a possible rework of  your sample code. I've made up some  
names and added a few things to clarify what I think you are doing.  
This is untested but should be basically workable. Hope it gets you  
going in a less db intense direction.

<?lassoscript
        inline(-database='cust1_forms', -sql='select id, question_text from  
questions');
                local('question_array' = array);
                records;
                        local('thisrec' = array(field('id'), field('question_text'));
                        inline(-database='cust1_forms', -sql='select id, value from  
question_values where id_question = '+field('id'));
                                local('tmpvalues' = records_array);
                               
                        /inline;
                        #values_arr->insert(pair(#thisrec = #tmpvalues));
                /records;
        /inline
?>
<!-- questions and question values are stored in array of pairs with  
question id and text stored as an array in the first element of  each  
pair. possible values stored in array in second element of each pair -->

[iterate(#values_arr, local('question'))]
        [local('q_id' = #question->first->get(1)]
<div id="question[#q_id]" class="questions">
        [#question->first->get(2)]?<br>
        <div id="track[#q_id]" style="width:200px; height:9px;">
                <div id="track[#q_id]-left"></div><div id="handle[#q_id]"  
style="width:19px; height:20px;">
                        <img src="/images/slider-images-handle.png" alt="" style="float:  
left;" />
                </div>
        </div>
        <p id="showresult[#q_id]">&nbsp;</p>
</div>
[/iterate]

     <script type="text/javascript" language="javascript">
      var question_values = new HASH();
                [iterate(#values_arr, local('question'))]
                        [iterate(#question->second, local('values')]
                        question_values.set('[#values->get(1)]','[#values->get(2)]');
                        [/iterate]
                        var questionid='[#question->first->get(1)]';
        // <![CDATA[
               
                // horizontal slider control
                new Control.Slider('handle'+questionid, 'track'+questionid, {
                        range: $R(1,7),
                        [noprocess]values: [1,2,3,4,5,6,7][/noprocess],
                        onSlide: function(v) { $('showresult'+questionid).update
(question_values.get(v)); },
                        onChange: function(v) { $('showresult'+questionid).update
('changed: ' + v }
                });
               
        // ]]>
                [/iterate]
        </script>

On Nov 17, 2008, at 1:28 AM, Steven Evans wrote:

> Good evening....
>
> Sorry if this is a bit OT....but I'm thinking that others have  
> tried this.  I am working on online questionaires right now, and my  
> client wants some "sliders" in lieu of radio, text, or checkboxes.
>
> I have this working, and multiple on page.  but the problem I am  
> having is in showing a text result, rather than an integer result.  
> My solution is working, but it is making a brutal amount of DB  
> calls and I'm wondering if there is a better way to do it.   You  
> will notice the var: new_loop here because I use multiple sliders  
> on one page.....
>
> In theory, though, everytime the person moves the slider, it makes  
> a call to the db to translate the number to what I want the user to  
> see (like 1 = Strongly disagree, 2 = Moderately Disagree, etc).  
> So, I'm trying to find a way to not have to call the DB  
> everytime....I really want to see an array when I load the  
> question, but I can only seem to set numbers instead of the  
> corresponding phrases.
>
> Any ideas?
>
> Thanks!
>
> sqe
>
>
>
>          <div id="track[var:'new_loop']" style="width:200px; height:
> 9px;">
>         <div id="track[var:'new_loop']-left"></div><div id="handle
> [var:'new_loop']" style="width:19px; height:20px;"><img src="/
> images/slider-images-handle.png" alt="" style="float: left;" /></div>
> </div>
> <p id="showresult[var:'new_loop']">&nbsp;</p>
>
>
>         [noprocess]
>             <script type="text/javascript" language="javascript">
>     // <![CDATA[
>    
>     // horizontal slider control
>     new Control.Slider('handle[/noprocess][var:'new_loop']',  
> 'track[var:'new_loop'][noprocess]', {
>     range: $R(1,7),
>     values: [1,2,3,4,5,6,7],
>     onSlide: function(v) {  var url='/findquesttype.lasso?
> order=' + v + '&questiontypeid=' + [/noprocess][field:'type_id']
> [noprocess];
>                            var divplacement='showresult'+[/
> noprocess][var:'new_loop'][noprocess];
>                            new Ajax.Updater(divplacement, url,  
> {evalScripts:true}); },
>     onChange: function(v) { $('showresult[/noprocess]
> [var:'new_loop'][noprocess]').innerHTML = 'changed: ' + v }
>     });
>
>     // ]]>
>     </script>
> [/noprocess]
>
> Steven Q. Evans
> Director of Technological Resources
> MSI Production Services
> http://www.msiprod.com
> (858)348-0629 • Mobile (858)344-3351 • (707)215-1032 Fax •  
> [hidden email]
>
>
>
>
>
> --
> This list is a free service of LassoSoft: http://www.LassoSoft.com/
> Search the list archives: http://www.ListSearch.com/Lasso/Browse/
> Manage your subscription: http://www.ListSearch.com/Lasso/
>


--
This list is a free service of LassoSoft: http://www.LassoSoft.com/
Search the list archives: http://www.ListSearch.com/Lasso/Browse/
Manage your subscription: http://www.ListSearch.com/Lasso/

Reply | Threaded
Open this post in threaded view
|

Re: [OT] Scriptaculous Slider

decorior
You may have already seen this, but the bottom example shows limited  
values for the slider:

http://www.aldenta.com/examples/script.aculo.us/slider-standard.html


On Nov 17, 2008, at 4:30 AM, Tim Taplin wrote:

> Here is a possible rework of  your sample code. I've made up some  
> names and added a few things to clarify what I think you are doing.  
> This is untested but should be basically workable. Hope it gets you  
> going in a less db intense direction.
>
> <?lassoscript
> inline(-database='cust1_forms', -sql='select id, question_text from  
> questions');
> local('question_array' = array);
> records;
> local('thisrec' = array(field('id'), field('question_text'));
> inline(-database='cust1_forms', -sql='select id, value from  
> question_values where id_question = '+field('id'));
> local('tmpvalues' = records_array);
>
> /inline;
> #values_arr->insert(pair(#thisrec = #tmpvalues));
> /records;
> /inline
> ?>
> <!-- questions and question values are stored in array of pairs with  
> question id and text stored as an array in the first element of  
> each pair. possible values stored in array in second element of each  
> pair -->
>
> [iterate(#values_arr, local('question'))]
> [local('q_id' = #question->first->get(1)]
> <div id="question[#q_id]" class="questions">
> [#question->first->get(2)]?<br>
> <div id="track[#q_id]" style="width:200px; height:9px;">
> <div id="track[#q_id]-left"></div><div id="handle[#q_id]"  
> style="width:19px; height:20px;">
> <img src="/images/slider-images-handle.png" alt="" style="float:  
> left;" />
> </div>
> </div>
> <p id="showresult[#q_id]">&nbsp;</p>
> </div>
> [/iterate]
>
>    <script type="text/javascript" language="javascript">
>     var question_values = new HASH();
> [iterate(#values_arr, local('question'))]
> [iterate(#question->second, local('values')]
> question_values.set('[#values->get(1)]','[#values->get(2)]');
> [/iterate]
> var questionid='[#question->first->get(1)]';
> // <![CDATA[
>
> // horizontal slider control
> new Control.Slider('handle'+questionid, 'track'+questionid, {
> range: $R(1,7),
> [noprocess]values: [1,2,3,4,5,6,7][/noprocess],
> onSlide: function(v) { $
> ('showresult'+questionid).update(question_values.get(v)); },
> onChange: function(v) { $
> ('showresult'+questionid).update('changed: ' + v }
> });
>
> // ]]>
> [/iterate]
> </script>
>
> On Nov 17, 2008, at 1:28 AM, Steven Evans wrote:
>
>> Good evening....
>>
>> Sorry if this is a bit OT....but I'm thinking that others have  
>> tried this.  I am working on online questionaires right now, and my  
>> client wants some "sliders" in lieu of radio, text, or checkboxes.
>>
>> I have this working, and multiple on page.  but the problem I am  
>> having is in showing a text result, rather than an integer result.  
>> My solution is working, but it is making a brutal amount of DB  
>> calls and I'm wondering if there is a better way to do it.   You  
>> will notice the var: new_loop here because I use multiple sliders  
>> on one page.....
>>
>> In theory, though, everytime the person moves the slider, it makes  
>> a call to the db to translate the number to what I want the user to  
>> see (like 1 = Strongly disagree, 2 = Moderately Disagree, etc).  
>> So, I'm trying to find a way to not have to call the DB  
>> everytime....I really want to see an array when I load the  
>> question, but I can only seem to set numbers instead of the  
>> corresponding phrases.
>>
>> Any ideas?
>>
>> Thanks!
>>
>> sqe
>>
>>
>>
>>         <div id="track[var:'new_loop']" style="width:200px; height:
>> 9px;">
>>        <div id="track[var:'new_loop']-left"></div><div  
>> id="handle[var:'new_loop']" style="width:19px; height:20px;"><img  
>> src="/images/slider-images-handle.png" alt="" style="float: left;" /
>> ></div>
>> </div>
>> <p id="showresult[var:'new_loop']">&nbsp;</p>
>>
>>
>>        [noprocess]
>>            <script type="text/javascript" language="javascript">
>>     // <![CDATA[
>>    
>>     // horizontal slider control
>>     new Control.Slider('handle[/noprocess][var:'new_loop']',  
>> 'track[var:'new_loop'][noprocess]', {
>>     range: $R(1,7),
>>     values: [1,2,3,4,5,6,7],
>>     onSlide: function(v) {  var url='/findquesttype.lasso?
>> order=' + v + '&questiontypeid=' + [/noprocess][field:'type_id']
>> [noprocess];
>>                            var divplacement='showresult'+[/
>> noprocess][var:'new_loop'][noprocess];
>>                            new Ajax.Updater(divplacement, url,  
>> {evalScripts:true}); },
>>     onChange: function(v) { $('showresult[/noprocess]
>> [var:'new_loop'][noprocess]').innerHTML = 'changed: ' + v }
>>     });
>>
>>     // ]]>
>>     </script>
>> [/noprocess]
>>
>> Steven Q. Evans
>> Director of Technological Resources
>> MSI Production Services
>> http://www.msiprod.com
>> (858)348-0629 • Mobile (858)344-3351 • (707)215-1032 Fax • [hidden email]
>>
>>
>>
>>
>>
>> --
>> This list is a free service of LassoSoft: http://www.LassoSoft.com/
>> Search the list archives: http://www.ListSearch.com/Lasso/Browse/
>> Manage your subscription: http://www.ListSearch.com/Lasso/
>>
>
>
> --
> This list is a free service of LassoSoft: http://www.LassoSoft.com/
> Search the list archives: http://www.ListSearch.com/Lasso/Browse/
> Manage your subscription: http://www.ListSearch.com/Lasso/
>




--
This list is a free service of LassoSoft: http://www.LassoSoft.com/
Search the list archives: http://www.ListSearch.com/Lasso/Browse/
Manage your subscription: http://www.ListSearch.com/Lasso/

Reply | Threaded
Open this post in threaded view
|

Re: [OT] Scriptaculous Slider

Steven Evans
In reply to this post by Tim Taplin
Tim (and all),

Thanks for your responses on this....

I'm trying to work this out now, and have taking it back to simple  
form....essentially just assuming that I have one question on a page,  
but want to translate the number to text.

That being said, i think Tim that your solution is helping me....I  
just can't figure out what the the HASH is.  I keep getting a not  
defined error for "Hash".  And, I can't seem to create an array of  
pairs for the the "onSlide" to call.

Can you shed any more light on what you were trying to do there?

Thanks!

sqe


On Nov 17, 2008, at 3:30 AM, Tim Taplin wrote:

> Here is a possible rework of  your sample code. I've made up some  
> names and added a few things to clarify what I think you are doing.  
> This is untested but should be basically workable. Hope it gets you  
> going in a less db intense direction.
>
> <?lassoscript
> inline(-database='cust1_forms', -sql='select id, question_text from  
> questions');
> local('question_array' = array);
> records;
> local('thisrec' = array(field('id'), field('question_text'));
> inline(-database='cust1_forms', -sql='select id, value from  
> question_values where id_question = '+field('id'));
> local('tmpvalues' = records_array);
>
> /inline;
> #values_arr->insert(pair(#thisrec = #tmpvalues));
> /records;
> /inline
> ?>
> <!-- questions and question values are stored in array of pairs with  
> question id and text stored as an array in the first element of  
> each pair. possible values stored in array in second element of each  
> pair -->
>
> [iterate(#values_arr, local('question'))]
> [local('q_id' = #question->first->get(1)]
> <div id="question[#q_id]" class="questions">
> [#question->first->get(2)]?<br>
> <div id="track[#q_id]" style="width:200px; height:9px;">
> <div id="track[#q_id]-left"></div><div id="handle[#q_id]"  
> style="width:19px; height:20px;">
> <img src="/images/slider-images-handle.png" alt="" style="float:  
> left;" />
> </div>
> </div>
> <p id="showresult[#q_id]">&nbsp;</p>
> </div>
> [/iterate]
>
>    <script type="text/javascript" language="javascript">
>     var question_values = new HASH();
> [iterate(#values_arr, local('question'))]
> [iterate(#question->second, local('values')]
> question_values.set('[#values->get(1)]','[#values->get(2)]');
> [/iterate]
> var questionid='[#question->first->get(1)]';
> // <![CDATA[
>
> // horizontal slider control
> new Control.Slider('handle'+questionid, 'track'+questionid, {
> range: $R(1,7),
> [noprocess]values: [1,2,3,4,5,6,7][/noprocess],
> onSlide: function(v) { $
> ('showresult'+questionid).update(question_values.get(v)); },
> onChange: function(v) { $
> ('showresult'+questionid).update('changed: ' + v }
> });
>
> // ]]>
> [/iterate]
> </script>
>
> On Nov 17, 2008, at 1:28 AM, Steven Evans wrote:
>
>> Good evening....
>>
>> Sorry if this is a bit OT....but I'm thinking that others have  
>> tried this.  I am working on online questionaires right now, and my  
>> client wants some "sliders" in lieu of radio, text, or checkboxes.
>>
>> I have this working, and multiple on page.  but the problem I am  
>> having is in showing a text result, rather than an integer result.  
>> My solution is working, but it is making a brutal amount of DB  
>> calls and I'm wondering if there is a better way to do it.   You  
>> will notice the var: new_loop here because I use multiple sliders  
>> on one page.....
>>
>> In theory, though, everytime the person moves the slider, it makes  
>> a call to the db to translate the number to what I want the user to  
>> see (like 1 = Strongly disagree, 2 = Moderately Disagree, etc).  
>> So, I'm trying to find a way to not have to call the DB  
>> everytime....I really want to see an array when I load the  
>> question, but I can only seem to set numbers instead of the  
>> corresponding phrases.
>>
>> Any ideas?
>>
>> Thanks!
>>
>> sqe
>>
>>
>>
>>         <div id="track[var:'new_loop']" style="width:200px; height:
>> 9px;">
>>        <div id="track[var:'new_loop']-left"></div><div  
>> id="handle[var:'new_loop']" style="width:19px; height:20px;"><img  
>> src="/images/slider-images-handle.png" alt="" style="float: left;" /
>> ></div>
>> </div>
>> <p id="showresult[var:'new_loop']">&nbsp;</p>
>>
>>
>>        [noprocess]
>>            <script type="text/javascript" language="javascript">
>>     // <![CDATA[
>>    
>>     // horizontal slider control
>>     new Control.Slider('handle[/noprocess][var:'new_loop']',  
>> 'track[var:'new_loop'][noprocess]', {
>>     range: $R(1,7),
>>     values: [1,2,3,4,5,6,7],
>>     onSlide: function(v) {  var url='/findquesttype.lasso?
>> order=' + v + '&questiontypeid=' + [/noprocess][field:'type_id']
>> [noprocess];
>>                            var divplacement='showresult'+[/
>> noprocess][var:'new_loop'][noprocess];
>>                            new Ajax.Updater(divplacement, url,  
>> {evalScripts:true}); },
>>     onChange: function(v) { $('showresult[/noprocess]
>> [var:'new_loop'][noprocess]').innerHTML = 'changed: ' + v }
>>     });
>>
>>     // ]]>
>>     </script>
>> [/noprocess]
>>
>> Steven Q. Evans
>> Director of Technological Resources
>> MSI Production Services
>> http://www.msiprod.com
>> (858)348-0629 • Mobile (858)344-3351 • (707)215-1032 Fax • [hidden email]
>>
>>
>>
>>
>>
>> --
>> This list is a free service of LassoSoft: http://www.LassoSoft.com/
>> Search the list archives: http://www.ListSearch.com/Lasso/Browse/
>> Manage your subscription: http://www.ListSearch.com/Lasso/
>>
>
>
> --
> This list is a free service of LassoSoft: http://www.LassoSoft.com/
> Search the list archives: http://www.ListSearch.com/Lasso/Browse/
> Manage your subscription: http://www.ListSearch.com/Lasso/
>

Steven Q. Evans
Director of Technological Resources
MSI Production Services
http://www.msiprod.com
(858)348-0629 • Mobile (858)344-3351 • (707)215-1032 Fax • [hidden email]





--
This list is a free service of LassoSoft: http://www.LassoSoft.com/
Search the list archives: http://www.ListSearch.com/Lasso/Browse/
Manage your subscription: http://www.ListSearch.com/Lasso/

Reply | Threaded
Open this post in threaded view
|

Re: [OT] Scriptaculous Slider

Tim Taplin
looks like my bad. try Hash instead of HASH.  I hate how picky  
javascript is about some things and careless about others.

assuming that works, the javascript variable question_values is the  
hash (an array of pairs) from which you can retrieve the text values  
by using the get function and the numeric key from the slider.  eg.  
question_values.get(v);

I've put in a couple of sample alerts for debugging usage below.  
Sometimes, putting in breakpoints using the firebug plugin on firefox  
can be useful but I usually get more useful info from alerts.

let me know if you are still having problems with Hash. I'll dig up  
some recent code to double check further if I need to but pretty sure  
this should work.

On Nov 17, 2008, at 10:49 AM, Steven Evans wrote:

> Tim (and all),
>
> Thanks for your responses on this....
>
> I'm trying to work this out now, and have taking it back to simple  
> form....essentially just assuming that I have one question on a  
> page, but want to translate the number to text.
>
> That being said, i think Tim that your solution is helping me....I  
> just can't figure out what the the HASH is.  I keep getting a not  
> defined error for "Hash".  And, I can't seem to create an array of  
> pairs for the the "onSlide" to call.
>
> Can you shed any more light on what you were trying to do there?
>
> Thanks!
>
> sqe
>>

You may want to add some alerts for debugging purposes.

>>    <script type="text/javascript" language="javascript">
>>     var question_values = new HASH();
>> [iterate(#values_arr, local('question'))]
>> [iterate(#question->second, local('values')]
>> question_values.set('[#values->get(1)]','[#values->get(2)]');
>> [/iterate]
>> var questionid='[#question->first->get(1)]';
>> // <![CDATA[
>>
>> // horizontal slider control
>> new Control.Slider('handle'+questionid, 'track'+questionid, {
>> range: $R(1,7),
>> [noprocess]values: [1,2,3,4,5,6,7][/noprocess],
>> onSlide: function(v) {
                                        alert('onSlide Value of v: '+v);
>> $('showresult'+questionid).update(question_values.get(v));
                                        alert('text retrieved from hash: '+question_values.get(v));

>> },
>> onChange: function(v) { $('showresult'+questionid).update
>> ('changed: ' + v }
>> });
>>
>> // ]]>
>> [/iterate]
>> </script>
>>
>> On Nov 17, 2008, at 1:28 AM, Steven Evans wrote:
>>
>>> Good evening....
>>>
>>> Sorry if this is a bit OT....but I'm thinking that others have  
>>> tried this.  I am working on online questionaires right now, and  
>>> my client wants some "sliders" in lieu of radio, text, or  
>>> checkboxes.
>>>
>>> I have this working, and multiple on page.  but the problem I am  
>>> having is in showing a text result, rather than an integer  
>>> result.  My solution is working, but it is making a brutal amount  
>>> of DB calls and I'm wondering if there is a better way to do  
>>> it.   You will notice the var: new_loop here because I use  
>>> multiple sliders on one page.....
>>>
>>> In theory, though, everytime the person moves the slider, it  
>>> makes a call to the db to translate the number to what I want the  
>>> user to see (like 1 = Strongly disagree, 2 = Moderately Disagree,  
>>> etc).  So, I'm trying to find a way to not have to call the DB  
>>> everytime....I really want to see an array when I load the  
>>> question, but I can only seem to set numbers instead of the  
>>> corresponding phrases.
>>>
>>> Any ideas?
>>>
>>> Thanks!
>>>
>>> sqe
>>>
>>>
>>>
>>>         <div id="track[var:'new_loop']" style="width:200px;  
>>> height:9px;">
>>>        <div id="track[var:'new_loop']-left"></div><div id="handle
>>> [var:'new_loop']" style="width:19px; height:20px;"><img src="/
>>> images/slider-images-handle.png" alt="" style="float: left;" /></
>>> div>
>>> </div>
>>> <p id="showresult[var:'new_loop']">&nbsp;</p>
>>>
>>>
>>>        [noprocess]
>>>            <script type="text/javascript" language="javascript">
>>>     // <![CDATA[
>>>    
>>>     // horizontal slider control
>>>     new Control.Slider('handle[/noprocess][var:'new_loop']',  
>>> 'track[var:'new_loop'][noprocess]', {
>>>     range: $R(1,7),
>>>     values: [1,2,3,4,5,6,7],
>>>     onSlide: function(v) {  var url='/findquesttype.lasso?
>>> order=' + v + '&questiontypeid=' + [/noprocess][field:'type_id']
>>> [noprocess];
>>>                            var divplacement='showresult'+[/
>>> noprocess][var:'new_loop'][noprocess];
>>>                            new Ajax.Updater(divplacement,  
>>> url, {evalScripts:true}); },
>>>     onChange: function(v) { $('showresult[/noprocess]
>>> [var:'new_loop'][noprocess]').innerHTML = 'changed: ' + v }
>>>     });
>>>
>>>     // ]]>
>>>     </script>
>>> [/noprocess]
>>>
>>> Steven Q. Evans
>>> Director of Technological Resources
>>> MSI Production Services
>>> http://www.msiprod.com
>>> (858)348-0629 • Mobile (858)344-3351 • (707)215-1032 Fax •  
>>> [hidden email]
>>>
>>>
>>>
>>>
>>>
>>> --
>>> This list is a free service of LassoSoft: http://www.LassoSoft.com/
>>> Search the list archives: http://www.ListSearch.com/Lasso/Browse/
>>> Manage your subscription: http://www.ListSearch.com/Lasso/
>>>
>>
>>
>> --
>> This list is a free service of LassoSoft: http://www.LassoSoft.com/
>> Search the list archives: http://www.ListSearch.com/Lasso/Browse/
>> Manage your subscription: http://www.ListSearch.com/Lasso/
>>
>
> Steven Q. Evans
> Director of Technological Resources
> MSI Production Services
> http://www.msiprod.com
> (858)348-0629 • Mobile (858)344-3351 • (707)215-1032 Fax •  
> [hidden email]
>
>
>
>
>
> --
> This list is a free service of LassoSoft: http://www.LassoSoft.com/
> Search the list archives: http://www.ListSearch.com/Lasso/Browse/
> Manage your subscription: http://www.ListSearch.com/Lasso/
>


--
This list is a free service of LassoSoft: http://www.LassoSoft.com/
Search the list archives: http://www.ListSearch.com/Lasso/Browse/
Manage your subscription: http://www.ListSearch.com/Lasso/

Reply | Threaded
Open this post in threaded view
|

Re: [OT] Scriptaculous Slider

Steve Upton
At 12:44 PM -0700 11/17/08, Tim Taplin wrote:
>looks like my bad. try Hash instead of HASH.  I hate how picky javascript is about some things and careless about others.

yeah case-sensitivity should be outlawed. It bites me regularly and always seems to hurt.

You can also just use a Javascript array to store the values.

Javascript arrays are automatically associative arrays (like Lasso maps), which caused me some confusion before I figured it out.

So you can do:

        var a = new Array;

        a[0] = 'thing';

but you can also do:

        a['somekey'] = 'thing';

but there are no guarantees that I didn't make a case-sensitivity mistaKe in that code...

hope this helps...

Regards,

Steve


--


--
This list is a free service of LassoSoft: http://www.LassoSoft.com/
Search the list archives: http://www.ListSearch.com/Lasso/Browse/
Manage your subscription: http://www.ListSearch.com/Lasso/

Reply | Threaded
Open this post in threaded view
|

Re: [OT] Scriptaculous Slider (also question about LASSO arrays)

Steven Evans
Yeah....the case thing is a drag, but I'm getting there!  This is one  
of those "wouldn't it be nice" things the client wanted that has taken  
12 hours longer than I wanted!  Funny how that works!

Ok....last thing that is biting me that should be a no brainer, but I  
can't dig out.....

In Lasso....I'm trying to use dynamic array names:

[var:'idarrayname' = 'choice_array' + (Var:'typeid')]
[var: $idarrayname = (array)]

inline....

  [$($idarrayname)->(Insert: (field:'type_choice'))]

/inline

But i keep getting and error on the insert......I've tried the  
iterations that I think will work:

         [$(var:'idarrayname')->(Insert: (field:'type_choice'))]

Essentially, I am creating an array of different questions and want to  
store than individually:

choice_array37
choice_array38

etc

Thanks.

sqe





On Nov 17, 2008, at 12:33 PM, Steve Upton wrote:

> At 12:44 PM -0700 11/17/08, Tim Taplin wrote:
>> looks like my bad. try Hash instead of HASH.  I hate how picky  
>> javascript is about some things and careless about others.
>
> yeah case-sensitivity should be outlawed. It bites me regularly and  
> always seems to hurt.
>
> You can also just use a Javascript array to store the values.
>
> Javascript arrays are automatically associative arrays (like Lasso  
> maps), which caused me some confusion before I figured it out.
>
> So you can do:
>
> var a = new Array;
>
> a[0] = 'thing';
>
> but you can also do:
>
> a['somekey'] = 'thing';
>
> but there are no guarantees that I didn't make a case-sensitivity  
> mistaKe in that code...
>
> hope this helps...
>
> Regards,
>
> Steve
>
>
> --
>
>
> --
> This list is a free service of LassoSoft: http://www.LassoSoft.com/
> Search the list archives: http://www.ListSearch.com/Lasso/Browse/
> Manage your subscription: http://www.ListSearch.com/Lasso/
>

Steven Q. Evans
Director of Technological Resources
MSI Production Services
http://www.msiprod.com
(858)348-0629 • Mobile (858)344-3351 • (707)215-1032 Fax • [hidden email]





--
This list is a free service of LassoSoft: http://www.LassoSoft.com/
Search the list archives: http://www.ListSearch.com/Lasso/Browse/
Manage your subscription: http://www.ListSearch.com/Lasso/

Reply | Threaded
Open this post in threaded view
|

Re: [OT] Scriptaculous Slider (also question about LASSO arrays)

Bil Corry-3
Steven Evans wrote on 11/17/2008 2:41 PM:
> In Lasso....I'm trying to use dynamic array names:
>
> [var:'idarrayname' = 'choice_array' + (Var:'typeid')]
> [var: $idarrayname = (array)]

Don't use dynamically-named vars, use a map instead.


>      [$(var:'idarrayname')->(Insert: (field:'type_choice'))]

The syntax (if you're attached to using dynamically-named vars) is as follows:
        [
        var($idarrayname) = array;
        var($idarrayname)->insert(field('type_choice'));
        ]



- Bil


--
This list is a free service of LassoSoft: http://www.LassoSoft.com/
Search the list archives: http://www.ListSearch.com/Lasso/Browse/
Manage your subscription: http://www.ListSearch.com/Lasso/