Submit form using a button outside the <form> tag

前端 未结 13 1455
南旧
南旧 2020-11-22 09:45

Say I have:

13条回答
  •  春和景丽
    2020-11-22 10:10

    This work perfectly! ;)

    This can be done using Ajax and with what I call: "a form mirror element". Instead to send a form with an element outside, you can create a fake form. The previous form is not needed.

    
    

    Code ajax would be like:

        
    

    This is very usefull if you want to send some data inside another form without submit the parent form.

    This code probably can be adapted/optimized according to the need. It works perfectly!! ;) Also works if you want a select option box like this:

    I hope it helped someone like it helped me. ;)

提交回复
热议问题