Please Help - Form Behaviour in IE

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have a form located at the bottom of a php page.
My form has 3 buttons that are used to perform calculations. When the user
clicks on any of those three buttons, the calculations are performed BUT the
page refreshes and scrolls back up to the top.

How do I stop the refresh and the scroll?
 
Hi Jen,

It would be helpful if you could supply a URL to your php page so that we
can have a look.

Not seeing the code, I would guess that you need to place your form on its
own php page and display it within an iframe on the php page you are using
now.

I think what is happening is that your form is Posting (or getting) to
itself (<form target="_self">) which pushes the form results back out to the
same window sorta emulating a page refresh, but without a bookmark the
browser stops at the top of the page instead of scrolling to the bottom.

Oh, you could try placing a bookmark in your Action url eg.
Action=http://myserver/Processmyform.php#MyForm
 
Rob Parsons said:
Hi Jen,

It would be helpful if you could supply a URL to your php page so that we
can have a look.

Not seeing the code, I would guess that you need to place your form on its
own php page and display it within an iframe on the php page you are using
now.

I think what is happening is that your form is Posting (or getting) to
itself (<form target="_self">) which pushes the form results back out to the
same window sorta emulating a page refresh, but without a bookmark the
browser stops at the top of the page instead of scrolling to the bottom.

Oh, you could try placing a bookmark in your Action url eg.
Action=http://myserver/Processmyform.php#MyForm




Hi, Rob. I have not gone live yet, so can I post the code here?
 
Rob Parsons said:
Hi Jen,

It would be helpful if you could supply a URL to your php page so that we
can have a look.

Not seeing the code, I would guess that you need to place your form on its
own php page and display it within an iframe on the php page you are using
now.

I think what is happening is that your form is Posting (or getting) to
itself (<form target="_self">) which pushes the form results back out to the
same window sorta emulating a page refresh, but without a bookmark the
browser stops at the top of the page instead of scrolling to the bottom.

Oh, you could try placing a bookmark in your Action url eg.
Action=http://myserver/Processmyform.php#MyForm




Hi, Rob.. I actually do have a bookmark .
 
Hi again Jen,
Do you have a URL we can have a look at. Have your tried using an iframe?
 
Hi, Rob... No, I do not have a URL since I have not gone live yet. I am
posting the code here so you can take a look. What I have done is to use a
named anchor to stop the scroll back to the top but IE still refreshes every
time the user clicks on a button. I have not tried IFrames yet, but will do
so. In the meantime, can you please load the code and test it yourself?
What I am sending you is a very simplified version of the actual code.
You'll see that there are two forms- one is being called as a function and
the other is not. Both form actions refresh the IE browser. Do I have to
use IFrames to stop this or is there another way?

<HTML>
<HEAD>
<TITLE>
test
</TITLE>
</HEAD>

<body>
<!--DWLayoutTable-->

<tr>
<td id="container" align="left">

<div id="status">
<span>text:</span><span class="stat1">text</span><br />
<span class="stat2">sometext:</span><span class="stat3"></span>
</div>

<div align="right" id="status1">
<span><a href="SampleTemp.htm">more text?</a></span>
</div>
</td>
</tr>

<tr><td>
<div align="left" id="em">
<form action="text.php5" method="post" style="width:275px; ">
<span class="style1">text <br />text & text!</span>
<input value="(e-mail address removed)" align="top" type="text" name="email" />
<input class="a" type="submit" align="top" name="submit" value="OK!" />
</form>

<a href="http://text.com" ><img src="text/h1.gif"/></a>
<a href="text.htm" ><img src="text/x.gif"/></a>
<a href="text.htm" ><img src="text/f.gif"/></a>
<a href="text.htm" ><img src="text/p.gif"/></a>
<a href="text.htm" ><img src="text/c.gif"/></a>
<a href="text.htm" ><img src="text/t.gif"/></a>
<a href="text.htm" ><img src="text/b.gif"/></a>
<a href="text.htm" ><img src="text/co.gif"/></a>

</div>
</td>
</tr>

<tr class="tr1">
<td>
<table width="750" align="center" class="tb2">
<tr><td align="left" valign="top">
<div id="linklist" style="margin:0px 15px 0px 15px; height:auto;">
<p>text texttext texttexttext text <em>AND</em> text <strong>text text
texttext</strong>? text texttext texttexttext text text texttext texttexttext
texttext texttext texttexttext texttext texttext texttexttext texttext
texttext texttexttext texttext texttext texttexttext texttext texttext
texttexttext texttext texttext texttexttext texttext texttext texttexttext
text <strong>text texttext texttexttext texttext texttext texttexttext
text</strong>. text texttext texttexttext texttext texttext texttexttext
texttext texttext texttexttext texttext texttext texttexttext texttext
texttext texttexttext text </p>
<span id="1" style="color:#CC0000; height:auto;">text texttext texttexttext
text<strong>text texttext texttexttext texttext texttext texttexttext
texttext texttext texttexttext texttext texttext texttexttext texttext
texttext texttexttext texttext texttext texttexttext texttext texttext
texttexttext texttext texttext texttexttext texttext texttext texttexttext
texttext texttext texttexttext texttext texttext texttexttext texttext
texttext texttexttext texttext texttext texttexttext texttext texttext
texttexttext texttext texttext texttexttext texttext texttext texttexttext
texttext texttext texttexttext texttext texttext texttexttext texttext
texttext texttexttext texttext texttext texttexttext texttext texttext
texttexttext texttext texttext texttexttext text</span>
<ul>
<li id="bullet">text texttext texttexttext text</li>
<li id="bullet">text texttext texttexttext text</li>
<li id="bullet">text texttext texttexttext text</li>
</ul>
<span id="1" style="color:##CC0000; ">text texttext texttexttext texttext
texttext texttexttext text</span>
<ul style=" margin-top:3px; padding-left:35px; color:#333333;
vertical-align:text-top; ">
<li id="bullet3">text texttext texttexttext texttext texttext texttexttext
texttext texttext texttexttext text
</li>
<li id="bullet3"> text texttext texttexttext texttext texttext texttexttext
texttext texttext texttexttext texttext texttext texttexttext text <span
class="style2"> text texttext texttexttext texttext texttext texttexttext
text</span> text texttext texttexttext texttext texttext texttexttext
texttext texttext texttexttext text
</li>
<li id="bullet3" >text texttext texttexttext texttext texttext texttexttext
texttext texttext texttexttext texttext texttext texttexttext texttext
texttext texttexttext text<span class="style2">text texttext texttexttext
texttext texttext texttexttext texttext texttext texttexttext text</span>
text texttext texttexttext texttext texttext texttexttext texttext texttext
texttexttext texttext texttext texttexttext texttext texttext texttexttext
text
</li>
</ul>
<p>text texttext texttexttext texttext texttext texttexttext texttext
texttext texttexttext texttext texttext texttexttext texttext texttext
texttexttext texttext texttext texttexttext texttext texttext texttexttext
texttext texttext texttexttext texttext texttext texttexttext texttext
texttext texttexttext text</p>

<p>text texttext texttexttext texttext texttext texttexttext texttext
texttext texttexttext texttext texttext texttexttext texttext texttext
texttexttext texttext texttext texttexttext texttext texttext texttexttext
texttext texttext texttexttext texttext texttext texttexttext text</p>

<p>text texttext texttexttext texttext texttext texttexttext texttext
texttext texttexttext texttext texttext texttexttext texttext texttext
texttexttext texttext texttext texttexttext texttext texttext texttexttext
texttext texttext texttexttext texttext texttext texttexttext text </p>

<p id="bullet3" style="height:23px; width:144px "></p>
<span>text texttext texttexttext texttext texttext texttexttext texttext
texttext texttexttext text</span>

<CENTER>
<H1>Using Text Fields</H1>
<?php
$errors = array();

$action=$_SERVER['PHP_SELF']."#rh";


if(isset($_REQUEST["seen_already"])){

validate_data();
if(count($errors) != 0){
display_errors();
display_welcome();
}
else {
process_data();
}
}
else {
display_welcome();
}

function validate_data()
{
global $errors;
if($_REQUEST["Name"] == "") {
$errors[] = "<FONT COLOR='RED'>Please enter your name</FONT>";
}
}

function display_errors()
{
global $errors;

foreach ($errors as $err){
echo $err, "<BR>";
}
}

function process_data()
{
echo "Your name is ";
echo $_REQUEST["Name"];
}

function display_welcome()
{
global $action;
echo "<FORM METHOD='POST' ACTION=$action>";
echo "What's your name?";
echo "<BR>";
echo "<INPUT NAME='Name' TYPE='TEXT'>";
echo "<BR>";
echo "<BR>";
echo "<INPUT TYPE=SUBMIT VALUE=Submit>";
echo "<INPUT TYPE=HIDDEN NAME='seen_already' VALUE='hidden_data'>";
echo "</FORM>";
}

?><a name="rh" id="rh"></a><?
echo "<FORM METHOD='POST' ACTION=$action>";
echo "What's your name?";
echo "<BR>";
echo "<INPUT NAME='Name' TYPE='TEXT'>";
echo "<BR>";
echo "<BR>";
echo "<INPUT TYPE=SUBMIT VALUE=Submit>";
echo "<INPUT TYPE=HIDDEN NAME='seen_already' VALUE='hidden_data'>";
echo "</FORM>";
?>
</CENTER>
</BODY>
 
Back
Top