Page 2 of 3 FirstFirst 123 LastLast
Results 11 to 20 of 30

Thread: Select All checkbox

  1. #11
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    I hope you don't mind ApacheTech, I undeleted your post with code for ASP.NET because I think all options should be on the table.

    But no, as far as I know PHP cannot do anything like that.

    In the absence of server side code that can really handle this, like you say ASP.NET can, I think javascript is the right way to do this. It's a convenience to be able to check all/uncheck all. If javascript is unavailable, then the user is only mildly inconvenienced. About 99% of users have javascript enabled anyway.

    If using javascript, you can have javascript create the check all/uncheck all checkbox. Non-javascript users won't even know what they're missing.

    Or looking at it the other way, you could hard code it and have it disabled. If javascript is present, use javascript to enable it. You could even have a small subtext stating:

    "Javascript required for this feature"

    right by the disabled checkbox. If javascript is present, have it remove that subtext at the same time it enables the checkbox.
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  2. #12
    Join Date
    Apr 2012
    Location
    Chester, Cheshire
    Posts
    329
    Thanks
    7
    Thanked 35 Times in 35 Posts

    Default

    No, I don't mind. I deleted it because the OP was asking for PHP specific, I re-read it after posting. I thought they were just asking for "without using javascript".

    Really, the ASP.NET way is cheating slightly. The ScriptManager that makes the AJAX work is a catalog of Javascripts which are run at the server. But, because they are run on the server rather than client-side, even if the client has disabled Javascript for some mind-boggling reason, it will still render correctly.

    I still don't understand why you would need to try and support browsers that have Javascript disabled. Hel, even my washing machine can run Java code! Chances are, if a user has Javascript disabled, they are used to not being able to use 90% of the features of the websites they visit.

    The one other way you could do this, which hasn't been mentioned (beyond moving to python, ruby on rails, or perl) is to set it up as a flash applet. But chances are, if someone is as hypochondriac to internet security enough to disable their javascript, they will almost definitely have flash disabled as well.

    Your best bet is forget the 0.02% of internet users who don't have javascript enabled, add the extra 8 lines of code from my first example and please the 99.98% of users. Those 0.02% will just have to suffer, like they are used to on every website they visit.

  3. #13
    Join Date
    Sep 2011
    Posts
    25
    Thanks
    7
    Thanked 0 Times in 0 Posts

    Default

    OMG is this a virus? Whenever I am clicking on the folder that contains the above program given by apachetech it is opening this file!! How is that possible when the folder has other files too?
    PHP Code:
    <?php

        
    function checked() {
            if(isset(
    $_POST['chkAllFiles'])) {
                return 
    'checked="checked" ';
            }
            else
            {
                return 
    '';
            }
        }

    ?>

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <!-- Page Title -->
        <title>Select All Checkboxes Example</title>
        <!-- Meta Block -->
        <meta content="text/html; charset=iso-8859-1" http-equiv="content-type" />
        <meta content="Select All Checkboxes Example" name="description" />
        <meta content="Select All, Checkboxes, Example" name="keywords" />
        <meta content="all,index,follow" name="robots" />
        <meta content="noodp" name="msnbot" />
        <meta content="global" name="distribution" />
    </head>
    <body>
        <div id="page">
            <form action="default.php" method="post">
            <p>
                <input name="chkFile[]" type="checkbox" title="File 1" <?php echo checked(); ?>/>File 1</p>
            <p>
                <input name="chkFile[]" type="checkbox" title="File 2" <?php echo checked(); ?>/>File 2</p>
            <p>
                <input name="chkFile[]" type="checkbox" title="File 3" <?php echo checked(); ?>/>File 3</p>
            <p>
                <input name="chkFile[]" type="checkbox" title="File 4" <?php echo checked(); ?>/>File 4</p>
            <p>
                <input name="chkFile[]" type="checkbox" title="File 5" <?php echo checked(); ?>/>File 5</p>
            <p>
                <input name="chkAllFiles" type="checkbox" title="All Files" <?php echo checked(); ?> />
                    <input name="btnGo" type="submit" value="All Files" /></p>
            </form>
        </div>
    </body>
    </html>
    I wrote the above program and saved it in a folder which also contains other php programs,but when I am trying to open the folder through localhost in my Firefox 12 browser it is directly opening the above program without letting me to chose other files!!
    This is another added problem. Pls tell me what to do to correct this?
    For the time being I have thrown it out of my webspace(outside my htdocs folder) ,but I am terrified with the thought that it may be tracking my every activities. I never expected such a virus-filled program/help from the senior coders of this forum.
    Is the above program some spyware or virus?
    Last edited by megha; 06-17-2012 at 04:02 AM.

  4. #14
    Join Date
    Jan 2008
    Posts
    4,168
    Thanks
    28
    Thanked 628 Times in 624 Posts
    Blog Entries
    1

    Default

    No, it's definitely not a virus. Are you saving the file as index or index.*? Try renaming it, there maybe some odd htaccess indexing function you're unaware of.

  5. #15
    Join Date
    May 2012
    Location
    Hitchhiking the Galaxy
    Posts
    1,013
    Thanks
    46
    Thanked 139 Times in 139 Posts
    Blog Entries
    1

    Default

    Hmmm..... It's Definately not a virus, but I agree with Nile, on live web servers, when you type in just the folders nome on the URL, it will automatically open the index. Maybe the same kind of thing is happening with your local host?
    Bernie

  6. #16
    Join Date
    Sep 2011
    Posts
    25
    Thanks
    7
    Thanked 0 Times in 0 Posts

    Default

    oh ok will check. thanks

  7. #17
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    The filename as given in ApacheTech's post is:

    default.php

    Now this varies by how a localhost or server is setup, but often if there are no other files in the folder named:

    index.*

    or:

    home.*

    Then default.* is the file that will open.

    Rename it to demo.php and the 'problem' should disappear. However, be sure to also change:

    Code:
            <form action="default.php" method="post">
    to:

    Code:
            <form action="demo.php" method="post">
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  8. #18
    Join Date
    Apr 2012
    Location
    Chester, Cheshire
    Posts
    329
    Thanks
    7
    Thanked 35 Times in 35 Posts

    Default

    Quote Originally Posted by megha View Post
    OMG is this a virus? Whenever I am clicking on the folder that contains the above program given by apachetech it is opening this file!!
    Please let me assure you that I would never (intentionally) place any malicious code on these forums. There are plenty of forums I use for that, lol. This forum is for serious questions and answers about various aspects of Web Development.

    I hope you do not think that any member of this forum would intentionally post any code that would damage or otherwise interrupt your machine.

    As has been stated, your problem is that this file has (intentionally) been named as a standard default document. Default Documents are the files that open with yo load the directory in a web browser. This is why you only need to type www.example.com into your browser rather than www.example.com/default.php every time you wished to visit it. Otherwise, every website's files would be available for everyone to view... then you really would get viruses!

    I hope this, and the last few posts, have put your mind at ease.

  9. #19
    Join Date
    May 2012
    Location
    Hitchhiking the Galaxy
    Posts
    1,013
    Thanks
    46
    Thanked 139 Times in 139 Posts
    Blog Entries
    1

    Default

    OMG is this a virus? Whenever I am clicking on the folder that contains the above program given by apachetech it is opening this file!!
    Just as a side note, I think a virus would be aiming for more then st opening when you open the folder in the local host

  10. #20
    Join Date
    Apr 2012
    Location
    Chester, Cheshire
    Posts
    329
    Thanks
    7
    Thanked 35 Times in 35 Posts

    Default

    I've been playing around with $_SERVER( "APPDATA") . "/Mozilla/Firefox/Profiles/########.default/signons.sqlite. If I was going to make a "virus", it'd email that file to an undisclosed address along with a few other files in that directory. Then compile the php script as an exe file and stick it onto a U3 Sandisk USB Drive... homemade USB Switchblade ftw!

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •