Can two identical forms exist on the same page of thinkPHP?

Source: Internet
Author: User
I submitted using ajax. Why can I submit data in the first form but cannot submit the data? after clicking submit, there is no response. the console does not report an error. The two forms are exactly the same. why? {Code ...} I submitted using ajax. Why can I submit data in the first form but cannot submit the data? after clicking submit, there is no response. the console does not report an error. The two forms are exactly the same. why?

var oBtn1=document.getElementById('btn1');var oTxt=document.getElementById('textarea');oBtn1.onclick=function(){  oV1=oTxt.value;  ajax("{:U('zhuye/zhuye')}",oV1,function(str){    if(str==1){      window.location.reload();    }  });}

Reply content:

I submitted using ajax. Why can I submit data in the first form but cannot submit the data? after clicking submit, there is no response. the console does not report an error. The two forms are exactly the same. why?

var oBtn1=document.getElementById('btn1');var oTxt=document.getElementById('textarea');oBtn1.onclick=function(){  oV1=oTxt.value;  ajax("{:U('zhuye/zhuye')}",oV1,function(str){    if(str==1){      window.location.reload();    }  });}

GetElementById: If you find the first qualified element, it will not continue to be executed. Therefore, if you have two IDs, you will always be able to get the content of the first form.

Isn't your textarea id repeated?

This is an obvious error. the element IDs in HTML should be unique.

ID is unique and cannot be repeated.

Id is unique on the same page

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.