[Proto-Scripty] Re: Ajax.InPlaceEditor dynamically geneate item id?

2008-12-22 Thread Matt Andrews

If you choose to do it this way, I'd advise using a timestamp rather
than (or in conjunction with) the random string generator, just to
ensure it's definitely unique. Entropy's a bitch...

On Dec 22, 9:16 am, Calvin Lai cal...@gmail.com wrote:
 Maybe you could write a random generator script that generates and stores a
 set of random letters and numbers, store it in a global array, and keep
 checking against that array every time you load a record from the database.
 Just make sure you insert the original record id into the inplaceeditor
 script as a parameter so it reaches the server-side file that you're going
 to use.

 --
 Calvin Lai
 Business Developmenthttp://dealspl.us

 On Mon, Dec 22, 2008 at 1:07 AM, Matt Andrews mattpointbl...@gmail.comwrote:



  You could just make your code into a function and pass the same php
  variable as the parameter:

  function newInPlaceEditor(itemID)
  {
   new Ajax.InPlaceEditor('title_'+itemID, '/demoajaxreturn.html', {rows:
  15,cols:40});
  }

  then your code:

  div id='title_?php echo '$id'?'a href=javascript://
  onclick='newInPlaceEditor(?php echo '$id'; ?'edit me/a/div

  (not tested)

  Matt

  On Dec 20, 10:41 pm, Audg abe...@ccc.edu wrote:
   Hi,

   I was wondering if anyone could lend a hand with the fabulous
   Ajax.InPlaceEditor script!

   My question is this: Is there a way to generate an ID on the fly that
   would make the id unique?

   Because I have a one-to-many situation with my database, there are
   times when I'm displaying multiple records, which would result in
   duplicate item ID's and confuse the script.

   For example, One Author could have many book titles...but I don't know
   how many books the author has written until I query the databaseso
   I would need to create the id's on the fly.

   I can make the div dynamic with php div id='title_?php echo
  '$id'?'edit me/div

   but is there a way to pass this same id to the new Ajax.InPlaceEditor
   to make it match?

   script type=text/javascript
    new Ajax.InPlaceEditor('editme_THIS_WOULD_BE_A_UNIQUE_RECORD_ID', '/
   demoajaxreturn.html', {rows:15,cols:40});
   /script

   Thanks for any help you can provide!


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
Prototype  script.aculo.us group.
To post to this group, send email to prototype-scriptaculous@googlegroups.com
To unsubscribe from this group, send email to 
prototype-scriptaculous+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/prototype-scriptaculous?hl=en
-~--~~~~--~~--~--~---



[Proto-Scripty] Sortable list - dynamic numbering?

2008-12-17 Thread Matt Andrews

Hi everyone,

I've made a fairly basic Sortable - it's two lists and you can drag
elements from one list to the (initially blank) second. My issue is
that I want the second list to auto number itself as you add to it,
eg, if you drag an element to the top of it, it's prefixed with a #1,
or if it's at the bottom, it becomes #2, etc. The idea here is that
I'm allowing users to assemble a top 25 list out of a selection of
hundreds of items. Any tips on doing this?

Thanks
Matt
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
Prototype  script.aculo.us group.
To post to this group, send email to prototype-scriptaculous@googlegroups.com
To unsubscribe from this group, send email to 
prototype-scriptaculous+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/prototype-scriptaculous?hl=en
-~--~~~~--~~--~--~---



[Proto-Scripty] Re: testing whether all elements in a div have a certain class

2008-11-10 Thread Matt Andrews

That's broadly right, but my problem is string concatenation. I'm
passing the div name to search for those spans in using a function,
so when I try to do:

var spanName = span_+levelID;

I just get a value of 'span_+levelID' for $spanName.

Matt

On Nov 7, 4:05 pm, Alex Mcauley [EMAIL PROTECTED]
wrote:
 okay i am trying to get this correct ..

 You want to see if a certain amount of spans in an element have a class name
 of 'complete' and if so do something else

 firstly you can easily count the amount with $$

 var $complete=$$('.complete').length

 then you want to do something if they are more than or equal to 3

 if(($complete)  ($complete=3) {

 do_something();

 }

 is this correct so far ..

 Sorry i am having trouble deciphering what you want to achieve

 Alex

 - Original Message -
 From: Matt Andrews [EMAIL PROTECTED]
 To: Prototype  script.aculo.us prototype-scriptaculous@googlegroups.com
 Sent: Friday, November 07, 2008 3:41 PM
 Subject: [Proto-Scripty] Re: testing whether all elements in a div have a

 certain class

 Can anyone help? I'm really close to solving this, I just need someone
 with a better grasp of Javascript to prod me in the right direction...

 On Nov 3, 9:51 am, Matt [EMAIL PROTECTED] wrote:
  On Nov 1, 4:38 pm, Jarkko Laine [EMAIL PROTECTED] wrote:

   1) your alerting with a string bar there.
   2) $$ returns an array of elements. If you want a single item, why not
   give the span a unique id and call it with $? If you need to use the
   double-dollar selector, you need to get the first element of the array
   to get the actual element: $$('#container_'+boxID+' span')[0]; One
   option that gives you the span element (with the html syntax you
   posted before) is this: $('container_' + boxID).down('span').

a href=# onclick=foo(24);click here/a

// returns $$('#container_24 span');

   You mean the function above alerts that string? Frankly, I don't
   believe you :-)

   The parameter that $ and $$ take is just a normal string. There's
   nothing magical about it. So if you can do string + someVar, and the
   result is a string, you can give it as a parameter to those functions.

   //jarkko

  I tried out those methods (the [0] ending and the .down function),
  neither worked. I'm still struggling to get my head around this - I
  can only pass the ID of the element through a function, so it's always
  going to be a variable, I can't know it in advance. Here's some actual
  code (the above stuff was a simplified (and badly-written...)
  function, not the actual one):

  //contained within my function:

  var spanName = span_+levelID; //levelID is passed in the function
  var spanArray = document.getElementsByClassName(name); // gets all
  the elements I want to test
  var completeArray = spanArray.getElementsByClassName('complete'); //
  should get all elements within the above array with a class of
  'complete'

  // if the number of spans is the same as the number of spans with
  'complete' class:
  if(spanArray.size() == completeArray.size()) {
  $('level2_click_1').removeClassName('incomplete');
  $('level2_click_1').addClassName('complete');
  $('level2_click_1').update(ON);
  } else {
  $('level2_click_1').removeClassName('complete');
  $('level2_click_1').addClassName('incomplete');
  $('level2_click_1').update(OFF);
  }

  HTML:

  span class=span_1 incomplete id=level3_click_1
  a href=javascript:// onclick=changeState('level3', '1',
  'on')OFF/a
  /span

  span class=span_2 incomplete id=level3_click_2
  a href=javascript:// onclick=changeState('level3', '2',
  'on')OFF/a
  /span

  span class=span_3 incomplete id=level3_click_3
  a href=javascript:// onclick=changeState('level3', '3',
  'on')OFF/a
  /span

  

  Basically, when all three of those spans have class name
  'complete' (eg, are turned on) I want a different span somewhere else
  (the 'level2_click_1' span, which I will need to turn into a variable
  rather than a hardcoded reference) needs to switch to 'complete' too.

  Does this make any more sense now?

  Matt


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
Prototype  script.aculo.us group.
To post to this group, send email to prototype-scriptaculous@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/prototype-scriptaculous?hl=en
-~--~~~~--~~--~--~---



[Proto-Scripty] Re: testing whether all elements in a div have a certain class

2008-11-07 Thread Matt Andrews

Can anyone help? I'm really close to solving this, I just need someone
with a better grasp of Javascript to prod me in the right direction...

On Nov 3, 9:51 am, Matt [EMAIL PROTECTED] wrote:
 On Nov 1, 4:38 pm, Jarkko Laine [EMAIL PROTECTED] wrote:



  1) your alerting with a string bar there.
  2) $$ returns an array of elements. If you want a single item, why not  
  give the span a unique id and call it with $? If you need to use the  
  double-dollar selector, you need to get the first element of the array  
  to get the actual element: $$('#container_'+boxID+' span')[0]; One  
  option that gives you the span element (with the html syntax you  
  posted before) is this: $('container_' + boxID).down('span').

   a href=# onclick=foo(24);click here/a

   // returns $$('#container_24 span');

  You mean the function above alerts that string? Frankly, I don't  
  believe you :-)

  The parameter that $ and $$ take is just a normal string. There's  
  nothing magical about it. So if you can do string + someVar, and the  
  result is a string, you can give it as a parameter to those functions.

  //jarkko

 I tried out those methods (the [0] ending and the .down function),
 neither worked. I'm still struggling to get my head around this - I
 can only pass the ID of the element through a function, so it's always
 going to be a variable, I can't know it in advance. Here's some actual
 code (the above stuff was a simplified (and badly-written...)
 function, not the actual one):

 //contained within my function:

         var spanName = span_+levelID; //levelID is passed in the function
         var spanArray = document.getElementsByClassName(name); // gets all
 the elements I want to test
         var completeArray = spanArray.getElementsByClassName('complete'); //
 should get all elements within the above array with a class of
 'complete'

         // if the number of spans is the same as the number of spans with
 'complete' class:
         if(spanArray.size() == completeArray.size()) {
                 $('level2_click_1').removeClassName('incomplete');
                 $('level2_click_1').addClassName('complete');
                 $('level2_click_1').update(ON);
         } else {
                 $('level2_click_1').removeClassName('complete');
                 $('level2_click_1').addClassName('incomplete');
                 $('level2_click_1').update(OFF);
         }

 HTML:

 span class=span_1 incomplete id=level3_click_1
   a href=javascript:// onclick=changeState('level3', '1',
 'on')OFF/a
 /span

 span class=span_2 incomplete id=level3_click_2
   a href=javascript:// onclick=changeState('level3', '2',
 'on')OFF/a
 /span

 span class=span_3 incomplete id=level3_click_3
   a href=javascript:// onclick=changeState('level3', '3',
 'on')OFF/a
 /span

 

 Basically, when all three of those spans have class name
 'complete' (eg, are turned on) I want a different span somewhere else
 (the 'level2_click_1' span, which I will need to turn into a variable
 rather than a hardcoded reference) needs to switch to 'complete' too.

 Does this make any more sense now?

 Matt
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
Prototype  script.aculo.us group.
To post to this group, send email to prototype-scriptaculous@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/prototype-scriptaculous?hl=en
-~--~~~~--~~--~--~---