0

I've a sign up form which has submit button with value "GET INSTANT ACCESS!" :

<input type="submit" class="wf-button" name="submit" value="GET INSTANT ACCESS!">

After submit, the value gets change to 'Thank You!':

<input type="button" class="wf-button" value="Thank You!">

I need to detect the button value. If it becomes "Thanks You!" then I have to show a popup. And this value gets change by some Ajax (GetResponse form). There is no page refresh.

I've tried below code but it is only working in FireFox & not working in Chrome.

<script>
    $(function() {
        $(".modalbox").fancybox();
    });
    $(function() {
        $('.wf-button').bind("DOMSubtreeModified",function(){
            //if btn valu is 'Thank You! trigger popup'                    
            $(".modalbox").trigger('click');

        });
    });
</script> 

Live URL: http://www.idynbiz.com/web/html/gold_ira_vf/? (just to show how the button changes its value)

Can some one help how can I detect the button value and show my popup? The button change its value in real time (Ajax). There is not page refresh.

Is there any JQuery approach with bind() Or on() function to detect the value?

Irfan
  • 4,882
  • 12
  • 52
  • 62

3 Answers3

1

$(function() {
  $('.btn1').on('change', function() {
    alert('Do stuff...');
  });
  $('.lnk1').on('click', function() {
    $('.btn1').val('Thank you!');
    $('.btn1').trigger('change');
  });
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<input type="submit" class="btn1" value="SUBSCRIBE" />
<a href="#" class="lnk1">Change button value</a>
Bitwise Creative
  • 4,035
  • 5
  • 27
  • 35
0

OK , when button is clicked and form is submitted for saving. just write these code

$(document).ready(function ()
{
   $('.wf-button').click(function ()
   {
     var valueofbutton = $(this).attr('value');
     if(valueofbutton == 'Thank You!')
       {
          window.open(); //// whatever you want to open in popup
       }
   });
});

i m sure that this will work

Kashyap Patel
  • 1,139
  • 1
  • 13
  • 29
0

You can use the following function in javascript which gets called after any > kind of postback, i.e. synchronous or asynchronous.

function pageLoad() { if($(".wf-button").val()=="Thank You!") { // show your popup } }

Hope it works....