Hey,
I'm not sure which category to post this under since it involves both JavaScript and PHP, so I guess I'll just post it in both.
My problem is that I have this upload form where users can upload an .mp3 file. After the user uploads, they click on a link which takes them to a URL like the following: http://example.com/upload.php?file=p.../song/song.mp3
When the user click on the link, the information is processed and PHP outputs the path of the music file with the following code:
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">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>test</title>
<script language="javascript" type="text/javascript" src="../scripts/javascript_id3/binaryajax.js"></script>
<script language="javascript" type="text/javascript" src="../scripts/javascript_id3/id3.js"></script>
<script>
<?php $music_file = $_GET['file']; ?> //////////////////////////////////////
var file = "<?php echo "$music_file"; ?>"; /////////////////////////////////
function mycallback() {
title = ID3.getTag(file, "title");
artist = ID3.getTag(file, "artist") ;
album = ID3.getTag(file, "album") ;
year = ID3.getTag(file, "year") ;
genre = ID3.getTag(file, "genre");
track = ID3.getTag(file, "track") ;
comment = ID3.getTag(file, "comment");
}
ID3.loadTags(file, mycallback);
function declareID3Values() { //////////////////////////////////
document.getElementById("artist").value = (artist); /////////////////
document.getElementById("album").value = (album); ////////////////
document.getElementById("song").value = (title); //////////////////
}
</script>
<script>
if(DomCheck()){
DomCorners("uploaded_song_info","../images/rc_f1f1f1.png",10);
}
</script>
</head>
<body onload="declareID3Values();">
<div id="main_content">
<div id="uploaded_song_info" style="background-image:url(../images/F1F1F1.gif); width:450px;">
<h1>Song Info</h1>
<form name="music_info">////////////////////////////////
<p><label for="artist" id="info_label">Artist</label> <br /><input name="artist" id="artist" type="text" size="50" /></p>
<p><label for="artist" id="info_label">Album</label> <br /><input name="album" id="album" type="text" size="50" /></p>
<p><label for="artist" id="info_label">Song</label> <br /><input name="song" id="song" type="text" size="50" /></p>
</form>////////////////////////////////////////
</div>
</div>
</body>
</html>
JavaScript is then supposed to set the tag information to the corresponding value of the form fields. When user clicks on that link however, the tag info is not inserted into the fields at first. It works when I refresh the page, but for some strange reason it does not insert it when the page first loads.
I'll add that I'm using the GET method of submitting data.
Also, I know could use some code to force the page to refresh, but I'd rather not.
If someone could shed a little light on the subject, that would be great.
Thanks,
Moatist
__________________
Think in code; Dream in digital.
<?php if($helpfull == true){ $talkupation++; } ?>
Last edited by moatist; 07-07-2009 at 12:45 AM..
|