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

看板Ajax作者時間17年前 (2008/07/15 19:30), 編輯推噓3(304)
留言7則, 5人參與, 最新討論串1/2 (看更多)
我的網頁大概是有二個selection, 一個是年,一個是月份 二個selection選擇後,按下確定,就會跳到被選到的年月的網頁 目前在IE6&7 / FF2均能正確操作 但Firefox3按下submit後就完全沒動靜了 我初步的判斷是Javascript程式不符合FF3的格式 但又不知道怎麼改? 所以來問一下,看有沒有高手願意指點我一下... 3段的片段的程式碼大致如下 含有部份的php程式碼... 註解仍用 // 代表 (抱歉不會用顏色 = =") ==========================我是第一段程式=================================== //取得所選取的年及月份的JS,及按下submit時接在abc.php後的網址(就是年+月) <script type="text/javascript"> function change_month() { var sely=document.all['year_sel']; var selm=document.all['month_sel']; var year=sely.options[sely.selectedIndex].value; var month=selm.options[selm.selectedIndex].value; 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/15 19:31)

07/15 19:33, , 1F
FF好像不能用all這種語法 我印象中拉
07/15 19:33, 1F

07/15 19:34, , 2F
還是用id getelementbyid這樣比較好
07/15 19:34, 2F

07/15 19:41, , 3F
我查了一下是location.href要改成window.location
07/15 19:41, 3F

07/15 20:01, , 4F
document.all 是 IE專有
07/15 20:01, 4F

07/15 22:40, , 5F
請愛用firebug
07/15 22:40, 5F

07/15 23:59, , 6F
謝謝各位,小弟研究看看...
07/15 23:59, 6F

07/16 00:22, , 7F
document.all['xxx'] => document.getElementById('xxx')
07/16 00:22, 7F
文章代碼(AID): #18V8f8t_ (Ajax)
文章代碼(AID): #18V8f8t_ (Ajax)