Jump to content

Why Doesn't This Script Work?


SuperPaperSam
 Share

Recommended Posts

It should play the flash file that was selected but for some reason it's not working. :)Please tell me how to fix it (or at least point out the problem) :]

<html>	<head>		<script type="text/javascript">			function file() {				var file = document.getElementById("file").value;			}			function width() {				var width = document.getElementById("width").value;			}			function height() {				var height = document.getElementById("height").value;			}		</script>	</head>	<body>		<form method="post" name="flashplayer">			<label>Flash Content: 				<input type="file" name="file" id="file">			</label><br><br>			<label>Width: 				<input name="width" type="text" id="width" value="800">			</label><br><br>			<label>Height: 				<input name="height" type="text" id="height" value="500">			</label><br><br>			<input type="button" name="sender" value="Play Flash Content" onclick="file();width();height();"/>		</form>		<embed src="file()" width="width()" height="height()" quality="high" pluginspage="http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash" type="application/x-shockwave-flash"></embed>	</body></html>

Thanks a MILLION!

Edited by SuperPaperSam
Link to comment
Share on other sites

This probably won't help, but the right way to label fields is:<label for="width">Width:</label><input type="text" id="width" />

Link to comment
Share on other sites

Hm...can you string onclicks like that? Try creating one function that calls all three, or at the end of one function, tag on a line that fires the next, then in the second one that fires the third. Just in case you can only have one onclick function.

Edited by chibineku
Link to comment
Share on other sites

I just tryed that and it's still not working.I'm pretty sure it has to deal with this line...

<embed src="file()" width="width()" height="height()" quality="high" pluginspage="http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash" type="application/x-shockwave-flash"></embed>

Can I insert the functions like this?

src="file()" width="width()" height="height()"

Any help would be very nice ;]

Link to comment
Share on other sites

this works in firefox, just need workaround for it to work in crappy IE, as usual<html> <head> <script type="text/javascript"> var file, width, height; </script> </head> <body> <form method="post" name="flashplayer"> <label>Flash Content: <input type="file" name="file" id="file"> </label><br><br> <label>Width: <input name="width" type="text" id="width" value="800"> </label><br><br> <label>Height: <input name="height" type="text" id="height" value="500"> </label><br><br> <input type="button" name="sender" value="Play Flash Content" onClick="returnall()"/> </form> <script type="text/javascript"> var file, width, height; function returnall() { file = document.getElementById("file").value; width = document.getElementById("width").value; height = document.getElementById("height").value; var swfcontainer=document.getElementById("swfcontainer"); var obj=document.getElementById("objectvalues"); var movieparam=document.getElementById("parammovie"); swfcontainer.style.display=""; obj.setAttribute('height', height); obj.setAttribute('width', width); obj.setAttribute('data', file); //movieparam.setAttribute('value', file); movieparam.value=file;}</script><div id="swfcontainer" style="display:none;"><object height="800" width="600" data="" type="application/x-shockwave-flash" id="objectvalues"><param name="movie" value="" id="parammovie"/></object></div> </body></html>

Edited by dsonesuk
Link to comment
Share on other sites

or: (but still! will not work in useless IE)<!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=iso-8859-1" /><title>Untitled Document</title></head> <body> <form method="post" action="java script:void(null)" name="flashplayer" id="flashplayer"> <label>Flash Content: <input type="file" name="file" id="file" /> </label><br /> <br /> <label>Width: <input name="width" type="text" id="width" value="800" /> </label><br /> <br /> <label>Height: <input name="height" type="text" id="height" value="500" /> </label><br /> <br /> <input type="button" name="sender" value="Play Flash Content" onclick="returnall()"/> </form><script type="text/javascript">/*<![CDATA[*//*---->*/ var file, width, height; function returnall() { filex = document.getElementById("file").value; widthx = document.getElementById("width").value; heightx = document.getElementById("height").value; var = swfcontainer=document.getElementById("swfcontainer");swfcontainer.innerHTML="\n<object type=\"application/x-shockwave-flash\" data=\""+filex+"\" height=\""+heightx+"\" width=\""+widthx+"\">\n<param name=\"movie\" value=\""+filex+"\" />\n</object>\n";}/*--*//*]]>*/</script> <div id="swfcontainer"> </div> </body></html>

Edited by dsonesuk
Link to comment
Share on other sites

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
 Share

×
×
  • Create New...