how to add assign the value and make an addition in javascript -
& lt; इनपुट नाम = "" प्रकार = "बटन" मान = "300" onclick = "document.all .t1.value = this.value "/ & gt; & Lt; input name = "t1" प्रकार = "text" id = "t1" /> gt; & lt; br / & gt; & Lt; input name = "" type = "बटन" मान = "400" onclick = "document.all.t2.value = this.value" / & gt; & Lt; input name = "t2" प्रकार = "text" id = "t2" /> gt; & lt; br / & gt; & LT; स्क्रिप्ट & gt; फ़ंक्शन जोड़ें () {document.getElementById ("T3") मान = मठ.फ्लूर (document.getElementById ("t1") मान) + Math.floor (document.getElementById ("t2")। मान); } & Lt; / script & gt; & Lt; input name = "" type = "बटन" मान = "जोड़ें" onclick = "add" / & gt; & Lt; input name = "t3" प्रकार = "text" id = "t3" / & gt; उपरोक्त कोड बुरा है, कुछ इसे सही करने की अपेक्षा करते हैं। धन्यवाद।
जब 300 पर क्लिक करें, पहले टेक्स्टबॉक्स में 300 ग्रास, 400 के समान, फिर बटन जोड़ें पर क्लिक करें। तीसरा पाठ बॉक्स shoew 700
आपका "ऑनक्लिक" इस तरह दिखना है:
& lt; इनपुट नाम = "" प्रकार = "बटन" मान = "जोड़" onclick = "add ()" / & gt; document.all के संदर्भ इंटरनेट एक्सप्लोरर के अलावा ब्राउज़र्स में काम नहीं करेंगे, इसलिए आपको उन लोगों को document.getElementById () का उपयोग करना चाहिए < / Code> इसके बजाय।
Comments
Post a Comment