Page 1 of 1

javascript code prompts

Posted: Mon Apr 19, 2004 1:48 pm
by m3rajk
i decided to try to add code prompts to the forums to make it easier for ppl to add my version of bb code. the problem is that three cases in the switch aren't working
to see what i have in action, go here: http://24.91.157.113/findyourdesire/ztest.html
the three that aren't working are table, ordered list and unordered list.

issues:
table: not giving cell prompts or making rows/columns
ordered list: not doing anything after getting prompt info
unordered list: same as ordered

Code: Select all

case 'ol':  // ordered list
    add1=prompt('How many items in the list?')*1;
    if(add1>0){  // we're going to have items
      build=build+'їol]';
      for(i=0;i<add1;i++)&#123; // for each item to add
	add2=prompt('Enter item',''); // get the item
        build=build+'&#1111;item]'+add2+'&#1111;/item]'; // add it
      &#125;
      build=build+'&#1111;/ol]';  // finish the list
    &#125;
    break;

  case 'table': // adds a table
    add1=prompt('How many rows would you like?',''); // get # of rows
    if(add1>0)&#123; // there's some rows
      add2=prompt('How many columns would you like?',''); // get # of cols
      if(add2>0)&#123; // we'll make a table
        build='&#1111;table]';
	for(i=0;i>add1;i++)&#123; // for each row..
          build=build+'&#1111;row]';
	  for(j=0;j<add2;j++)&#123; // for each cell, get the data and add it
	    prmpt='Enter cell data for row '+add1+' column '+add2
	    add3=prompt(prmpt,''); // get the item
            build=build+'&#1111;cell]'+add3+'&#1111;/cell]';
	  &#125;
          build=build+'&#1111;/row]'; // make the row
	&#125;
        build=build+'&#1111;/table]'; // finish the table
      &#125;
    &#125; 
    break;

  case 'ul':  // unordered list
    add1=prompt('How many items in the list?');
    if(add1>0)&#123; // we're going to have items
      build=build+'&#1111;ul]';
      for(i=0;i<add1;i++)&#123; // for each item to add
	add2=prompt('Enter item',''); // get the item
        build=build+'&#1111;item]'+add2+'&#1111;/item]'; // add it
      &#125;
      build=build+'&#1111;/ul]';  // finish the list
    &#125; 
    break;
i thought the issue might have something to do with using a number a as a string and so i used *1 to cast it as a number, but that changes nothing.

Posted: Mon Apr 19, 2004 1:59 pm
by magicrobotmonkey
on the table part theres this:

for(i=0;i>add1;i++)

which should be

for(i=0;i<add1;i++)

and the list looked like it was working to me?

Posted: Mon Apr 19, 2004 4:36 pm
by m3rajk
the list failed to actually add anything. let me check the table after i fix that and get back to you

Posted: Mon Apr 19, 2004 5:00 pm
by m3rajk
table is now working like a charm

Posted: Mon Apr 19, 2004 5:03 pm
by m3rajk
curiouser and curiouser.
when i tried it before when i was testing it didn't work