开发者

jquery, changing form action

i cannot seem to find the answer to this. i uploaded code to pastebin (so wouldnt clutter up the post):

http://pastebin.com/BhnNTnJM

but the action only changes for the delete form (id=form-horse-delete) and not the other 2 forms located on the page. i am at my wits end trying to figure out why it doesn't work for the 2 forms, yet will work for the 1 form.

in IE, if i try and change the action of the 2 forms, it gives a javascript error. but if i take out the change, it works fine 开发者_开发问答with no javascript error.


You have an input field called action in the form-horse-update and form-horse-add forms. e.g.

<input type="hidden" name="action" value="add" />

action is kind of a reserved word, as having an input field with that name changes the behaviour of the form. Normally in JavaScript (let alone jQuery) a reference to something like:

document.myform.action

refers to the action attribute of the form. The minute you add an input field called action then instead the above would refer to the input element called action and there is no longer a way to access the form's action attribute.

The best solution is to rename your action input fields to something else (but probably best not to rename it to submit! ;) )

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜