Re: [問題] Firefox3按下Submit後不會跳頁的問題

看板Ajax作者時間17年前 (2008/07/16 18:19), 編輯推噓3(3011)
留言14則, 4人參與, 最新討論串2/2 (看更多)
已經有改過了一些,但還是有問題 所以又上來請教了 = =" 目前的情況是我把原先的document.all改成了document.getElementByTagName('XXX') 另外加了<form></form> 執行的結果是在網址列會顯示「abc.php?year_sel=2008&month_sel=5&submit=」 預設接在abc.php?後面的變數變成了year_sel及month_sel了?? 後面多了一個【&submit=】 但還是不會跳頁就是了 且firebug有出現sely is undefined的訊息 >"< 還請高手指教一下 (小弟是JS的新手) 下面是改了一點的程式碼... ※ 引述《whk ()》之銘言: : ==========================我是第一段程式===修改了一點================= : //取得所選取的年及月份的JS,及按下submit時接在abc.php後的網址(就是年+月) : <script type="text/javascript"> : function change_month() : { var sely=document.getElementsByTagName('year_sel'); var sely=document.getElementsByTagName('month_sel'); : var year=sely.options[sely.selectedIndex].value; : var month=selm.options[selm.selectedIndex].value; : windows.location.href="abc.php?presel_year="+year+"&presel_month="+month; : } : </script> : ==========================我是第二段程式===沒改============== : //取得所選取的年月,及預設的年月欄位值 : <? : $today=getdate(); : $this_month=$today['mon']; : $this_year=$today['year']; : //取得所選的年份資料 : if(isset($presel_year) && $presel_year!="") { : $now_year=$presel_year; : } else { : $now_year = $this_year; : } : ?> : <select name="year_sel"> : <? : //預設顯示"年份"的欄位值 : for($j=2007;$j<=$this_year;++$j) { : $default_year_string=$j==$now_year?"selected=\"selected\"":""; : echo "<option value=\"$j\" $default_year_string>$j 年</option>\n"; : } : ?> : </select> : <select name="month_sel"> : <? : //取得所選的月份資料 : if(isset($presel_month) && $presel_month!="") { : $now_month = $presel_month; : } else { : $now_month = $this_month; : } : //預設顯示月份的欄位值 : for($i=1; $i<=12; ++$i) { : $default_month_string=$i==$now_month?"selected=\"selected\"":""; : echo "<option value=\"$i\" $default_month_string>$i 月</option>\n"; : } : ?> : </select> : ==============================我是第三段程式===================== : <button name="submit" onClick="javascript:change_month()">確定</button> : 先謝謝回覆的版友! -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 220.133.108.182 ※ 編輯: whk 來自: 220.133.108.182 (07/16 18:41)

07/16 19:16, , 1F
你看看 http://tinyurl.com/6m3naz 能不能看懂?
07/16 19:16, 1F

07/16 19:16, , 2F
bytagname('xx')[0]要這樣 bytagname是傳回陣列
07/16 19:16, 2F

07/16 19:17, , 3F
Firebug 和 W3Schools 一天不用, 就會言語無味, 面目可憎...
07/16 19:17, 3F

07/16 19:19, , 4F
window.location=("XX")這樣看看
07/16 19:19, 4F

07/16 20:05, , 5F
echo "<option value=".$i." ".$default_month_string.">".
07/16 20:05, 5F

07/16 20:16, , 6F
雙引號不用隔開,sorry. 會不會是用到保留字
07/16 20:16, 6F

07/16 20:22, , 7F
windows.location may fail in firefox
07/16 20:22, 7F

07/16 20:23, , 8F
try to use document.location for instead.
07/16 20:23, 8F

07/17 00:23, , 9F
其實原本是用document.getElementById()的...然後把select也加
07/17 00:23, 9F

07/17 00:23, , 10F
上id, 但結果相同,也有用過document.href
07/17 00:23, 10F

07/17 00:25, , 11F
echo<option>那行確定是沒問題的.謝謝唷!
07/17 00:25, 11F

07/17 13:36, , 12F
window locatin的get參數不是你自己給的...跑出submit
07/17 13:36, 12F

07/17 13:36, , 13F
是什麼意思...
07/17 13:36, 13F

07/19 02:03, , 14F
解決了,謝謝大家的幫忙, 跑出submit是自己耍笨,哈
07/19 02:03, 14F
文章代碼(AID): #18VSiZuy (Ajax)
文章代碼(AID): #18VSiZuy (Ajax)