Jump to content

I need Help in writing Javascript to Open and Play music in iTunes by clicking a Submit button


kingamada

Recommended Posts

Morning to you Master of Java Programming.

My name is King Amada, with basic knowledge of HTML and Javascript.

I want to Create a javascript button, that onclick it will open itunes and play music, i am using Mac OSX 10.8.2, and have safari browser to test my website. and i want to validate my form, i want the user not be able to submit the form without filling in all the fields, and selecting the platform, and last but not least, i want if the user select wimac, to open another music file, if wimob to open another one, please help me out.

this is my code below, help me out please?

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" ""]http://www.w3.org/TR...nsitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml%22>"]http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /><title>Untitled Document</title><style type="text/css">#apDiv1 {position: absolute;width: 200px;height: 331px;z-index: 1;left: 189px;top: 121px;font-style: oblique;font-weight: lighter;color: #999;background-image: url(../../Downloads/back_to_the_mac.jpg.png);}#apDiv2 {position: absolute;width: 200px;height: 56px;z-index: 2;font-size: 18px;left: 0px;top: 82px;}</style><script type="text/javascript">function MM_validateForm() { //v4.0 if (document.getElementById){ var i,p,q,nm,test,num,min,max,errors='',args=MM_validateForm.arguments; for (i=0; i<(args.length-2); i+=3) { test=args[i+2]; val=document.getElementById(args[i]); if (val) { nm=val.name; if ((val=val.value)!="") { if (test.indexOf('isEmail')!=-1) { p=val.indexOf('@'); if (p<1 || p==(val.length-1)) errors+='- '+nm+' must contain an e-mail address.\n'; } else if (test!='R') { num = parseFloat(val); if (isNaN(val)) errors+='- '+nm+' must contain a number.\n'; if (test.indexOf('inRange') != -1) { p=test.indexOf(':'); min=test.substring(8,p); max=test.substring(p+1); if (num<min || max<num) errors+='- '+nm+' must contain a number between '+min+' and '+max+'.\n'; } } } else if (test.charAt(0) == 'R') errors += '- '+nm+' is required.\n'; } } if (errors) alert('The following error(s) occurred:\n'+errors); document.MM_returnValue = (errors == '');} }</script></head><body background="../../Downloads/back_to_the_mac.jpg.png"><div id="apDiv1"> <table width="200" height="331" border="0"> <form id="form1" name="form1" method="get" action="../../Movies/Music Videos/Michael Jackson - Dirty Diana - YouTube.FLV"> <tr> <th width="107" scope="col" align="left">WiName:</th> <th width="77" scope="col"> <label for="WName"></label> <input type="text" name="WName" id="WName" tabindex="1" size="15"/> </th> </tr> <tr> <th scope="row" align="left">WiKey:</th> <td><label for="Wkey"></label> <input type="Password" name="Wkey" id="Wkey" tabindex="2" size="15" /></td> </tr> <tr> <th scope="row"> </th> <td><div id="apDiv2" align="center"><hr />Platform<hr /></div></td> </tr> <tr> <th scope="row" align="left">WiMob:</th> <td><input type="radio" name="radio" id="Mob" value="Mob" tabindex="3" /> <label for="Mob"></label></td> </tr> <tr> <th scope="row" align="left">WiWin:</th> <td><input type="radio" name="radio" id="Win" value="Win" tabindex="4" /> <label for="Win"></label></td> </tr> <tr> <th scope="row" align="left">WiMac:</th> <td><input type="radio" name="radio" id="Mac" value="Mac" tabindex="5" /> <label for="Mac"></label></td> </tr> <tr> <th scope="row"> </th> <td><input name="Submit" type="submit" id="Submit" tabindex="6" onclick="MM_validateForm('WName','','R','Wkey','','R');return document.MM_returnValue" value="Submit" /></td> </tr> </form> </table></div></body></html>

Link to comment
Share on other sites

  • 2 weeks later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...