Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    New to the CF scene
    Join Date
    Jun 2006
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question code check/repair

    ok looka here...

    I've got this code that vic wrote me and it rocks, but now I'm tryin to put em all on one page instead of havin it in 4 different pages, and when I do the commands seem to overlap themselves. i.e., I've got a start button that activates a randomization script on the top two table defs, but then when I click the OTHER start button (the one that corresponds to the BOTTOM row of table defs) it just starts/restarts the top ones. I need these buttons to correspond to their respective fields, and I need a STOP button too. Like if you have a look at it actually working, it has a start button and then the same start button right next to it. I need one of them to be a STOP button.

    Here's how it looks


    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

    <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">

    <head>
    <title></title>
    <script language="JavaScript" type="text/javascript">
    /*<![CDATA[*/


    var formAry=['C','A','G','E','D']
    var scaleAry=['A','A#','Bb','C','C#','Db','D','D#','Eb','E','F','F#','Gb','G','G#','Ab']

    var TO;

    function Notes(id,spd){
    var table=document.getElementById(id);
    var cells=table.getElementsByTagName('TD');
    table.style.fontSize='20px';
    clearTimeout(TO);
    NotesDo(cells,spd);
    }

    function NotesDo(cells,spd){
    cells[2].innerHTML=formAry[Math.floor(Math.random()*formAry.length)];
    cells[3].innerHTML=scaleAry[Math.floor(Math.random()*scaleAry.length)];
    TO=setTimeout(function(){ NotesDo(cells,spd); },spd);
    }

    /*]]>*/
    </script></head>

    <body>
    <table id="notes" cellpadding="0" cellspacing="0" border="1" >
    <tr>
    <td width=100 align=center >form</td>
    <td width=100 align=center >scale</td>
    </tr>
    <tr >
    <td width=100 align=center >C A G E D</td>
    <td width=100 align=center >A, A#, Bb, C, C#, Db, D, D#, Eb, E, F, F#, Gb, G, G#, Ab</td>
    </tr>
    </table>
    <input type="button" value="Start" onclick="Notes('notes',3000);" />
    <input type="button" value="Start" onclick="Notes('notes',3000);" />
    </body>
    <br><br><br>
    </html> <!-- here's where I just took a wild guess and figured this would be enough of a split to make the code work... --!>

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

    <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">

    <head>
    <title></title>
    <script language="JavaScript" type="text/javascript">
    /*<![CDATA[*/


    var patternAry=['C','G']
    var positionAry=['1','2','3','4','5','6','7','8','9','10','11','12','13','14','15','16','17','18','19','20']

    var TO;

    function Notes(id,spd){
    var table=document.getElementById(id);
    var cells=table.getElementsByTagName('TD');
    table.style.fontSize='20px';
    clearTimeout(TO);
    NotesDo(cells,spd);
    }

    function NotesDo(cells,spd){
    cells[2].innerHTML=patternAry[Math.floor(Math.random()*patternAry.length)];
    cells[3].innerHTML=positionAry[Math.floor(Math.random()*positionAry.length)];
    TO=setTimeout(function(){ NotesDo(cells,spd); },spd);
    }

    /*]]>*/
    </script></head>

    <body>
    <table id="notes" cellpadding="0" cellspacing="0" border="1" >
    <tr>
    <td width=100 align=center >pattern</td>
    <td width=100 align=center >position</td>
    </tr>
    <tr >
    <td width=100 align=center >C G</td>
    <td width=100 align=center >1-20</td>
    </tr>
    </table>
    <input type="button" value="Start" onclick="Notes('notes',3000);" />
    <input type="button" value="Start" onclick="Notes('notes',3000);" />
    </body>

    </html>
    Last edited by lexscarlet; 07-03-2006 at 07:10 PM.

  • #2
    Regular Coder
    Join Date
    Aug 2005
    Location
    Toronto, ON, Canada
    Posts
    231
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I've got this code that vic wrote me and it rocks,
    ask him again
    rm -f /

  • #3
    Senior Coder
    Join Date
    Mar 2005
    Location
    Portsmouth UK
    Posts
    4,511
    Thanks
    3
    Thanked 504 Times in 491 Posts
    yes tink I should have had a look at this

    but to honest I am not sure what you are trying to achieve

    Is is that you want four displays of random form and scale?

    if so, are they all to change at the same time or to be sequenced?

    is this anything like what you want
    Code:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    
    <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
    
    <head>
    <title></title>
    <script language="JavaScript" type="text/javascript">
    /*<![CDATA[*/
    
    
    var formAry=['C','A','G','E','D']
    var scaleAry=['A','A#','Bb','C','C#','Db','D','D#','Eb','E','F','F#','Gb','G','G#','Ab']
    
    var TO1,TO2;
    
    function Notes(id,spd){
     var table=document.getElementById(id);
     var cells=table.getElementsByTagName('TD');
     table.style.fontSize='20px';
     clearTimeout(TO1);
     NotesDo(cells,spd);
    }
    
    function NotesDo(cells,spd){
     cells[2].innerHTML=formAry[Math.floor(Math.random()*formAry.length)];
     cells[3].innerHTML=scaleAry[Math.floor(Math.random()*scaleAry.length)];
     TO1=setTimeout(function(){ NotesDo(cells,spd); },spd);
    }
    
    
    function Notes2(id,spd){
     var table=document.getElementById(id);
     var cells=table.getElementsByTagName('TD');
     table.style.fontSize='20px';
     clearTimeout(TO2);
     NotesDo2(cells,spd);
    }
    
    function NotesDo2(cells,spd){
     cells[4].innerHTML=formAry[Math.floor(Math.random()*formAry.length)];
     cells[5].innerHTML=scaleAry[Math.floor(Math.random()*scaleAry.length)];
     TO2=setTimeout(function(){ NotesDo2(cells,spd); },spd);
    }
    
    /*]]>*/
    </script></head>
    
    <body>
    <table id="notes" cellpadding="0" cellspacing="0" border="1" >
    <tr>
    <td width=100 align=center >form</td>
    <td width=100 align=center >scale</td>
    </tr>
    <tr >
    <td width=100 align=center >C A G E D</td>
    <td width=100 align=center >A, A#, Bb, C, C#, Db, D, D#, Eb, E, F, F#, Gb, G, G#, Ab</td>
    </tr>
    <tr >
    <td width=100 align=center >C A G E D</td>
    <td width=100 align=center >A, A#, Bb, C, C#, Db, D, D#, Eb, E, F, F#, Gb, G, G#, Ab</td>
    </tr>
    </table>
    <input type="button" value="Start" onclick="Notes('notes',3000);" />
    <input type="button" value="Start" onclick="Notes2('notes',3000);" />
    </body>
    <br><br><br>
    </html>
    Last edited by vwphillips; 07-08-2006 at 10:28 PM.
    Vic

    God Loves You and will never love you less.

    http://www.vicsjavascripts.org/Home.htm

    If my post has been useful please donate to http://www.operationsmile.org.uk/

  • #4
    Senior Coder
    Join Date
    Mar 2005
    Location
    Portsmouth UK
    Posts
    4,511
    Thanks
    3
    Thanked 504 Times in 491 Posts
    many as you want with this

    Code:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    
    <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
    
    <head>
    <title></title>
    <script language="JavaScript" type="text/javascript">
    /*<![CDATA[*/
    
    
    var formAry=['C','A','G','E','D']
    var scaleAry=['A','A#','Bb','C','C#','Db','D','D#','Eb','E','F','F#','Gb','G','G#','Ab']
    
    var zxcCnt=0;
    
    function zxcNotes(zxcobj,zxcspd){
     window['zxcNewNote'+zxcCnt]=new zxcNotesOOP(zxcobj,zxcspd);
    }
    
    function zxcStopStart(zxcobj){
     var zxcoop=window[zxcobj.id.replace('zxcStop','zxcNewNote')];
     if (zxcobj.value=='Stop'){
      zxcobj.value='Start';
      clearTimeout(zxcoop.to);
     }
     else {
      zxcobj.value='Stop';
      zxcoop.notedo();
     }
    }
    
    function zxcNewNote(zxcobj){
     var zxcoop=window[zxcobj.id.replace('zxcMore','zxcNewNote')];
     var zxctr;
     var zxctb=zxcobj;
     while (zxctb.parentNode){
      if (zxctb.tagName=='TR'){  zxctr=zxctb; }
      if (zxctb.tagName=='TBODY'){ zxctb=zxctb; break; }
      zxctb=zxctb.parentNode;
     }
     zxcobj.parentNode.removeChild(zxcobj);
     zxctr=zxctr.cloneNode(true);
     zxctb.appendChild(zxctr);
     var zxcip=zxctr.getElementsByTagName('INPUT')[0];
     zxcip.value='Start';
     zxcip.onclick=function(){ zxcNotes(this,zxcoop.dly+10); }
    }
    
    
    function zxcNotesOOP(zxcobj,zxcspd){
     this.tr=zxcobj;
     while (zxcobj.parentNode){
      if (this.tr.tagName=='TR'){  break; }
      this.tr=this.tr.parentNode;
     }
     if (this.tr.tagName!='TR'){ return; }
     zxcobj.value='Stop';
     zxcobj.id='zxcStop'+zxcCnt;
     zxcobj.onclick=function(){ zxcStopStart(this); }
     this.more=zxcobj.cloneNode(true);
     this.more.id='zxcMore'+zxcCnt;
     this.more.onclick=function(){ zxcNewNote(this); }
     this.more.value='More';
     zxcobj.parentNode.appendChild(this.more);
     this.ref='zxcOOP'+zxcCnt++;
     window[this.ref]=this;
     this.dly=zxcspd;
     this.cells=this.tr.getElementsByTagName('TD');
     this.notedo();
    }
    
    zxcNotesOOP.prototype.notedo=function(){
     this.cells[0].innerHTML=formAry[Math.floor(Math.random()*formAry.length)];
     this.cells[1].innerHTML=scaleAry[Math.floor(Math.random()*scaleAry.length)];
     this.setTimeOut('notedo()',this.dly);
    }
    
    zxcNotesOOP.prototype.setTimeOut=function(zxcf,zxcd){
     this.to=setTimeout('window.'+this.ref+'.'+zxcf,zxcd);
    }
    
    
    /*]]>*/
    </script>
    
    </head>
    
    <body>
    <table id="notes" cellpadding="0" cellspacing="0" border="1" >
    <tbody>
    <tr>
    <td width=100 align=center >form</td>
    <td width=100 align=center >scale</td>
    <td width=100 align=center >control</td>
    </tr>
    <tr >
     <td width=100 align=center style="font-size:18px;" >&nbsp;</td>
     <td width=100 align=center style="font-size:18px;" >&nbsp;</td>
     <td width=120 align=center ><input type="button" value="Start" onclick="zxcNotes(this,3000);" /></td>
    </tr>
    </tbody>
    </table>
    </body>
    <br><br><br>
    </html>
    Vic

    God Loves You and will never love you less.

    http://www.vicsjavascripts.org/Home.htm

    If my post has been useful please donate to http://www.operationsmile.org.uk/


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •