PDA

View Full Version : Can a Java applet be called from within a javascript?



REOzzy
Apr 24th, 2003, 06:21 PM
I would like to call a java applet with parameter tags into the folowing section of javascript. replacing the playsample call in the href.

document.write('<td><p class="normal"><input type="checkbox" name="songcheckbox" onClick="changetime(\'' + i + '\')" /> <a href="javascript:playsample(\'' + songArray[i][3] + '\')">' + songArray[i][0] + '</a><span class="small"> (' + songtime + ' min)</span></p></td>');

I am fairly new to JS and am not even sure this is possible.

I would appreciate any help on this even if its to say I'm wasting my time:)

Thanx

glenngv
Apr 25th, 2003, 09:30 AM
document.applets['appletName'].playsample(parameter)

REOzzy
Apr 26th, 2003, 07:01 AM
Thank you glenngv for your reply.

I'm sure it would be very helpful if i knew anything about the playsample function.
I have searched for information on the subject but found nothing much mentioned
only the occasional use of it here and there.

Perhaps i had better explain better. I kind of inherited a site with several javascripts
already installed. Most were custom made for the site and so had little or no commenting.

I have this one script that works wonderfully for its purpose except that the
sounds won't play. that is why i thought i might use an applet to play the sounds.

most of this script is source unknown. but the an attached portion is coppyrighted.
I will include the entire script here and hope someone can help figure out why the
sound won't play.

<!--hide script from older browsers

<!--cdlength is the maximum allowed time in minutes on a cd -->
<!-- numsongs is the number of songs in your array. this will be one greater than the last numbered array element -->
var cdlength = 60;
var numsongs = 48;
var cdcode = "";
<!-- define the array to hold the song information-->
var songArray = new Array();
<!-- make it multidimensional-->
for (i=0; i<numsongs; i++)
{songArray[i] = new Array(3)}

<!-- add songs below, title in quotes, song length to the nearest minute and cd code easily identifiable -->
songArray[0][0] = "Awakening"
songArray[0][1] = 5
songArray[0][2] = "MM01"
songArray[0][3] = "awakening"
songArray[1][0] = "A Heartfelt Place"
songArray[1][1] = 5
songArray[1][2] = "MM02"
songArray[1][3] = "aheartfeltplace"
songArray[2][0] = "At Sunset"
songArray[2][1] = 4
songArray[2][2] = "MM03"
songArray[2][3] = "atsunset"
songArray[3][0] = "Open Spirit"
songArray[3][1] = 4
songArray[3][2] = "MM04"
songArray[3][3] = "openspirit"
songArray[4][0] = "Dance Into The Light"
songArray[4][1] = 3
songArray[4][2] = "MM05"
songArray[4][3] = "danceintothelight"
songArray[5][0] = "Serenity"
songArray[5][1] = 4
songArray[5][2] = "MM06"
songArray[5][3] = "serenity"
songArray[6][0] = "Wildish Prime"
songArray[6][1] = 5
songArray[6][2] = "MM07"
songArray[6][3] = "wildishprime"
songArray[7][0] = "Soul Spirals"
songArray[7][1] = 2
songArray[7][2] = "MM08"
songArray[7][3] = "soulspirals"
songArray[8][0] = "The Deepening"
songArray[8][1] = 5
songArray[8][2] = "MM09"
songArray[8][3] = "thedeepening"
songArray[9][0] = "Young Sierra"
songArray[9][1] = 5
songArray[9][2] = "MM10"
songArray[9][3] = "youngsierra"
songArray[10][0] = "A Still Point"
songArray[10][1] = 3
songArray[10][2] = "MM11"
songArray[10][3] = "astillpoint"
songArray[11][0] = "Natureís Cathedral"
songArray[11][1] = 6
songArray[11][2] = "MM12"
songArray[11][3] = "naturescathedral"
songArray[12][0] = "Eastern Sky"
songArray[12][1] = 4
songArray[12][2] = "MM13"
songArray[12][3] = "eastermsky"
songArray[13][0] = "Passionís power"
songArray[13][1] = 3
songArray[13][2] = "MM14"
songArray[13][3] = "passionspower"
songArray[14][0] = "Solitude"
songArray[14][1] = 5
songArray[14][2] = "MM15"
songArray[14][3] = "solitude"
songArray[15][0] = "Dance Of Life"
songArray[15][1] = 2
songArray[15][2] = "UC01"
songArray[15][3] = "danceoflife"
songArray[16][0] = "A Look Into Your Eyes"
songArray[16][1] = 4
songArray[16][2] = "UC02"
songArray[16][3] = "alookintoyoureyes"
songArray[17][0] = "First Snow"
songArray[17][1] = 7
songArray[17][2] = "UC03"
songArray[17][3] = "firstsnow"
songArray[18][0] = "Woman and the Wolves"
songArray[18][1] = 4
songArray[18][2] = "UC04"
songArray[18][3] = "womanandwolves"
songArray[19][0] = "Souls In Search"
songArray[19][1] = 4
songArray[19][2] = "UC05"
songArray[19][3] = "soulsinsearch"
songArray[20][0] = "Shimmering Shadows"
songArray[20][1] = 3
songArray[20][2] = "UC06"
songArray[20][3] = "shimmeringshadows"
songArray[21][0] = "River Dreams"
songArray[21][1] = 7
songArray[21][2] = "UC07"
songArray[21][3] = "riverdreams"
songArray[22][0] = "Will She?"
songArray[22][1] = 3
songArray[22][2] = "UC08"
songArray[22][3] = "willshe"
songArray[23][0] = "River Rocks and Roils"
songArray[23][1] = 6
songArray[23][2] = "UC09"
songArray[23][3] = "riverrocksandroils"
songArray[24][0] = "Into The Night"
songArray[24][1] = 4
songArray[24][2] = "UC11"
songArray[24][3] = "intothenight"
songArray[25][0] = "Beach Story"
songArray[25][1] = 5
songArray[25][2] = "UC12"
songArray[25][3] = "beachstory"
songArray[26][0] = "Sanctuary"
songArray[26][1] = 3
songArray[26][2] = "UC13"
songArray[26][3] = "sanctuary"
songArray[27][0] = "Where Eagles Soar"
songArray[27][1] = 4
songArray[27][2] = "UC14"
songArray[27][3] = "whereeaglessoar"
songArray[28][0] = "Serenity"
songArray[28][1] = 4
songArray[28][2] = "UC15"
songArray[28][3] = "serenity"
songArray[29][0] = "Ancient Timeless Dance"
songArray[29][1] = 2
songArray[29][2] = "RB01"
songArray[29][3] = "ancienttimelessdance"
songArray[30][0] = "Big Old Swamp Train"
songArray[30][1] = 5
songArray[30][2] = "RB02"
songArray[30][3] = "bigoldswamptrain"
songArray[31][0] = "Earth Music"
songArray[31][1] = 4
songArray[31][2] = "RB03"
songArray[31][3] = "earthmusic"
songArray[32][0] = "First Day Of Spring"
songArray[32][1] = 3
songArray[32][2] = "RB04"
songArray[32][3] = "firstdayofspring"
songArray[33][0] = "I95 North"
songArray[33][1] = 3
songArray[33][2] = "RB05"
songArray[33][3] = "i95north"
songArray[34][0] = "Innocent Dance"
songArray[34][1] = 5
songArray[34][2] = "RB06"
songArray[34][3] = "innocentdance"
songArray[35][0] = "Irish Toccata"
songArray[35][1] = 3
songArray[35][2] = "RB07"
songArray[35][3] = "irishtoccata"
songArray[36][0] = "Keeper Of The Flame"
songArray[36][1] = 4
songArray[36][2] = "RB08"
songArray[36][3] = "keeperoftheflame"
songArray[37][0] = "Leaving Earth"
songArray[37][1] = 3
songArray[37][2] = "RB09"
songArray[37][3] = "leavingearth"
songArray[38][0] = "Meditation III"
songArray[38][1] = 6
songArray[38][2] = "RB10"
songArray[38][3] = "meditationiii"
songArray[39][0] = "Questions"
songArray[39][1] = 4
songArray[39][2] = "RB11"
songArray[39][3] = "questions"
songArray[40][0] = "Quiet Night"
songArray[40][1] = 5
songArray[40][2] = "RB12"
songArray[40][3] = "quietnight"
songArray[41][0] = "Romance"
songArray[41][1] = 4
songArray[41][2] = "RB13"
songArray[41][3] = "romance"
songArray[42][0] = "Savage"
songArray[42][1] = 4
songArray[42][2] = "RB14"
songArray[42][3] = "savage"
songArray[43][0] = "Sweet Roberta"
songArray[43][1] = 3
songArray[43][2] = "RB15"
songArray[43][3] = "sweetroberta"
songArray[44][0] = "This Little Piggy"
songArray[44][1] = 3
songArray[44][2] = "RB16"
songArray[44][3] = "thislittlepiggy"
songArray[45][0] = "Wind in the High Treetops"
songArray[45][1] = 4
songArray[45][2] = "RB17"
songArray[45][3] = "windinthehightreetops"
songArray[46][0] = "Wisdom of the Elders"
songArray[46][1] = 4
songArray[46][2] = "RB18"
songArray[46][3] = "wisdomoftheelders"
songArray[47][0] = "Youth In Bloom"
songArray[47][1] = 4
songArray[47][2] = "RB19"
songArray[47][3] = "youthinbloom"


<!--write the track table -->
document.write("<table border='0' align='center'>");
for (i=0; i<numsongs; i=i+2)
{
var j = i+1
songtime = songArray[i][1];
document.write("<tr>");
document.write('<td><p class="normal"><input type="checkbox" name="songcheckbox" onClick="changetime(\'' + i + '\')" /> <a href="javascript:playsample(\'' + songArray[i][3] + '\')">' + songArray[i][0] + '</a><span class="small"> (' + songtime + ' min)</span></p></td>');
if (j<numsongs)
{
document.write('<td><p class="normal"><input type="checkbox" name="songcheckbox" onClick="changetime(\'' + j + '\')" /> <a href="javascript:playsample(\'' + songArray[j][3] + '\')">' + songArray[j][0] + '</a><span class="small"> (' + songtime + ' min)</span></p></td>');
}
document.write("</tr>");
}
document.write("</table>");
<!--finished writing track table-->

//---------------------------------------------------------------------||
// FUNCTION: changetime ||
// PARAMETERS: songnumber ||
// RETURNS: Timetotal and cdcode ||
// PURPOSE: Dynamically changes timer and cdcode ||
// AUTHOR: Marion Cable ||
//---------------------------------------------------------------------||

function changetime(songnumber)
{
var controlIndex;
var element;
var numberOfControls = document.customform.length;
var timetotal = 0;
var cdcode = "";
document.customformout.timebox.value = timetotal.toString();
document.customformout.codebox.value = cdcode;
for (controlIndex = 0; controlIndex < numberOfControls; controlIndex++)
{

element = document.customform[controlIndex];
if (element.type == "checkbox")
{
if (element.checked == true)
{
var i = parseInt(controlIndex);
timetotal = timetotal + songArray[i][1];
cdcode = cdcode + "/" + songArray[i][2];

if (timetotal > cdlength)
{
timetotal = "Sorry, tracktime too long!";
cdcode = "";
document.customformout.timebox.value = timetotal.toString();
document.customformout.codebox.value = cdcode;
}
document.customformout.timebox.value = timetotal.toString();
document.customformout.codebox.value = cdcode;

}
}
}

}
//=====================================================================||
// END Changetime script ||
//=====================================================================||

//end hide script-->