I am implementing click to call by using href.
<a href="tel:+919876543210">Click here to call</a>
It is working for single number. But I need to give 2 numbers in href as alternate number.
I have tried with this,
<a href="tel:+919876543210, +919876543211">Click here to call</a>
I also tried with following approach,
<a href="tel:+919876543210, tel:+919876543211">Click here to call</a>
But it takes only first number. Is it possible to add 2 numbers in href? If yes then how? When user will click on this then random numbers should be choosed. Any help will be appreciated. Thanks in advance.
You can use JavaScript for this :-)
Below is some code for a simple web page that should solve your problem
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
<script type="text/javascript">
// The Phone numbers
var phoneNumbers = [
"+919876543210",
"+919876543211"
];
/**
* Returns a random integer between min (inclusive) and max (inclusive)
* Using Math.round() will give you a non-uniform distribution!
*/
function getRandomInt(min, max) {
return Math.floor(Math.random() * (max - min + 1)) + min;
}
function call() {
// Get min and max index of the phone number array
min = 0;
max = phoneNumbers.length - 1;
// get the random phone number
phoneNumberToCall = phoneNumbers[getRandomInt(min, max)];
// Call the random number
window.open("tel:" + phoneNumberToCall);
}
</script>
</head>
<body>
<a onclick="call()" href="">Click here to call</a>
</body>
</html>
I got the random number generator from here => https://stackoverflow.com/a/1527820/2627137