PDA

View Full Version : Changing page code from form.


CBrown
06-08-2005, 07:46 PM
Hey guys,

I have a problem here, I have this code:
<object codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=5,0,0,0" height="120" width="400">
<param name="movie" value="http://www.h2advanced.com/media/swf/signature_01.swf?playerName=VARIABLE">
<param name="quality" value="high">
<embed src="http://www.h2advanced.com/media/swf/signature_01.swf?playerName=VARIABLE" quality="high" pluginspage="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash" type="application/x-shockwave-flash" height="120" width="400">
</object>
that will display someone's halo 2 stats as long as the word VARIABLE is replaced with their gamertag. What I want to do is make a form with a text input field and a submit button so that a user can input their gamertag, push the button, and the thing comes up with their stats. All of my attempts have failed at this. Please help.

If you want to see what I tried to do on my own:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Frustrating little booger</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<script type="text/javascript">
function lookup(name)
{
document.write ('<object codebase=\"http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=5,0,0,0\" height=\"120\" width=\"400\"><param name=\"movie\" value=\"http://www.h2advanced.com/media/swf/signature_01.swf?playerName=' + name + '\"><param name=\"quality\" value=\"high\"><embed src=\"http://www.h2advanced.com/media/swf/signature_01.swf?playerName=' + name + '\" quality=\"high\" pluginspage=\"http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash\" type=\"application/x-shockwave-flash\" height=\"120\" width=\"400\"></object>');
}
</script>
</head>

<body>
<form name="form1" action="javascript:lookup(document.window.form1.text1.value);">
Gamertag:<input id="text1"></input><br>
<button type="submit" width="150" height"20">
</body>
</html>

</object>


thanks again,
Chris

_Aerospace_Eng_
06-08-2005, 09:50 PM
Something like this?
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Untitled Document</title>
<style type="text/css">
html,body {
margin:0;
padding:0;
height:100%;
background-color:#000000;
text-align:center;
}
form {
margin:0;
}
</style>
<script type="text/javascript">
function change(){
if(document.forms[0].thegame.value==''){
alert('Please enter a game name.');
}
else {
document.getElementById('thestats').innerHTML='<object '
+'type="application/x-shockwave-flash" data="http://www.h2advanced.com/media/swf/signature_01.swf?playerName='+document.forms[0].thegame.value+'" '
+'width="400" height="120">'
+'<param name="movie" value="http://www.h2advanced.com/media/swf/signature_01.swf?playerName='+document.forms[0].stats.value+">'
+'<param name="scale" value="noborder">'
+'</object>'
}
return false;
}
</script>
</head>

<body>
<span id="thestats">
<object
type="application/x-shockwave-flash" data="http://www.h2advanced.com/media/swf/signature_01.swf"
width="400" height="120">
<param name="movie" value="http://www.h2advanced.com/media/swf/signature_01.swf">
<param name="scale" value="noborder">
</object>
</span>
<form method="post" action="" onsubmit="return change()">
<input type="text" name="stats" size="30">
<input type="submit" value="Show">
</form>
</body>
</html>
I used the standards way to put flash on the page, its not to easy to access the embed or object tag while its on the page, so its easier to just rewrite it using innerHTML.