Click to See Complete Forum and Search --> : building a window from user data


stewie
01-17-2003, 01:58 PM
my goal is to build a generic popup window which will play one of 30 movie files. i want the user to click on their choice and the movie play in a popup. the code i have for the window building itself works but im hung up on how to pass the info from the user click into the html of the window im building so the appropriate movie plays. that filename goes in 2 places in the window (i have 2 plus signs "++" there for now).

should i be thinking array?

any help would be very cool. im braindead. ill put my code below this.
thanks

<html>
<head>
<SCRIPT language="javascript">

function openmovie() {
var OpenWindow=window.open("","newwin","height=380,width=400");
OpenWindow.document.write("<html>")
OpenWindow.document.write("<head>")
OpenWindow.document.write("<title></title>")
OpenWindow.document.write("</head>")
OpenWindow.document.write("<body bgcolor='#1A304D' link='#FFFFFF' vlink='#FFFFFF' alink='#FFFFFF' topmargin='10' text='#FFFFFF'>")
OpenWindow.document.write("<center>")
OpenWindow.document.write("<OBJECT ID='MediaPlayer1' classid='CLSID:22D6F312-B0F6-11D0-94AB-0080C74C7E95' codebase='http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=5,1,52,701' standby='Loading Microsoft Windowsr Media Player components...' type='application/x-oleobject'>")
OpenWindow.document.write("<PARAM NAME='AutoStart' VALUE='True'>")
OpenWindow.document.write("<PARAM NAME='FileName'")
OpenWindow.document.write(" VALUE=' ++ '><PARAM NAME='ShowControls' VALUE='True'><PARAM NAME='ShowStatusBar' VALUE='True'>")
OpenWindow.document.write("<EMBED type='application/x-mplayer2'")
OpenWindow.document.write(" pluginspage='http://www.microsoft.com/Windows/MediaPlayer/'")
OpenWindow.document.write(" SRC=' ++ '")
OpenWindow.document.write(" name='MediaPlayer1'")
OpenWindow.document.write(" width=320")
OpenWindow.document.write(" height=240")
OpenWindow.document.write(" autostart=1")
OpenWindow.document.write(" showcontrols=1")
OpenWindow.document.write(" statusbar=1>")
OpenWindow.document.write("</EMBED></OBJECT>")
OpenWindow.document.write("<br><br>")
OpenWindow.document.write("<a href='' onClick='self.close()'>Close Window</a>")
OpenWindow.document.write("</center>")
OpenWindow.document.write("</body>")
OpenWindow.document.write("</html>")
}
</SCRIPT>
</head>
<body>
<a href='' onClick="openmovie()">217</a><br>
<a href='' onClick="openmovie()">218</a><br>
</body>
</html>

Webskater
01-17-2003, 02:14 PM
Instead of writing all the code for the pop-up window on the main page you could just write all the relevant code on a separate page - let's call it showmovie.htm

When someone clicks on a link on the main page you pass the file name into the function and then send it as a parameter to the pop-up window.

function openmovie(filename)
{
window.open("showmovie.htm?filename=" + filename,"newwin","height=380,width=400");
}

stewie
01-17-2003, 03:25 PM
so the dummy page sits on the server as a seperate document. what do i replace those ++ with so that the code knows to put the filename the user clicks there instead of the ++.

still pretty new to this, this part im unfamilliar with:

showmovie.htm?filename=" + filename

maybe i need a better book!!

stewie
01-17-2003, 07:11 PM
ok, i've figured out how to get my store the string i want, and i know it works cause i can get it to write itself on the page (the simple document.write i included to test it).

now i need it to write the exact same string in the popup i'm trying to build, both places. ive gotta be writing it wrong, im trying to use plus signs to return the output but im missing something. here is my code ill seperate the 2 lines that need the string inserted.

<html>
<head>
<SCRIPT language="javascript">
var s = new String("217_hestoosexyforhisfat.wmv");
var t = new String("218_epeterbusunim.wmv");
function openmovie(stringName) {
var OpenWindow=window.open("","newwin","height=380,width=400");
document.write(stringName)
OpenWindow.document.write("<html>")
OpenWindow.document.write("<head>")
OpenWindow.document.write("<title></title>")
OpenWindow.document.write("</head>")
OpenWindow.document.write("<body bgcolor='#1A304D' link='#FFFFFF' vlink='#FFFFFF' alink='#FFFFFF' topmargin='10' text='#FFFFFF'>")
OpenWindow.document.write("<center>")
OpenWindow.document.write("<OBJECT ID='MediaPlayer1' classid='CLSID:22D6F312-B0F6-11D0-94AB-0080C74C7E95' codebase='http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=5,1,52,701' standby='Loading Microsoft Windowsr Media Player components...' type='application/x-oleobject'>")
OpenWindow.document.write("<PARAM NAME='AutoStart' VALUE='True'>")
OpenWindow.document.write("<PARAM NAME='FileName'")


OpenWindow.document.write(" VALUE=' +stringName+ '><PARAM NAME='ShowControls'
VALUE='True'><PARAM NAME='ShowStatusBar' VALUE='True'>")


OpenWindow.document.write("<EMBED type='application/x-mplayer2'")
OpenWindow.document.write(" pluginspage='http://www.microsoft.com/Windows/MediaPlayer/'")


OpenWindow.document.write(" SRC=' +stringName+ '")


OpenWindow.document.write(" name='MediaPlayer1'")
OpenWindow.document.write(" width=320")
OpenWindow.document.write(" height=240")
OpenWindow.document.write(" autostart=1")
OpenWindow.document.write(" showcontrols=1")
OpenWindow.document.write(" statusbar=1>")
OpenWindow.document.write("</EMBED></OBJECT>")
OpenWindow.document.write("<br><br>")
OpenWindow.document.write("<a href='' onClick='self.close()'>Close Window</a>")
OpenWindow.document.write("</center>")
OpenWindow.document.write("</body>")
OpenWindow.document.write("</html>")
}
</SCRIPT>
</head>
<body>
<p onClick="openmovie(s)">217<br>
<p onClick="openmovie(t)">218<br>
</body>
</html>

if anyone can see what im doing wrong, pleeease tell me!!

thanks

stewie
01-17-2003, 07:36 PM
i got it. i can rest now.

if anyone cares, i forgot double quotations around my +stringName+

whew.