Jump to content

aloha

Members
  • Posts

    3
  • Joined

  • Last visited

aloha's Achievements

Newbie

Newbie (1/7)

0

Reputation

  1. I inserted the following javascript to verify my form inputs with <form method onsubmit="return(chkForm())" ......>. THe AJAX script works properly and returns an alert message when the data submitted are the same as that saved in the database. The AJAX will reset the form and return false to the form. But the form continues to submit data to the CGI script. How do we stop the script from submitting in the above scenario? function chkForm() { var album = document.swapForm.album; var title = document.swapForm.title; var artist = document.swapForm.artist; var input = document.swapForm.file; if (input.value == "" || album.value == "" || title.value == "" || artist.value == "") { if (album.value == "") { alert("Please enter the album title!"); album.focus(); return(false); } if (title.value == "") { alert("Please enter the music or song title!"); title.focus(); return(false); } if (artist.value == "") { alert("Please enter the artist's name!"); artist.focus(); return(false); } if (input.value == "") { alert("Please submit an MP3 file for swapping!"); input.focus(); return(false); } else { var str = input.value; if (str.indexOf(".mp3") == -1) { alert("Invalid file format!"+"\n"+"We accept only MP3 music file!"); input.focus(); return(false); } } } else { xmlHttp = GetXmlHttpObject(); if (xmlHttp == null) { alert("Browser does not support HTTP request!"); return; } var url = "chkdata"; url = url+"?album="+album.value+"&title="+title.value+"&artist="+artist.value; xmlHttp.onreadystatechange = stateChanged; xmlHttp.open("GET", url, true); xmlHttp.send(null); }}function stateChanged() { if (xmlHttp.readyState == 4 || xmlHttp.readyState == "complete") { var note = xmlHttp.responseText; if (note == "") { return(true); } else { document.getElementById("swapForm").reset(); alert(note); return(false); } }}function GetXmlHttpObject(handler) { var objXMLHttp = null; if (window.XMLHttpRequest) { objXMLHttp = new XMLHttpRequest(); } else if (window.ActiveXObject) { objXMLHttp = new ActiveXObject("Microsoft.XMLHTTP"); } return objXMLHttp;}
  2. Thank you very much for referring me to a fine resource!
  3. Aloha:When you move your mouse over an MP3 file, you will see a box showing the file's labels such as Artist, Album Title, Track Number and Size, etc. If we upload the MP3 file using <input type=file name=upload>, can we use JavaScript to extract the above labels? How can that be done? If it cannot be done with JavaScript, is there any way to extract the labels with a server script?Thank you for any advice! Cheers!
×
×
  • Create New...