I have an application written in PHP with some Javascript that works as expected using windows laptops and android phones. However there are a few places in it that do not work when the user is using an iphone, and they are all where a javascript call is made as a result of user screen interaction.
Firstly there are a number of checkboxes on one page and each has an identical onclick event, that updates a variable, and enables a button.
PHP/HTML Code…
//Now the checkboxes
for ($y = 0; $y < $itemcount; $y++) {
$chkval = $skills[$y];
$checked = '';
if ($chkval == "1") {
$checked = 'checked = "checked" disabled="disabled"';
}
$id = " id = 'chk[".$memid.",".$y."]'";
echo '<td style="text-align: center;">';
echo "<input type='checkbox' class='checkbox checkbox-success' " . $checked .$id. " onclick='chkcountfn($required,$y,\"$memid\") ' />";
echo'</td>';
Javascript code:
let divid = "row" + memid;
let dateid = "date" + memid;
let savebtn = "save" + memid;
let str = document.getElementById(divid).innerHTML;
let datestr = document.getElementById(dateid).innerHTML;
let changestr = memid;
let char = str[col];
if (str[col] === "0") {
char = "1";
} else {
char = "0";
}
charReplaced = replaceChar(str, char, col);
document.getElementById(divid).innerHTML = charReplaced;
document.getElementById("changes").value = changestr;
let btn = document.getElementById(savebtn);
if (btn.classList.contains('disabled')) {
// remove the class
btn.classList.remove('disabled');
}
let count = 0;
let ch = "1";
for (let i = 0; i < charReplaced.length; i++) {
if (charReplaced.charAt(i) == ch) {
count++;
}
}
if (count >= required) {
if (datestr.length === 0) {
alert("Required number of skills acheived");
var today = new Date();
var dd = today.getDate();
var mm = today.getMonth() + 1;
var yyyy = today.getFullYear();
if (dd < 10) {
dd = '0' + dd;
}
if (mm < 10) {
mm = '0' + mm;
}
today = dd + '/' + mm + '/' + yyyy;
document.getElementById(dateid).innerHTML = today;
}
}
}
function replaceChar(origString, replaceChar, index) {
let firstPart = origString.substr(0, index);
let lastPart = origString.substr(index + 1);
let newString = firstPart + replaceChar + lastPart;
return newString;
}
The other case is where pressing a button calls a javascript goback:
echo '<a class = "btn btn-success" href = "javascript:goback()"><span class = "fa fa-arrow-left"></span> Back</a>';
In other parts of the program, where there is no user interaction with the screen, javascript is handled by the iphone as expected, which shows that the phones have their javascript enabled.
What would be the best way to make the system operable on an iphone without “breaking it” for other devices?
Many thanks