1

I am try to make Qr code Generator.I have input filed there user enter URL of site and this URL goes in php file via Ajax and php file check validated and return URL link.this result pass into the jQuery('#output').qrcode(url); and result show in div.Problem is when Qr code set in div next time if user update url than again new Qr code generate and result is two different Qr cods.How can i Handel this when user update link than last Qr code image remove and updated Qr Code image show.

i am showing what i have done check my JavaScript and HTML code.

JavaScript

function grcodeg() {

      $(document).ajaxStart(function() {
        $("#qr-preview").html('<img src="editor/loader.gif"/>').show();
           $("#output").css("display","none").hide();})
        .ajaxStop(function() {
                $("#qr-preview").html('<img src="editor/loader.gif" />').hide();
                $("#output").css("display","block").show();
          });

        $("#qr-form").ajaxForm(function(url){        
               jQuery('#output').qrcode(url);
    }).submit();        

          }

HTML

<form action="editor/arcode_g.php" method="post" id="qr-form">
  <label for="url-qr">Link to a Website</label>
   <br>
     <input type="url" name="url-qr">
   <br>
      <label for="label-qr">Add QR Label</label>
         Describe what your QR code will do.
    <br>
         <input  type="text" name="label-qr">
     <br>
          <a onclick="grcodeg();">Ok</a>
      </form>

   <!----Qr Code Result------------->

    <div id="qr-preview"></div>
    <div id="output"></div>
3
  • I'm struggling a bit with your English. Could you get some help to clarify? Commented Nov 7, 2013 at 15:15
  • Sorry for my bad English Actually English is not my native language. Commented Nov 7, 2013 at 15:19
  • Understandable. No worries. Commented Nov 7, 2013 at 15:20

1 Answer 1

1

If I understand the question then you need to change this:

 $("#qr-form").ajaxForm(function(url){        
           jQuery('#output').qrcode(url);
}).submit(); 

to this:

 $("#qr-form").ajaxForm(function(url){        
          $("#output").html("");
           jQuery('#output').qrcode(url);
}).submit(); 

to clear the div before drawing into it again

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.