javascript - How to update database thruogh dropdown without page reload -


कृपया इस कोड को पहले देखें:

  $ (document) .ready (function ( ($ ("# वैकल्पिक" [प्रकार = बटन])। प्रत्येक (फ़ंक्शन () {$ (this) .on ('click', function () {btnObj = $ (this); rowId = $ (this) attr ("rowId"); changestatus = $ (this) .attr ("changeStatus"); $ .get ("changeStatus.php? rowId =" + rowId + "& amp; बदलेंStatus =" + परिवर्तनस्थैटस, फ़ंक्शन (डेटा, स्थिति) {ifstatus == 0} {str = "unverify"; btnText = "verify"; newStatus = 1;} else {str = "सत्यापित करें"; btnText = "unverify"; newStatus = 0;} अगर (डेटा ==) 'सफलता') (चेतावनी ("स्थिति सफलतापूर्वक" +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ });});});}); & Lt; / स्क्रिप्ट & gt;   

यहां मेरा परिवर्तन स्थिति पृष्ठ है:

  $ dbhost = 'xxxxxx'; $ dbuser = 'xxxxxxx'; $ dbpass = 'xxx'; $ conn = mysql_connect ($ dbhost, $ dbuser, $ dbpass); यदि (! $ Conn) {मर ('कनेक्ट नहीं किया जा सका:'। Mysql_error ()); } mysql_select_db ('xxxxxxxx'); $ Sql ​​= "प्रयोग का परीक्षण अद्यतन सत्यापन करें"। $ _ प्राप्त करें ['परिवर्तनस्टैटस']। "जहां पंक्ति ="। $ _GET ['rowId']; $ रिवल्यूकल = माइस्किल_क्वेरी ($ sql, $ conn); अगर (! ($ रिटावल)) {मर ('त्रुटि'); } और {गूंजती "सफलता"; } Mysql_close ($ conn);   

मैं 0,1 मानों के साथ अपने डेटाबेस को क्वेरी करने के लिए इस कोड में एक बटन का उपयोग कर रहा था अगर एक बार दबाया जाता है, तो डेटाबेस 1 के साथ पूछताछ करता है, अगर फिर से दबाया जाता है, तो 0 के साथ क्वेरी की गई डेटाबेस।

अब, मुझे डेटाबेस के साथ 3 मानों के साथ बटन के स्थान पर एक ड्रॉपडाउन रखना होगा: 0,1,2 । यदि पहले मान चुना गया है, तो डेटाबेस पंक्ति को मान 0 और इसके साथ अपडेट किया जाना है।

मैं यह कैसे करूँ?

निकालें बटन को चुनें और इस तरह चुनें:

  & lt; class = "my-select" & gt; & lt; विकल्प मान = "0" & ​​gt; अपडेट & lt; / विकल्प & gt; & lt; विकल्प मान = "1" & gt; बनाएँ & lt; / विकल्प & gt; & lt; विकल्प मान = "2" & gt; हटाएं & lt; / विकल्प & gt; & Lt; / चयन & gt;   

आपको डेटा-पंक्ति आईडी विशेषता भी जोड़नी है।

jquery:

  $ (दस्तावेज़) .ready (फ़ंक्शन () {$ ("my-select")। परिवर्तन (फ़ंक्शन () {btnObj = $ (this); rowId = $ (this) .attr ("data-rowId"); changeStatus = $ (this) .val () ; $ .get ("changeStatus.php? rowId =" + rowId = "& amp; changeStatus =" + changeStatus, फ़ंक्शन (डेटा, स्थिति) {अगर (डेटा == 'सफलता') {चेतावनी ("स्थिति को सफलतापूर्वक अपडेट किया गया" str + "।");} अन्य {चेतावनी ("कुछ त्रुटि");}});});});    

Comments

Popular posts from this blog

Verilog Error: output or inout port "Q" must be connected to a structural net expression -

jasper reports - How to center align barcode using jasperreports and barcode4j -

c# - ASP.NET MVC - Attaching an entity of type 'MODELNAME' failed because another entity of the same type already has the same primary key value -