PDA

View Full Version : Strange form submit problem


GreatKent
03-24-2005, 12:00 PM
Does anybody know why the following form submit code works in single page but does NOT work in frames?



<html>
<head>
<title>Kent is Great!</title>

</head>
<body>
<form method="POST" action="http://www.dreye.com/tw/vip/viplogin.phtml" target="_self" name="viploginForm">
<input type="hidden" name="r_account" value="kent_web">
<input type="hidden" name="r_password" value="abc">
</form>

<script language="JavaScript">
document.viploginForm.submit();
</script>

</body>
</html>

_Aerospace_Eng_
03-24-2005, 02:43 PM
depends on where that form is when its in the frameset

GreatKent
03-24-2005, 05:20 PM
I place the Form in the body of one of the frames page. Where shoudl place to make it work? Thx!!

_Aerospace_Eng_
03-24-2005, 05:27 PM
you may need to have a function in that page that gets called with body onload, and i've known some scripts wont work if you dont have the correct declartions, change this
<script language="JavaScript">
document.viploginForm.submit();
</script>
to this
<script type="text/javascript"><!--
function submitform(){
document.viploginForm.submit();
}
//-->
</script>
and put it in your head tags, and then use the onload to call it so your page should look like this
<html>
<head>
<title>Kent is Great!</title>
<script type="text/javascript"><!--
function submitform(){
document.viploginForm.submit();
}
//-->
</script>
</head>
<body onload="submitform()">
<form method="POST" action="http://www.dreye.com/tw/vip/viplogin.phtml" target="_self" name="viploginForm">
<input type="hidden" name="r_account" value="kent_web">
<input type="hidden" name="r_password" value="abc">
</form>
</body>
</html>

GreatKent
03-28-2005, 02:05 AM
Thank you VERY much!!!!:) It works now:D

By the way, may i ask one more question:
I have added an onUnload function to the above html, but if it is put in a frame, the onUnload function is not executed, any idea?

_Aerospace_Eng_
03-28-2005, 02:18 AM
its gotta be on the actual frameset page, well at least im guessing this is what you want when the user leaves your site completely, and since you can't have a body onload in the frameset page because it will only be called if the user doesn't have a browser that can show frames. Put this in the head tags of your frameset page
<script type="text/javascript">
function alertme(){
alert('blah');
}
window.onunload=alertme;
</script>
you can change the function to what you want it to do, just take note of the window.onunload=alertme; this will change as your function name changes. I dont know why but Internet Explorer doesn't seem to support the onunload if the browser is closed, but it will work if the user navigates away from the frameset

GreatKent
03-28-2005, 10:22 PM
the window.onunload=alertme seems not to be working in frame set page in my IE, but anyway, I can put every in one page and it works perfectly! Again, thank a lots.......:)