Home > Backend Development > PHP Tutorial > 在下php小白请大牛指教!我写的这个按钮跳转怎么无效啊。急

在下php小白请大牛指教!我写的这个按钮跳转怎么无效啊。急

WBOY
Release: 2016-06-20 12:42:49
Original
1084 people have browsed it

nbsp;html>




 
 <script> <br />function func(){ <br /> location.href='products.php'; <br /> } <br /> <br /></script>
 

 
 

 
    
    
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
          
          
          
          
          
          
        
        
         
        
        
     
水果售货标记
编号 名称 规格 价格 剩余量 网址
1 苹果 箱/40元 10元/斤 20斤 www.huamin.com
2 桔子 框/100元 5元/斤 60斤 www.huamin.com

        
      
        

 



 


回复讨论(解决方案)


点击后不仅仅执行func(),还会提交表单,这样就造成func()无法执行,因为一旦提交表单就会刷新页面。建议你写在form里 即:

试了还不行啊,还是无法跳转到指定页面…

onsubmit="return false;" form属性

<!doctype html><html><head><meta charset="utf-8"><link rel="stylesheet" type="text/css" href="table_style.css"><title> </title> <script type="text/javascript">/*function func(){ location.href='products.php';}*/</script> </head> <body> <form name="form1" method="post" action="products.php"> <table  >    <caption><strong>水果售货标记</strong></caption>    <tbody>        <tr>        <th width="36">编号</th>        <th width="37">名称</th>        <th width="61">规格</th>        <th width="54">价格</th>        <th width="53">剩余量</th>        <th width="111">网址</th>        </tr>        <tr>        <td>1</td>        <td>苹果</td>        <td>箱/40元</td>        <td>10元/斤</td>        <td>20斤</td>        <td>www.huamin.com</td>        </tr>        <tr>          <td>2</td>          <td>桔子</td>          <td>框/100元</td>          <td>5元/斤</td>          <td>60斤</td>          <td>www.huamin.com</td>        </tr>        <tr>        <td colspan="6">       <input type='submit' name='button' id='button' value='提交'  >               </td>         </tr>        </tbody>     </table> </form></body></html>
Copy after login

function func(){
 location.href='products.php';
  return false;
}

 

可以把type="submit" 改成type="button" 就不会提交了

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template