作者whk ()
看板Ajax
標題Re: [問題] Firefox3按下Submit後不會跳頁的問題
時間Wed Jul 16 18:19:14 2008
已經有改過了一些,但還是有問題
所以又上來請教了 = ="
目前的情況是我把原先的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)
2F:推 tn801534:bytagname('xx')[0]要這樣 bytagname是傳回陣列 07/16 19:16
3F:→ KC73:Firebug 和 W3Schools 一天不用, 就會言語無味, 面目可憎... 07/16 19:17
4F:推 tn801534:window.location=("XX")這樣看看 07/16 19:19
5F:→ asdosx:echo "<option value=".$i." ".$default_month_string.">". 07/16 20:05
6F:→ asdosx:雙引號不用隔開,sorry. 會不會是用到保留字 07/16 20:16
7F:→ asdosx:windows.location may fail in firefox 07/16 20:22
8F:→ asdosx:try to use document.location for instead. 07/16 20:23
9F:→ whk:其實原本是用document.getElementById()的...然後把select也加 07/17 00:23
10F:→ whk:上id, 但結果相同,也有用過document.href 07/17 00:23
11F:→ whk:echo<option>那行確定是沒問題的.謝謝唷! 07/17 00:25
12F:推 tn801534:window locatin的get參數不是你自己給的...跑出submit 07/17 13:36
13F:→ tn801534:是什麼意思... 07/17 13:36
14F:→ whk:解決了,謝謝大家的幫忙, 跑出submit是自己耍笨,哈 07/19 02:03