I have a form which checks if an item of stock is available in my ecommerce project that I am working on. You can see in the form, I have 2 buttons, and in the formm and to make the first function work, I have used the line <form class="text-center" onsubmit="addclient();return false">
I have 2 other functions which add the client and move the client. This line of code adds the client, there is a second one to move the customer. But I can only call this "register" function.
How can I incorporate the 2nd function into this form using the second button. I am very new to ajax and this is pretty complicated stuff. Hope someone can share their expertise. I appreciate this is a noob question
Thanks in advance for helping me out
I have 2 functions:
function checkavailability() {
jQuery("#loading1").slideDown();
jQuery.post("cart.php", { a: "options", sld: jQuery("#sld").val(), extension: jQuery("#extension").val(), checktype: 'register', ajax: 1 },
function(data){
jQuery("#results").html(data);
jQuery("#results").fadeIn();
jQuery("#topsay").hide();
jQuery("#loading1").slideUp();
});
}
The Second Function
function moveclient() {
jQuery("#loading1").slideDown();
jQuery.post("cart.php", { a: "options", sld: jQuery("#sld").val(), transfer: jQuery("#transfer").val(), checktype: 'transfer', ajax: 1 },
function(data){
jQuery("#results").html(data);
jQuery("#results").slideDown();
jQuery("#loading1").slideUp();
});
}
The Form
<form onsubmit="checkavailability();return false">
<input type="hidden" name="direct" value="true" />
<input name="sld" id="sld" type="text" />
<div class="col-xs-12 col-sm-2">
<select>
<option>Date1</option>
<option>Date2</option>
<option>Date3</option>
<option>Date4</option>
</select>
</div>
<button type="submit" class="button">Move</button>
<button type="submit" class="button">Register</button>
</form>