SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    Community Advisor silver trophybronze trophy
    dresden_phoenix's Avatar
    Join Date
    Jun 2008
    Location
    Madison, WI
    Posts
    2,816
    Mentioned
    34 Post(s)
    Tagged
    2 Thread(s)

    blocking a form input

    I should KNOW THIS.. but I guess I am missing something...

    i am trying to create a from that has some check-boxes that are pre-selected. I dont want the user to be able to change this selection but I want the value to be submitted with the form. I would have guessed that this was a job for DISABLED , but that actually keeps the input for being submitted. I tried READONLY but that is still allowing me to check /uncheck the box...

    what is the correct way to code this?
    thanks all...

  2. #2
    Programming Team silver trophybronze trophy
    Mittineague's Avatar
    Join Date
    Jul 2005
    Location
    West Springfield, Massachusetts
    Posts
    17,237
    Mentioned
    194 Post(s)
    Tagged
    2 Thread(s)
    Wouldn't that be for type hidden? It doesn't seem intuitive to present an input that isn't a choice. Unless I'm missing what you're trying to do.

  3. #3
    Community Advisor silver trophybronze trophy
    dresden_phoenix's Avatar
    Join Date
    Jun 2008
    Location
    Madison, WI
    Posts
    2,816
    Mentioned
    34 Post(s)
    Tagged
    2 Thread(s)
    Well I want tolet the user know this value will be attributed, but I dont want him to be able to change the value .

  4. #4
    Robert Wellock silver trophybronze trophy xhtmlcoder's Avatar
    Join Date
    Apr 2002
    Location
    A Maze of Twisty Little Passages
    Posts
    6,316
    Mentioned
    60 Post(s)
    Tagged
    0 Thread(s)
    You are out of luck really with a checkbox and HTML alone. Since DISABLED values aren't submitted and READONLY basically applies to text and passwords rather than checkboxes. If you used TEXTAREA you would see read-only at work via a browser.

  5. #5
    The CSS Clinic is open silver trophybronze trophy
    Paul O'B's Avatar
    Join Date
    Jan 2003
    Location
    Hampshire UK
    Posts
    40,484
    Mentioned
    182 Post(s)
    Tagged
    6 Thread(s)
    Could you cheat like this?

    Code:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>Untitled Document</title>
    <style type="text/css">
    input, label {
        z-index:-1;
        position:relative
    }
    </style>
    </head>
    <body>
    <form id="form1" method="post" action="">
        <fieldset class="preselected">
        <legend>Pre-selected for you</legend>
        <input name="check1" type="checkbox" id="check1" checked="checked" />
        <label for="check1">check1</label>
        <input type="checkbox" name="check2" id="check2" checked="checked" />
        <label for="check2">check2</label>
        <input type="checkbox" name="check3" id="check3" checked="checked" />
        <label for="check3">check3</label>
        <input type="checkbox" name="check4" id="check4" checked="checked" />
        <label for="check4">check4</label>
        </fieldset>
    </form>
    </body>
    </html>
    You'd have to make it specific of course with classes etc.

    Opera is the only browser that doesn't play ball with the above so you could do something like this.

    Code:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>Untitled Document</title>
    <style type="text/css">
    input, label {
        z-index:-1;
        position:relative
    }
    .preselected{
        position:relative
    }
    .preselected b{
        position:absolute;
        z-index:99;
        top:0;
        left:0;
        right:0;
        bottom:0;
        background:red;
        opacity:0.1
    }
    </style>
    <!--[if IE ]>
    <style>
    .preselected b{background:transparent}
    </style>
    <![endif]-->
    </head>
    <body>
    <form id="form1" method="post" action="">
        <fieldset class="preselected">
        <legend>Pre-selected for you</legend>
        <input name="check1" type="checkbox" id="check1" checked="checked" />
        <label for="check1">check1</label>
        <input type="checkbox" name="check2" id="check2" checked="checked" />
        <label for="check2">check2</label>
        <input type="checkbox" name="check3" id="check3" checked="checked" />
        <label for="check3">check3</label>
        <input type="checkbox" name="check4" id="check4" checked="checked" />
        <label for="check4">check4</label>
        <b></b>
        </fieldset>
    </form>
    </body>
    </html>


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
  •