Thanks man,
I'll give it a whirl ... Thanks for all your time and energy.

d



On Oct 23, 4:19 am, mkmanning <michaell...@gmail.com> wrote:
> Something like this (untested):
>
> var arrValues = ['c1','c2','c3','c3'],
> cnameIndex = $.inArray(this.className,arrValues)+1;
> this.className = cnameIndex===arrValues.length?0: cnameIndex ];
>
> if you can live with only one classname, otherwise you'll have to add
> code to remove the old classname from arrValues and then add the new
> class with addClass.
>
> Basically all this is doing is getting the current value of a given
> property, such as background-color, finding its index in the arrValues
> array, incrementing that by one and then setting the new value to the
> element in the array with the incremented index. If the index is at
> the end of the array, it resets to 0.
>
> On Oct 22, 4:39 am, The Danny Bos <danny...@gmail.com> wrote:
>
>
>
> > Thanks so much man,
> > That'll work well ... One more thing, how would I change it to point
> > to classes instead of direct colours?
>
> > var arrValues = ['c1','c2','c3','c3'],
>
> > Thanks again,
>
> > On Oct 22, 6:27 pm, mkmanning <michaell...@gmail.com> wrote:
>
> > > Yeah, the snippet I wrote updates the color; you can add an ajax call
> > > to update your db as well, if the value your updating in the db is the
> > > color, or else the value is in an array that's indexed the same.
>
> > > On Oct 22, 12:10 am, The Danny Bos <danny...@gmail.com> wrote:
>
> > > > For each click of the DIV I'm hoping to change the BackgroundColor,
> > > > make some updates in the Database (depending on which array selection
> > > > it's on) and that's about it.
>
> > > > So, the first click of the DIV = "Change BG to 'green', update DB
> > > > field to 'XXX'"
> > > > the second click of the DIV = "Change the BG to 'aqua', update DB
> > > > field to 'YYY'"
> > > > the third click ... etc
>
> > > > Know what I mean?
>
> > > > On Oct 22, 6:04 pm, mkmanning <michaell...@gmail.com> wrote:
>
> > > > > Well, if you just want to loop through the array to change the
> > > > > background color, you don't really need toggle then. Try this:
>
> > > > >  $("#item_list > li > div > a").click(function(){
> > > > >   var arrValues = ['rgb(9, 128, 0)','rgb(0, 255, 255)','rgb(0, 0,
> > > > > 255)','rgb(128, 0, 128)'],
> > > > >   bgcolor = $.inArray($(this).css('background-color'),arrValues)+1;
> > > > >   $(this).css('background-color',arrValues[bgcolor===arrValues.length?
> > > > > 0:bgcolor]);
>
> > > > > });
>
> > > > > disclaimer: just wrote it inside Firebug's console, so haven't tested
> > > > > it outside that...
>
> > > > > On Oct 21, 10:14 pm, The Danny Bos <danny...@gmail.com> wrote:
>
> > > > > > Thanks, had a good read, figured it out in part.
> > > > > > Now I'm stuck trying to introduce an array to do my bidding ...
> > > > > > Example below.
>
> > > > > > The array is an example of how I want to loop through to use those
> > > > > > values.
> > > > > > Underneath is the perfect code for clicking an Anchor and changing 
> > > > > > its
> > > > > > BGcolour differently each time.
>
> > > > > > Any ideas?
>
> > > > > > $(document).ready(
> > > > > >         function(){
> > > > > >                 var arrValues = ['green','aqua','blue','purple'];
>
> > > > > >                 $("#item_list > li > div > a").toggle(
> > > > > >                 function(){
> > > > > >                         $(this).css('background-color', 'green');
> > > > > >                 }, function() {
> > > > > >                         $(this).css('background-color', 'aqua');
> > > > > >                 }, function() {
> > > > > >                         $(this).css('background-color', 'blue');
> > > > > >                 }, function() {
> > > > > >                         $(this).css('background-color', 'purple');
> > > > > >                 });
>
> > > > > > });
>
> > > > > > On Oct 22, 3:46 am, mkmanning <michaell...@gmail.com> wrote:
>
> > > > > > > .toggle() allows you to rotate through multiple functions, you 
> > > > > > > might
> > > > > > > want to check it out in the 
> > > > > > > docs:http://docs.jquery.com/Events/toggle#fnfn2fn3.2Cfn4.2C...
>
> > > > > > > On Oct 21, 2:58 am, The Danny Bos <danny...@gmail.com> wrote:
>
> > > > > > > > I've got one for ya, JQuery and Ajax.
>
> > > > > > > > I want to have a button image, let's stay it's inactive state 
> > > > > > > > it's a
> > > > > > > > grey circle, when someone clicks it once, it'd change to a blue 
> > > > > > > > circle
> > > > > > > > (update associated DB field to "blue"), click it again and it 
> > > > > > > > becomes
> > > > > > > > a red circle (update the DB field to "red") and so on. So users 
> > > > > > > > keep
> > > > > > > > clicking until they get the right color, then move on to the 
> > > > > > > > next
> > > > > > > > one.
>
> > > > > > > > I've seen something similar in Google where you can star emails 
> > > > > > > > with
> > > > > > > > different stars.
>
> > > > > > > > Any idea how you'd do this?
> > > > > > > > It's got me stumped.

Reply via email to