2013-04-22 98 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; 
相关问题