2013-04-22 95 views

回答

1

insert(document.getElementById('insertValue').value)應該這樣做。

但你的問題與ajax無關...

+0

感謝這是工作好:) – user2309096 2013-04-22 22:35:55

1

試試這個。

JS:

function insert(e){ 

myValue = document.getElementById('insertValue').value; 

// myValue is now set to the contents of the text field 'insertValue' 
// let's check it... 

alert(myValue); 

} 

HTML:

<input id="insertValue" type="text" /> 
<input type="button" value="Insert" onclick="insert(this)" /> 

我不明白,如果你也想在按鈕的值設置爲文本字段的內容。如果你想(並且沒有理由你需要),只需將它添加到JS函數中即可。

e.value = myValue; 
相關問題