×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Contact US

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Code that works on Windows, Android and Iphone

Code that works on Windows, Android and Iphone

Code that works on Windows, Android and Iphone

(OP)
I have written a program for internal use using, mainly, PHP, but also has a lot of Javascript. It works absolutely fine using WIndows devices (including Windows phones), Android phones, and for the most part iPhones, but there are some items that don't work properly using the latter.

Generally they are where user interraction is required to "fire" the javascript.

1) On every page there is a back button. If the code is a straightforward href then no problem, but some pages can be called from different places fo I have used a javasript action:

CODE -->

<button onclick="window.history.back()">Back</button> 
This works fine in everything but iphones.

2) On one page there is a set of checkboxes, and clicking any one of them fires a javascript code that counts number of items that are checked and if a certain number activates a button

CODE --> PHP/HTML

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>'; 

CODE --> Javascript

function chkcountfn(required, col, memid) {
                let initid = "init" + memid;+
                let divid = "row" + memid;
                
                let dateid = "date" + memid;
                let savebtn = "save" + memid;
                let str = document.getElementById(divid).innerHTML;
                let origstr = document.getElementById(initid).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;
                
                // to do: disable if origstr == charReplaced
                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;
            } 
Using some, but not all, iPhones the checkbox clicks, but the javasript is ignored (ie the Save button is not activated). It seems that older iPhones are the main culprits, newer ones do seem to work most of the time.

I should emphasise that all iphones tested do have Javascript enabled, and in all other parts of the program Javascript acts as expected.

Many thanks for any help

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login


Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close