JSFiddle - React, Tailwind, and code Playground

by learner001

JavaScript

function myFunction() 
	{
		alert("You need to login before negotiating! However you can purchase the product without negotiating");
	}

var startClock;
var submitamt;
var walkaway;
var digits;

$(function() 
	{
		startClock = $('#startClock').on('click', onStart);
		submitamt = $('#submitamt').on('click', onSubmit);
		walkaway = $('#walkaway').on('click', onWalkAway);
		digits = $('#count span');
		beforeStart();
	});

var onStart = function(e) 
	{
		startClock.fadeOut(function() 
			{
				startTimer();
				submitamt.fadeIn(function() 
					{
						submitamt.trigger('click'); // fire click event on submit
					});
				walkaway.fadeIn();
			});
	};

var onSubmit = function(e) 
	{
		var txtbox = $('#txt').val();
		var hiddenTxt = $('#hidden').val();
		
		$("#walkaway").hide();
		$("#submitamt").hide();
	
		$.ajax(
			{
				type: 'post',
				url: 'test2.php',
				dataType: 'json',
				data: {
					txt: txtbox,
					hidden: hiddenTxt
				},
				cache: false,
				success: function(returndata) 
					{
						$('#first').html(returndata[0]);
						$('#second').html(returndata[1]);
						$('#third').html(returndata[2]);
						$('#fourth').html('<img src="' + returndata[3] + '" height="125" width="125">')
						
						console.log(returndata);
						$("#walkaway").show();
						$("#submitamt").show();
					},
				error: function() 
					{ 
						console.error('Failed to process ajax !');
					}
			});
	};

var onWalkAway = function(e) 
	{
		//console.log('onWalkAway ...');
	};

var counter;
var timer;
var startTimer = function()
	{
		counter = 120;
		timer = null;
		timer = setInterval(ticker, 1000);
	};

var beforeStart = function() 
	{
		digits.eq(0).text('2');
		digits.eq(2).text('0');
		digits.eq(3).text('0');
	};

var ticker = function() 
	{
		counter--;
		var t = (counter / 60) | 0; // it is round off
		digits.eq(0).text(t);
		t = ((counter % 60) / 10) | 0;
		digits.eq(2).text(t);
		t = (counter % 60) % 10;
		digits.eq(3).text(t);
		if (!counter)...