2012-02-13 38 views
2
<?=form_open('blog/register');?> 
      <table> 
       <tr> 
        <td><label for="register_name">Username : </label></td> 
        <td><input type="text" name="register_name" readonly="readonly" value="<?=$_POST['username']?>"/></td>      
       </tr> 
       <tr> 
        <td><label for="register_email">Email:</label></td> 
        <td><input type="text" name="register_email" readonly="readonly" value="<?=$_POST['email']?>"/></td>     
       </tr>     
       <tr> 
        <td><label for="register_password">Password:</label></td> 
        <td><input type="password" name="register_password" readonly="readonly" value="<?=$_POST['password']?>"/></td>     
       </tr>    
       <tr> 
        <td></td> 
        <td><input type="submit" value="Register" onclick="return true;"/></td> 
       </tr> 
       <tr> 
        <td></td> 
        <td>      
         <input type="button" value="Edit" onclick="window.location.replace('http://localhost/index.php?username='<?=$_POST['username']?>'&email='<?=$_POST['email']?>');return true;"/> 
        </td> 
       </tr> 
      </table> 
     <?=form_close()?> 

這是兩個按鈕作爲兩個選項的形式,註冊按鈕將用戶重定向到註冊屏幕,而第二個按鈕將指示他登錄屏幕。它不起作用,請問有人可以給我一個提示或任何指示嗎?2個按鈕一個表格

我點擊第二個按鈕,沒有任何反應。第一個按鈕正常工作

+0

什麼是 「它不工作」 是什麼意思?它現在做了什麼,你認爲它應該做什麼? – Bazzz 2012-02-13 09:50:50

+0

好吧,我更新它以獲得更好的清晰度 – user1211355 2012-02-13 09:52:14

+5

哦,天啊,那個標題... – xbonez 2012-02-13 10:03:14

回答

4

嘗試更換

<input type="button" value="Edit" onclick="window.location.replace('http://localhost/index.php?username='<?=$_POST['username']?>'&email='<?=$_POST['email']?>');return true;"/> 

<input type="button" value="Edit" onclick="window.location.href = 'http://localhost/index.php?username=<?=$_POST['username']?>&email=<?=$_POST['email']?>';return true;"/> 

我相信你有一些報價混爲一談。

爲了澄清,我刪除了圍繞你的PHP的單引號,因爲我相信他們沒有必要,並在你不想要的地方切斷你的位置字符串。 您的代碼生成的位置字符串是'http://localhost/index.php?username=',這是不正確的。

UPDATE
改變replace()href

+0

爲什麼你建議'替換()'http://w3schools.com/jsref/jsref_replace.asp他只使用一個參數...它應該是'windows.location.href =',不是? (只是問),我有一種感覺,你忘記'功能調用 – Vyktor 2012-02-13 10:05:08

+0

結束時,但它並沒有解決我的問題,我按第二個按鈕,它仍然是一樣的沒有什麼javascript方法被稱爲 – user1211355 2012-02-13 10:14:53

+0

@維克托,很好的建議,我改變了我的答案。 'href'的確是要走的路。我只是注意到了引號問題,並糾正了這個問題,但確實'replace'並不是正確的函數調用。請注意,這是user1211355所使用的,並非我的建議。 – Bazzz 2012-02-13 12:11:19

0

代碼替換

<input type="button" value="Edit" onclick="window.location.replace('http://localhost/index.php?username='<?=$_POST['username']?>'&email='<?=$_POST['email']?>');return true;"/> 

<input type="button" value="Edit" onclick="window.location.replace('http://localhost/index.php?username=<?=$_POST['username']?>&email=<?=$_POST['email']?>');return true;"/>