javascript调用提交回发

I've read a lot of googling forums, but my simple sample still doesn't work. That is why I ask you to help me with my prob. I have page1 and page 2. I also have for debugging button (submit) in page1 and page2 with function header($direct). This part works and I have full understanding. But I cann't call full postback via javascript function. I don't know where is my fault. This is my union code for page1:

<?php
if (isset($_POST['btn']))
{
   header('Location: page2.php');
}
elseif (isset ($_POST['btn2']))
{
   header('Location: page2.php');
}
?>

<h1>This is page 1</h1>
<form id="form1" name="form1" method="post" action="<?php $_SERVER['PHP_SELF'] ?>">
   <input type="submit" name="btn" value="submit: goto page2"/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<input type="button" name="btn2" id ="btn2" value="button: goto page2" onclick="postback();" />
</form>

<script type="text/javascript">
   function postback(){
 var f = document.getElementById('form1');
f.submit();
   }
</script>



I want to call full postback without ajax because with ajax I have no problems. In last example I tried to call javascript postback with selection object and I couldn't any problems with it. But now, when I try to use simple button onclick event it still doesn't work. why? I hope you understand my English and point me to my faults. Thank you in advance

input type button will not show value in post

if you want to pass anything into post try input type=hidden

try this

<input type="submit" name="btn2" id ="btn2" value="button: goto page2" onclick="postback();" />

make type as submit it worked for me

The problem is in your statement. Your action statement is: php $_SERVER['PHP_SELF'] ... You need to put echo in there so PHP knows to echo the variable: echo $_SERVER['PHP_SELF']

It's always the little things.