开发者

Submitting form with JavaScript on selector change

I have added some code to automatically submit the form when a selector is changed:

            <select name="template" id="templateselector" onchange='this.form.submit()'>
                {{foreach $templates as $t}开发者_运维知识库}
                    <option value="{{$t}}"{{if $t==$template}} selected="selected"{{/if}}>{{$t}}</option>
                {{/foreach}}
            </select>

The bracket tags come from my template engine.

When the page is first loaded, and an entry of the select list is selected, the form submits. It then pre-selects the selected item in the list (selected="selected").

But when the item is pre-selected, the on submit action no longer works. Why is that?


Because you are "changing" from an item to the same item, which isn't a change.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜