Basically the php gives the javascript a list of movies located in my directory, I am able to successfully launch any movie not containing a "space." I changed the code a little bit to allow for a "text input" and manually typed the name of a movie with %20 instead of a space and it worked. So I would like to modify the above code to do this automatically without visibly changing the movie titles. I am not sure where I should change the code.
First of all thank you very much for your reply. I tried both (escape() and encodeURIComponent()) both for whatever reason made my document.write output /movies/undefined as apposed to /movies/movietitle. If anyone has any other ideas I would be great full. In the mean time I will continue googling for the solution.
First of all thank you very much for your reply. I tried both (escape() and encodeURIComponent()) both for whatever reason made my document.write output /movies/undefined as apposed to /movies/movietitle. If anyone has any other ideas I would be great full. In the mean time I will continue googling for the solution.
this is the from op post #1 and is the reason why i jump to conclusion that using document.getElementById('id4').value doesn't work. How it work before i have no idea,
Quote:
In any case, if you use sel.options[sel.selectedIndex] you will be getting an Option *object*.
You need to get either the .value or the .text of the Option:
Code:
sel.options[sel.selectedIndex].value
or
sel.options[sel.selectedIndex].text
yes, you are right about object vs. value/text, is my fault. Thank you,
But all modern browsers *DO* support getting the .value of a <select>.
Basically, you can do document.someSelect.value and it is the equivalent of doing document.someSelect.options[document.someSelect.selectedIndex].value
There were many browser back in the early days that did not support this, but MSIE introduced it (I think in MSIE 5) and current browsers all follow suit. Or at least all that I tested: MSIE, Firefox, Chrome.
__________________
An optimist sees the glass as half full.
A pessimist sees the glass as half empty.
A realist drinks it no matter how much there is.
I changed the code a little bit to allow for a "text input" and manually typed the name of a movie with %20 instead of a space and it worked. So I would like to modify the above code to do this automatically without visibly changing the movie titles. I am not sure where I should change the code.
There are a few functions you can use to encode special characters in a url.
I normally use encodeURI() unless I have to encode these chars as well - , / ? : @ & = + $ #. encodeURIcomponent() encodes these characters as well.
Parameter values in $_GET and $_POST are automatically decoded when they are received by your php script.
that of course required me to type the name into the box and that did work. But it also would require the %20 to be typed in instead of spaces. This also caused problems because I did not know what file extension my movies had. So I thought using a php script to grab the name of the movies would eliminate the need for needing to know the file extension and that worked great. However I am still having the %20 issue. That should answer your questions about "how did it ever work before." The script still does work, wonder if there is a way to re incorporate the "id4" value? Then just use escape(). I understand the escape() I have used it in the past but I am unfamiliar with the rest of the suggestions.
Thanks again for everyones help, hopefully I will get this figured out pretty soon.
Thanks again for all the suggestions, here is what I ended up doing
Code:
<script type="text/javascript">
var a=document.getElementById("id6").value;
var b=a.replace(/\s/g,"%20");
function ld(){
document.write("<html><!DOCTYPE HTML PUBLIC \"-\/\/W3C\/\/DTD HTML 4.01 Transitional\/\/EN\"http\:\/\/www.w3.org\/TR\/html4\/loose.dtd><html xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\" xml:lang=\"en\" lang=\"en\"><head><title>Darkapec Movie Player</title><script type=\"text\/javascript\" src=\"ss1.js\"><\/script><script type=\"text\/javascript\" src=\"fun1.js\"><\/script><\/head><body><h1>Darkapec Movie Player<\/h1><br/><embed type=\"application/x-vlc-plugin\" name=\"video1\" id=\"vlc\" autoplay=\"yes\" loop=\"no\" width=\"640\" height=\"480\" target=\""+b+"\"/><div id=\"nowt\"></div><div id=\"id1\"></div><div id=\"id2\"></div><script type=\"text\/javascript\" src=\"fun1.js\"><\/script><br/><input type=\"button\" onclick='pl()' value=\"Play\" /><input type=\"button\" onclick=\'ps()\' value=\"Pause\" /><input type=\"button\" onclick=\'st()\' value=\"Stop\" /><input type=\"button\" onclick=\'vlc.audio.toggleMute()\' value=\"Mute\" /><br/><b>width :</b><input type=\"text\" id=\"i1\"/><br/><b>height :</b><input type=\"text\" id=\"i2\"/><br/><input type=\"button\" onclick=\'aspectRatio()\' value=\"Adjust Screen\" />");
}
</script>
It just seemed to work the best. I kept running into issues with the escape().
Now I am looking at how to set this up so load directories or load multiple directories and populate the list. But that question is more for a PHP forum.
Thanks again guys for all your help I will definitely be back to this community.