[問題] javascript改變form的action

看板Web_Design作者 (做個盾牌眼球兵吧)時間14年前 (2009/09/22 15:14), 編輯推噓1(100)
留言1則, 1人參與, 最新討論串1/1
現在有個form是這樣 <form id="tform" name="tform" method="POST" action="aaa.php"> <input name="action" type="hidden" id="action" value="additem" /> </form> 我要用javascript去改變表單送的地方 function sendform(sendto) { document.getElementById('tform').action=sendto; document.getElementById('tform').submit(); } 現在有問題了 form裡面有個hidden物件也叫action alert(document.getElementById('tform').action); 會顯示[object],也就是裡面那個物件 我要怎麼樣才能正確的修改form物件的action屬性? thx -- 羅達隆的王 ↘Ψ↙ 子阿薩斯要去斯坦索姆玩ya阿他們生病了殺光他們我不要我也不要Youa refiredIamf◢◆◣ired阿薩斯眉頭一皺,我們分手吧殺光他們羅達隆的王子阿薩斯殺光了 斯坦索姆 ㄟˇㄏ▌的居民發現故事30秒講不完。會替你們報仇的有了這個就IMBA了 我ROLL了99!管你的嘿嘿WhoamI?IamSpiderman阿薩斯變成了不良少年殺了很多人 他復◢◣∕█/︷\█﹨◢◣活了科爾蘇加德起來吧我的勇士為你而戰我的女…把薩菲隆便成 不死◥ ◥◣◥ ◤◢◤ ◤龍ya打敗了伊力丹你還沒準備好…終於成了巫… ψpm2001 -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 140.124.183.1

09/22 15:18, , 1F
getElementById('tform').setAttribute('action',sendto) 試試
09/22 15:18, 1F
文章代碼(AID): #1Ak7bLg2 (Web_Design)