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.
Page 1 of 3 123 LastLast
Results 1 to 15 of 31
  1. #1
    New Coder
    Join Date
    Mar 2013
    Posts
    12
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Unhappy EvalSound function help with sound

    I'm a teacher that created a spelling program for my kids that I use every day in my classroom. We just switched from XP to Windows 7 and now my program won't play the sounds. We also switched to netscape browser, which this program never worked in ( the sound bites are wav files). I need this program to work, but I just can't figure this out. I think it has to do wit the EvalSound function:

    function EvalSound(soundobj)
    {
    var thissound = eval("document." + soundobj);
    thissound.Play();
    thissound = null;
    }

    Some one ran a test for me on the site and it says: "uncaught type error: cannot call method 'play' of undefined"

    How can I make this program work in Windows7 as well as in the netscape browser?

  • #2
    Senior Coder rnd me's Avatar
    Join Date
    Jun 2007
    Location
    Urbana
    Posts
    4,298
    Thanks
    10
    Thanked 584 Times in 565 Posts
    use the <audio> tag. google "audio tag" or "audio tag javascript" for cut and paste examples.
    my site (updated 13/9/26)
    BROWSER STATS [% share] (2014/5/28) IE7:0.1, IE8:5.3, IE11:8.4, IE9:3.2, IE10:3.2, FF:18.2, CH:46, SF:7.9, NON-MOUSE:32%

  • #3
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    25,200
    Thanks
    75
    Thanked 4,342 Times in 4,308 Posts
    The <audio> tag DOES NOT WORK with ".wav" files in MSIE. Not even in MSIE 9.

    The <embed> and <object> tags will work with ".wav" in MSIE.

    But then I just noticed: "Netscape browser." ???? Netscape is officially *DEAD*. Why why why would you choose a browser that is completely obsolete, no longer supported by ANYBODY, will never be updated further, etc.??? Netscape was bought by AOL, but even AOL gave up on in it in February 2008 when it realized it could never keep up with the modern browsers, such as Chrome and Firefox. In any case, I'm pretty sure that <audio> was never implemented in ancient Netscape.
    An optimist sees the glass as half full.
    A pessimist sees the glass as half empty.
    A realist drinks it no matter how much there is.

  • #4
    New Coder
    Join Date
    Mar 2013
    Posts
    12
    Thanks
    3
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by Old Pedant View Post
    The <audio> tag DOES NOT WORK with ".wav" files in MSIE. Not even in MSIE 9.

    The <embed> and <object> tags will work with ".wav" in MSIE.

    But then I just noticed: "Netscape browser." ???? Netscape is officially *DEAD*. Why why why would you choose a browser that is completely obsolete, no longer supported by ANYBODY, will never be updated further, etc.??? Netscape was bought by AOL, but even AOL gave up on in it in February 2008 when it realized it could never keep up with the modern browsers, such as Chrome and Firefox. In any case, I'm pretty sure that <audio> was never implemented in ancient Netscape.
    Oh my, I can't believe I said Netscape. I meant firefox. The district has defaulted to firefox and the program won't work in firefox... never has. It plays in xp in internet explorer, but it won't in windows 7. I use the embed tag. Here is what par tof the code looks like:

    <script language="JavaScript">
    <!--

    function SymError()
    {
    return true;
    }

    window.onerror = SymError;

    var SymRealWinOpen = window.open;

    function SymWinOpen(url, name, attributes)
    {
    return (new Object());
    }

    window.open = SymWinOpen;

    //-->
    </script>

    <script language="JavaScript">




    javascript:window.history.forward(1);


    // helper function to play the sound
    function EvalSound(soundobj)
    {
    var thissound = eval("document." + soundobj);
    thissound.Play();
    thissound = null;
    }



    // an array of words
    var wordArray = new Array(
    'a.wav',
    'about.wav',
    'all.wav',
    'am.wav',
    'an.wav',
    'and.wav',
    'are.wav',
    'as.wav',
    'at.wav',

    'be.wav',
    'been.wav',
    'but.wav',
    'by.wav',

    'can.wav',
    'called.wav',
    'come.wav',
    'could.wav',

    'day.wav',
    'did.wav',
    'do.wav',
    'down.wav',

    'each.wav',

    'find.wav',
    'first.wav',
    'for.wav',
    'from.wav',

    'get.wav',
    'go.wav',

    'had.wav',

    'has.wav',
    'have.wav',
    'he.wav',
    'her.wav',
    'him.wav',
    'his.wav',
    'how.wav',

    'I.wav',
    'if.wav',
    'in.wav',
    'into.wav',
    'is.wav',
    'it.wav',
    'its.wav',

    'like.wav',
    'long.wav',
    'look.wav',

    'made.wav',
    'make.wav',
    'many.wav',
    'may.wav',
    'more.wav',
    'my.wav',

    'no.wav',
    'not.wav',
    'now.wav',
    'number.wav',

    'of.wav',
    'on.wav',
    'one.wav',
    'or.wav',
    'other.wav',
    'out.wav',

    'part.wav',
    'people.wav',

    'said.wav',
    'see.wav',
    'she.wav',
    'so.wav',
    'some.wav',

    'than.wav',
    'that.wav',
    'the.wav',
    'their.wav',
    'then.wav',
    'them.wav',
    'there.wav',
    'these.wav',
    'they.wav',
    'this.wav',
    'time.wav',
    'to.wav',
    'two.wav',

    'up.wav',
    'use.wav',

    'was.wav',
    'water.wav',
    'way.wav',
    'we.wav',
    'were.wav',
    'what.wav',
    'when.wav',
    'which.wav',
    'who.wav',
    'will.wav',
    'with.wav',
    'words.wav',
    'would.wav',
    'write.wav',

    'you.wav',
    'your.wav'


    );



    // an array of sentences
    var sentenceArray = new Array(
    'senone.wav',
    'sentwo.wav',
    'senthree.wav',
    'senfour.wav',
    'senfive.wav',

    'sensix.wav',
    'senseven.wav',
    'seneight.wav',
    'sennine.wav',
    'senten.wav',

    'seneleven.wav',
    'sentwelve.wav',
    'senthirteen.wav',
    'senfourteen.wav',
    'senfifteen.wav',

    'sensixteen.wav',
    'senseventeen.wav',
    'seneighteen.wav',
    'sennineteen.wav',
    'sentwenty.wav'



    );


    // global variable to represent the total number of words and sentences
    // in the IE document.embed collection.
    var totalEmbedCount = 0;

    ///////////////////////////////////////////////////////////////////////////////
    // function SelectWords
    // This function will generate html and write it to document object.
    // The html is randomly selected words from the wordArray or the sentenceArray
    // arrays. The words are then added to the selectedArray.
    // Do not allow duplicate words. This requires that the wordArray and
    // sentence array have unique entries.
    //
    // parameters:
    // array the array from which to select from
    // maximumWords the number of words to randomly select from the numArr list
    //
    // the process:
    //
    // generate a random index in the numArr list.
    // while the number of selected words is less than maximumWords
    // if the value at the index was already selected,then
    // select another random index
    // else
    // add the indexed value to the selected value list
    // write the html to the document
    // store the indexed value in the document embed list
    // endif
    // end while
    ///////////////////////////////////////////////////////////////////////////////
    function SelectWords(array, maximumWords)
    {
    var selectedArray = new Array(); // the list of selected objects
    var randomIndex = 0;
    var selectedCount = 0;
    var selectedWord = "";

    debugger;

    // return if there are not enough words to select from
    if(array.length < maximumWords)
    {
    return;
    }

    print
    // select maximumWords randomly selected words
    while(selectedCount < maximumWords)
    {
    randomIndex = Math.round((array.length-1)*Math.random());

    // save the randomly selected word for later use
    selectedWord = array[randomIndex];

    if(selectedArray[randomIndex] != randomIndex)
    {
    // store the index at the index to indicate that the index was selected.
    selectedArray[randomIndex] = randomIndex;

    // generate the html
    document.write("<EMBED src=" + selectedWord + " autostart=false hidden=true enablejavascript=true></br>");
    document.embeds[totalEmbedCount].name = selectedWord;

    // increment the selected word count.
    selectedCount++;

    // increment the total number of embed entries.
    totalEmbedCount++;

    } // if (selectedArray[randomIndex] != randomIndex)

    } // while(selectedIndex < maximumWords)

    selectedArray = null;
    array = null;

    } // SelectWords


    // note that these values are required to support the html below because there are
    // 20 words in "Word List 1" and 5 sentences in "Sentence List 1"
    // select 20 words from the word array.
    SelectWords(wordArray, 20);

    // select 5 sentences from the sentence array.
    SelectWords(sentenceArray, 5);

    </script>

    Then I put the layout in a form so when the kids click a button it plays the word


    <a href="#" onClick="EvalSound('embeds[0]')">
    Word 1
    </a><input type="hidden" Name="name1" Size="10" ID="Hidden2">
    <script>
    document.spelling1.name1.value=document.embeds[0].name
    </script>

    I just can't find the bug. any help suggested. I'm down to only 2 computers out of 6 that will play it now and I use it daily in my classroom.

  • #5
    New Coder
    Join Date
    Mar 2013
    Posts
    12
    Thanks
    3
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by rnd me View Post
    use the <audio> tag. google "audio tag" or "audio tag javascript" for cut and paste examples.
    audio tag is for html5, right? I converted files to mp3, then tried to get audio tag to work, but it didn't respond.any other suggestions?

  • #6
    Senior Coder rnd me's Avatar
    Join Date
    Jun 2007
    Location
    Urbana
    Posts
    4,298
    Thanks
    10
    Thanked 584 Times in 565 Posts
    Quote Originally Posted by pbeaking View Post
    audio tag is for html5, right? I converted files to mp3, then tried to get audio tag to work, but it didn't respond.any other suggestions?
    the audio tag is for webpages shown in browsers we all love like iPad's Safari, Firefox, and IE9+.
    i'm not sure what html5 is at this point; it's a lot more complex than when we had 2 browsers and 3 doctypes to contend with...

    Ironically, firefox won't play MP3 in an audio tag, but will play wav just fine.

    frustrating i know, but there are combos of browsers, formats, and code to work about everywhere; we can figure it out.

    do you need it to work in IE, or is just firefox enough for this project?
    my site (updated 13/9/26)
    BROWSER STATS [% share] (2014/5/28) IE7:0.1, IE8:5.3, IE11:8.4, IE9:3.2, IE10:3.2, FF:18.2, CH:46, SF:7.9, NON-MOUSE:32%

  • #7
    New Coder
    Join Date
    Mar 2013
    Posts
    12
    Thanks
    3
    Thanked 0 Times in 0 Posts
    The district has defaulted to Firefox, so I suppose it would be better if it worked in it. However, two computers are XP and 4 our win 7 I need it to work on all computers if possible. Any help would be so appreciated. I have 24 kids that take spelling tests twice a week and only 2 computers work. It really slows things down

  • #8
    Senior Coder rnd me's Avatar
    Join Date
    Jun 2007
    Location
    Urbana
    Posts
    4,298
    Thanks
    10
    Thanked 584 Times in 565 Posts
    my site (updated 13/9/26)
    BROWSER STATS [% share] (2014/5/28) IE7:0.1, IE8:5.3, IE11:8.4, IE9:3.2, IE10:3.2, FF:18.2, CH:46, SF:7.9, NON-MOUSE:32%

  • #9
    Senior Coder xelawho's Avatar
    Join Date
    Nov 2010
    Posts
    2,925
    Thanks
    56
    Thanked 548 Times in 545 Posts
    I think this is becoming overly complicated. But the other thing is that the code you have is quite old, so it seems to me that it would be easier to rewrite than try to fix it and patch it here and there.

    Can you explain in plain terms what the program is supposed to do? From what I gather, it takes all the sound files, jumbles them randomly then I guess the kid clicks a "play" button and the sounds play one by one.

    And the sound files are all in .wav format and it only needs to work in firefox.

    Is that correct?

  • #10
    New Coder
    Join Date
    Mar 2013
    Posts
    12
    Thanks
    3
    Thanked 0 Times in 0 Posts
    My Spelling Rodeo takes 100 words and randomly selects 20. It also has 20 sentences and randomly selects 5.It then connects these words to buttons in a form. The kids click on the buttons to get their words.
    After the kids are done, they submit form to me and it sends the list of words chosen to my email (on a side note, the list of words come with the .wav after it and I would love to have it get rid of the .wav and just give me the word). Yes, firefox would be the browser most used at school. I need to redo the sound bites for clarity, so I can change them to any format if that is helpful. I just don't have the know how to fix this.

  • #11
    Senior Coder xelawho's Avatar
    Join Date
    Nov 2010
    Posts
    2,925
    Thanks
    56
    Thanked 548 Times in 545 Posts
    Maybe you can use this for a start. I left the second lot of inputs visible for testing purposes, but you can hide them by adding type="hidden" - I have commented where to do it in the code

    Works in Firefox and Chrome, won't work in IE <9

    Code:
    <!DOCTYPE html>
    <html>
    <head>
    <title>Spelling Rodeo</title>
    </head>
    
    <body>
    <audio id="myaudio"></audio>
    
    <form id="theform"></form>
    
    <script type="text/javascript">
    (function(){
    // an array of words
    var wordArray = [
    'a.wav',
    'about.wav',
    'all.wav',
    'am.wav',
    'an.wav',
    'and.wav',
    'are.wav',
    'as.wav',
    'at.wav',
    
    'be.wav',
    'been.wav',
    'but.wav',
    'by.wav',
    
    'can.wav',
    'called.wav',
    'come.wav',
    'could.wav',
    
    'day.wav',
    'did.wav',
    'do.wav',
    'down.wav',
    
    'each.wav',
    
    'find.wav',
    'first.wav',
    'for.wav',
    'from.wav',
    
    'get.wav',
    'go.wav',
    
    'had.wav',
    
    'has.wav',
    'have.wav',
    'he.wav',
    'her.wav',
    'him.wav',
    'his.wav',
    'how.wav',
    
    'I.wav',
    'if.wav',
    'in.wav',
    'into.wav',
    'is.wav',
    'it.wav',
    'its.wav',
    
    'like.wav',
    'long.wav',
    'look.wav',
    
    'made.wav',
    'make.wav',
    'many.wav',
    'may.wav',
    'more.wav',
    'my.wav',
    
    'no.wav',
    'not.wav',
    'now.wav',
    'number.wav',
    
    'of.wav',
    'on.wav',
    'one.wav',
    'or.wav',
    'other.wav',
    'out.wav',
    
    'part.wav',
    'people.wav',
    
    'said.wav',
    'see.wav',
    'she.wav',
    'so.wav',
    'some.wav',
    
    'than.wav',
    'that.wav',
    'the.wav',
    'their.wav',
    'then.wav',
    'them.wav',
    'there.wav',
    'these.wav',
    'they.wav',
    'this.wav',
    'time.wav',
    'to.wav',
    'two.wav',
    
    'up.wav',
    'use.wav',
    
    'was.wav',
    'water.wav',
    'way.wav',
    'we.wav',
    'were.wav',
    'what.wav',
    'when.wav',
    'which.wav',
    'who.wav',
    'will.wav',
    'with.wav',
    'words.wav',
    'would.wav',
    'write.wav',
    
    'you.wav',
    'your.wav']
    
    
    // an array of sentences
    var sentenceArray = [
    'senone.wav',
    'sentwo.wav',
    'senthree.wav',
    'senfour.wav',
    'senfive.wav',
    
    'sensix.wav',
    'senseven.wav',
    'seneight.wav',
    'sennine.wav',
    'senten.wav',
    
    'seneleven.wav',
    'sentwelve.wav',
    'senthirteen.wav',
    'senfourteen.wav',
    'senfifteen.wav',
    
    'sensixteen.wav',
    'senseventeen.wav',
    'seneighteen.wav',
    'sennineteen.wav',
    'sentwenty.wav']
    
    function shuffle(array) {
    var n = array.length, k, t;
    if (n == 0) {return false};
    while (--n) {
    k = Math.floor(Math.random() * (n+1));
    t = array[n];
    array[n] = array[k];
    array[k] = t;
    }
    }
    
    shuffle(sentenceArray);
    
    shuffle(wordArray);
    
    var thecontent=document.getElementById("theform");
    thecontent.innerHTML='Words<br>'
    for (var i = 0; i < 20; i++) {
    var theword=wordArray[i].replace(".wav","");
    thecontent.innerHTML+='<input type="button" onclick="playSound(\''+theword+'\')" value="Play Sound"/>Spell Word: <input name="word'+i+'"/><input value="'+theword+'" name="hidword'+i+'"/><br>'; //add type="hidden" to last input here to hide answers
    }
    
    thecontent.innerHTML+='Sentences<br>'
    for (var a = 0; a < 5; a++) {
    var thephrase=sentenceArray[a].replace(".wav","");
    thecontent.innerHTML+='<input type="button" onclick="playSound(\''+thephrase+'\')" value="Play Sound"/>Spell sentence: <input style="width: 400px" name="phrase'+a+'"/><input value="'+thephrase+'" name="hidphrase'+a+'"/><br>'; //add type="hidden" to last input here to hide answers
    }
    }());
    
    function playSound(thefile){
    document.getElementById("myaudio").src=thefile+".wav";
    document.getElementById("myaudio").play();
    }
    </script>
    </body>
    
    </html>

  • #12
    New Coder
    Join Date
    Mar 2013
    Posts
    12
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Can't get it to work!

    I tinkered with your example all last night and part of today. I see what you've done (or I think I see), but when I loaded it up on page in firefox, there was no sound. It said error on page. I've attached a link here so you can see the format that I'm trying to achieve. The form is not fill in the blank. The kids listen to the audio and then write their words down on paper. They then submit it so that I get a list of what words they were given. That's great you got rid of the .wav thing! I was trying to figure out how to do a table so that I could have the buttons go across in 4 columns. I thank you so much for the help. I think it's best you just look at site.

    Spelling Rodeo List 1

  • #13
    Senior Coder xelawho's Avatar
    Join Date
    Nov 2010
    Posts
    2,925
    Thanks
    56
    Thanked 548 Times in 545 Posts
    interesting.

    I ran the code I posted in Chrome and it works fine with your sound files. In firefox I get an error that says "Media resource http://spellingrodeocom.ipage.com/Sp...t%201/your.wav could not be decoded."

    but running the code with my .wav files, it works fine in firefox

    googling around, it seems that the problem could come from one of two issues:
    - the MIME type of your files is not set correctly
    - the bit rate is too high. It would appear that Firefox supports 8-bit and 16-bit PCM, but not other bit depths (12, 20, 24, 32).

    maybe if you were going to re-record your audio files anyway it would make sense to do them in .ogg format which may be less problematic:
    https://developer.mozilla.org/en-US/..._media_formats

    sorry, I don't know too much about audio so I'm not sure how much help I can be here

  • Users who have thanked xelawho for this post:

    pbeaking (03-31-2013)

  • #14
    New Coder
    Join Date
    Mar 2013
    Posts
    12
    Thanks
    3
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by xelawho View Post
    interesting.

    I ran the code I posted in Chrome and it works fine with your sound files. In firefox I get an error that says "Media resource http://spellingrodeocom.ipage.com/Sp...t%201/your.wav could not be decoded."

    but running the code with my .wav files, it works fine in firefox

    googling around, it seems that the problem could come from one of two issues:
    - the MIME type of your files is not set correctly
    - the bit rate is too high. It would appear that Firefox supports 8-bit and 16-bit PCM, but not other bit depths (12, 20, 24, 32).

    maybe if you were going to re-record your audio files anyway it would make sense to do them in .ogg format which may be less problematic:
    https://developer.mozilla.org/en-US/..._media_formats

    sorry, I don't know too much about audio so I'm not sure how much help I can be here
    It was the bit rate that made the difference! I tried it on my win 7 at home and it plays in firefox and chrome. I'll try it at school on Monday. Thank you SO Much!

    I have two more questions:

    Is there a way to make the play sound buttons go 4 across by 5 rows? I've tried to put a table in the code, but can't seem to figure it out. Is there a way to assign each element pulled from the array to a specific cell?

    Also, I have my sentences named senone.wav, sentwo.wav. That is what comes in the form to me when I go to grade. Is there any way give each sentence wav an id or name that can then be replaced in the form. What I'm trying to do is have the full sentence show in the form that is sent to me: ie. senone.wav = "He and I had the duck."

  • #15
    Senior Coder xelawho's Avatar
    Join Date
    Nov 2010
    Posts
    2,925
    Thanks
    56
    Thanked 548 Times in 545 Posts
    buttons and inputs are inline elements, so they will naturally (naturally?) go across the page. So all we have to do is add a line break after every fourth button and it kind of looks like a table. Add a little css and it looks alot like a table, without even having to make a table. Have a look and see what you think.

    You can store the sentence text along with the file path, in objects. I've done the first six to give you an idea of the data structure. Feel free to ask if you get confused. The obvious downfall being that if any of your kids looks at the source code all the answers are there. But that's true for the single word files, anyway...

    I'm assuming you have saved the new files with the different bit rates with different path names, as I tested this code with the old path names and got the same result - works in Chrome, not in FF...

    Code:
    <!DOCTYPE html>
    <html>
    <head>
    <title>Spelling Rodeo</title>
    <style>
    #btns{
    text-align: center; 
    }
    
    .wrdbtn{
    width: 10%;
    margin:5px;
    }
    </style>
    </head>
    
    <body>
    <audio id="myaudio"></audio>
    
    <form id="theform">
    <fieldset id="btns"></fieldset>
    
    </form>
    
    <script type="text/javascript">
    (function(){
    // an array of words
    var wordArray = [
    'a.wav',
    'about.wav',
    'all.wav',
    'am.wav',
    'an.wav',
    'and.wav',
    'are.wav',
    'as.wav',
    'at.wav',
    
    'be.wav',
    'been.wav',
    'but.wav',
    'by.wav',
    
    'can.wav',
    'called.wav',
    'come.wav',
    'could.wav',
    
    'day.wav',
    'did.wav',
    'do.wav',
    'down.wav',
    
    'each.wav',
    
    'find.wav',
    'first.wav',
    'for.wav',
    'from.wav',
    
    'get.wav',
    'go.wav',
    
    'had.wav',
    
    'has.wav',
    'have.wav',
    'he.wav',
    'her.wav',
    'him.wav',
    'his.wav',
    'how.wav',
    
    'I.wav',
    'if.wav',
    'in.wav',
    'into.wav',
    'is.wav',
    'it.wav',
    'its.wav',
    
    'like.wav',
    'long.wav',
    'look.wav',
    
    'made.wav',
    'make.wav',
    'many.wav',
    'may.wav',
    'more.wav',
    'my.wav',
    
    'no.wav',
    'not.wav',
    'now.wav',
    'number.wav',
    
    'of.wav',
    'on.wav',
    'one.wav',
    'or.wav',
    'other.wav',
    'out.wav',
    
    'part.wav',
    'people.wav',
    
    'said.wav',
    'see.wav',
    'she.wav',
    'so.wav',
    'some.wav',
    
    'than.wav',
    'that.wav',
    'the.wav',
    'their.wav',
    'then.wav',
    'them.wav',
    'there.wav',
    'these.wav',
    'they.wav',
    'this.wav',
    'time.wav',
    'to.wav',
    'two.wav',
    
    'up.wav',
    'use.wav',
    
    'was.wav',
    'water.wav',
    'way.wav',
    'we.wav',
    'were.wav',
    'what.wav',
    'when.wav',
    'which.wav',
    'who.wav',
    'will.wav',
    'with.wav',
    'words.wav',
    'would.wav',
    'write.wav',
    
    'you.wav',
    'your.wav']
    
    
    // an array of objects containing the sentence file paths and their text
    var sentenceArray = [
    {aud:'senone.wav',
     txt:'The cat sat on the mat'},
    {aud:'sentwo.wav',
     txt:'The quick brown fox did something'},
     {aud:'senthree.wav',
     txt:'Peter Piper picked a peck'},
     {aud:'senfour.wav',
     txt:'The rain in Spain'},
     {aud:'senfive.wav',
     txt:'Once a Jolly Jumbuck...'},
     {aud:'sensix.wav',
     txt:'She sells sea shells'} // the last one in the list should not have a comma after it - all the others should.
    ]
    
    function shuffle(array) {
    var n = array.length, k, t;
    if (n == 0) {return false};
    while (--n) {
    k = Math.floor(Math.random() * (n+1));
    t = array[n];
    array[n] = array[k];
    array[k] = t;
    }
    }
    
    shuffle(sentenceArray);
    
    shuffle(wordArray);
    
    var thecontent=document.getElementById("btns");
    thecontent.innerHTML='Words<br>'
    for (var i = 1; i < 21; i++) {
    var theword=wordArray[i].replace(".wav","");
    thecontent.innerHTML+='<input type="button" class="wrdbtn" onclick="playSound(\''+wordArray[i]+'\')" value="Play Word '+i+'"/><input value="'+theword+'" type="hidden" name="hidword'+i+'"/>'; //remove type="hidden" here to see answers
    if(i%4==0){
    thecontent.innerHTML+="<br>";
    }
    }
    
    thecontent.innerHTML+='Sentences<br>'
    for (var a = 1; a < 6; a++) {
    var theaudio=sentenceArray[a].aud;
    var thephrase=sentenceArray[a].txt;
    thecontent.innerHTML+='<input type="button" class="wrdbtn" onclick="playSound(\''+theaudio+'\')" value="Play Sentence '+a+'"/><input value="'+thephrase+'" type="hidden" name="hidphrase'+a+'"/>'; //remove type="hidden" here to see answers
    }
    }());
    
    function playSound(thefile){
    document.getElementById("myaudio").src=thefile;
    document.getElementById("myaudio").play();
    }
    </script>
    </body>
    
    </html>

  • Users who have thanked xelawho for this post:

    pbeaking (04-01-2013)


  •  
    Page 1 of 3 123 LastLast

    Tags for this Thread

    Posting Permissions

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