Z
zjw2112
Hello. I have an html page that contains javascript where when a
button is clicked, a div's innnerHTML is modified based on a text box's
value. If I modify the text box's value again and click the button
again, the div section won't update. Below is my code. Please look at
the function submitMe(). Inside the for loop, the file's path is
dynamic, based on the value inside the text box. The first time this
function is called everything works. On subsequent times that the
function is called, the file path doesn't change based on the text box
value. I would like to note that the code is not a real application at
the moment, I am just trying out somethings, so some of whats going on
might not make since. If you can understand the code, and see possible
improvements, please let me know. Thanks.
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta name="generator" content="HTML Tidy, see www.w3.org">
<title>Audio</title>
<meta http-equiv="Content-Type" content="text/html;
charset=ISO-8859-1">
<script type="text/javascript">
function playMe(file, position)
{
Player.settings.requestMediaAccessRights("read");
if ( (file % 2) == 0 )
{
var plRet;
plRet = Player.mediaCollection.getByAlbum("Vapor
Trails");
if (plRet.count > 0)
{
var secondItem = plRet.item(1);
Player.URL = secondItem.sourceURL;
Player.controls.currentPosition=position;
Player.controls.play();
}
else
{
alert("Unable to obtain media collection");
}
}
else
{
var plRet;
plRet = Player.mediaCollection.getByAlbum("Remasters
(Disc 2)");
if (plRet.count > 0)
{
var secondItem = plRet.item(1);
Player.URL = secondItem.sourceURL;
Player.controls.currentPosition=position;
Player.controls.play();
}
else
{
alert("Unable to obtain media collection");
}
}
}
function submitMe()
{
document.all.result_section.innerHTML = "";
var htmlStr = "<div id='result_section'>";
htmlStr += "<OBJECT id=Player
classid=CLSID:6BF52A52-394A-11d3-B153-00C04F79FAA6 ";
htmlStr += "height='300' width='300'>";
htmlStr += "<PARAM NAME='autoStart'
VALUE='true'></OBJECT><BR><BR>";
htmlStr += "<table id='table1' border=1>";
htmlStr += "<tr>";
htmlStr += "<th>Score<\/th>";
htmlStr += "<th>PAT File<\/th>";
htmlStr += "<th>Time Offset<\/th>";
htmlStr += "<\/tr>";
alert(htmlStr);
var scoreCount = 34.0;
for (i = 0; i < 5; i++)
{
htmlStr += "<tr>";
htmlStr += "<td>" + (scoreCount + i) + "<\/td>";
htmlStr += "<td><a href='javascriptlayMe(" + i + ","
+ scoreCount;
htmlStr += ");'>C:\\program files\\nexidia\\media\\" +
document.form1.search_term.value;
htmlStr += "\\file1.mp3</a></td>";
htmlStr += "<td>00:04:30</td>";
htmlStr += "</tr>";
scoreCount += 5.0;
}
htmlStr += "</table></div>";
document.all.result_section.innerHTML=htmlStr;
}
</script>
</head>
<body>
<div id="search_section">
<form method="get" name="form1">Please enter search term: <input
name="search_term" value=""><br>
<br>
<input type="button" name="Submit" value="Submit"
onclick="submitMe()">
</form>
</div>
<div id="result_section"></div>
</body>
</html>
button is clicked, a div's innnerHTML is modified based on a text box's
value. If I modify the text box's value again and click the button
again, the div section won't update. Below is my code. Please look at
the function submitMe(). Inside the for loop, the file's path is
dynamic, based on the value inside the text box. The first time this
function is called everything works. On subsequent times that the
function is called, the file path doesn't change based on the text box
value. I would like to note that the code is not a real application at
the moment, I am just trying out somethings, so some of whats going on
might not make since. If you can understand the code, and see possible
improvements, please let me know. Thanks.
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta name="generator" content="HTML Tidy, see www.w3.org">
<title>Audio</title>
<meta http-equiv="Content-Type" content="text/html;
charset=ISO-8859-1">
<script type="text/javascript">
function playMe(file, position)
{
Player.settings.requestMediaAccessRights("read");
if ( (file % 2) == 0 )
{
var plRet;
plRet = Player.mediaCollection.getByAlbum("Vapor
Trails");
if (plRet.count > 0)
{
var secondItem = plRet.item(1);
Player.URL = secondItem.sourceURL;
Player.controls.currentPosition=position;
Player.controls.play();
}
else
{
alert("Unable to obtain media collection");
}
}
else
{
var plRet;
plRet = Player.mediaCollection.getByAlbum("Remasters
(Disc 2)");
if (plRet.count > 0)
{
var secondItem = plRet.item(1);
Player.URL = secondItem.sourceURL;
Player.controls.currentPosition=position;
Player.controls.play();
}
else
{
alert("Unable to obtain media collection");
}
}
}
function submitMe()
{
document.all.result_section.innerHTML = "";
var htmlStr = "<div id='result_section'>";
htmlStr += "<OBJECT id=Player
classid=CLSID:6BF52A52-394A-11d3-B153-00C04F79FAA6 ";
htmlStr += "height='300' width='300'>";
htmlStr += "<PARAM NAME='autoStart'
VALUE='true'></OBJECT><BR><BR>";
htmlStr += "<table id='table1' border=1>";
htmlStr += "<tr>";
htmlStr += "<th>Score<\/th>";
htmlStr += "<th>PAT File<\/th>";
htmlStr += "<th>Time Offset<\/th>";
htmlStr += "<\/tr>";
alert(htmlStr);
var scoreCount = 34.0;
for (i = 0; i < 5; i++)
{
htmlStr += "<tr>";
htmlStr += "<td>" + (scoreCount + i) + "<\/td>";
htmlStr += "<td><a href='javascriptlayMe(" + i + ","
+ scoreCount;
htmlStr += ");'>C:\\program files\\nexidia\\media\\" +
document.form1.search_term.value;
htmlStr += "\\file1.mp3</a></td>";
htmlStr += "<td>00:04:30</td>";
htmlStr += "</tr>";
scoreCount += 5.0;
}
htmlStr += "</table></div>";
document.all.result_section.innerHTML=htmlStr;
}
</script>
</head>
<body>
<div id="search_section">
<form method="get" name="form1">Please enter search term: <input
name="search_term" value=""><br>
<br>
<input type="button" name="Submit" value="Submit"
onclick="submitMe()">
</form>
</div>
<div id="result_section"></div>
</body>
</html>