2015-02-09 44 views
2
select: function(event, ui) { 
     spinstring = ui.item.label; 
} 

这是我的ajax select事件。我需要在相同的jsp页面中将spinstring的值发送到jsp表单。 如何发送?从ajax的select事件中获取值并将其传递给jsp表单

+0

是否要将该值设置为form:input元素?请明确说明 – 2015-02-09 06:41:07

+0

是的。我在jsp页面中有一个输入元素。我需要通过自旋字符串来设置此输入元素 - 来自ajax – 2015-02-09 07:50:10

+0

什么是行不通的? – 2015-02-09 08:21:39

回答

1

说,你有id

<input type="text" id="spin" /> 

然后你可以设置使用jQuery它的值作为

select: function(event, ui) { 
    spinstring = ui.item.label; 
    $(#spin).val(spinstring); 
} 

在纯JavaScript,你需要使用document对象的<input>场。

document.getElementById("spin").value = ui.item.label; 
+0

感谢您的回答。 – 2015-02-10 05:17:23

+0

现在工作正常 – 2015-02-10 05:18:08

相关问题