I am new to Magento. I have the following requirements.
A page has a text box where the customer enters an id. Once the id is entered, I need to check whether this id is available in the OMS using a OMS webservice call. And if the id is valid, I need to enable the submit button in the page. If the id is invalid I need to disable the submit button. Could someone give me some direction on this.
Thanks
Update: I tried to do this using the following code, Javascript: The function will called on click of the submit button
submit.onclick = function()
{
$.ajax
({
url: "<?php echo $this->getUrl('checkout/OnepageController/checkid')?>",
type: "POST",
data: {id: '2345'},
dataType: json,
success: function(data) {
status = data;
}
});
if (status=='invalid')
{
alert('id function was not hit');
return false; // cancel submission
}
else if (status=='valid')
{
alert('id function was hit');
return true;
}
}
Php: Magento Controller
public function checkidAction()
{
$id = $_POST['id'];
if ($id=='1234')
{
$status = "valid";
}
else
{
$status ="invalid";
}
echo json_encode($status);
}
Could you please tell me if something is wrong here. I am not able to get the status information back to the ajax call. Thanks