开发者

append Selectbox value to textbox on body load

I am working on dynamic page.

Using {$pagetitle} smarty tag I get selectbox something like this.

<select name="page">
<option value="page1" title="Page1">Page1</option>
<option value="page2" title="Page2" selected>Page2</option>
<option value="page3" title="page3">Page3</option>
<option value="page4" title="Page4">Page4</option>
</select>

I can not have selectbox id as this is automatically generated through {smarty} tag

I want to append value of previously selected option to the textbox below on body load.

<input type="text" value"" id="pageno" />

How can I achieve this using JQuery?

Thank开发者_运维问答s


You just need to query the select by name instead of id:

$(document).ready(function() {
    $('#pageno').val($('select[name="page"]').val());
});

See it in action at jsfiddle.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜