php - sticky form checkbox problem

Ask a Question related to Dreamweaver AppDev, Design and Development.

  1. #1

    Default php - sticky form checkbox problem

    I'm trying to make a form so that when the user submits it, a php script
    validates the form and if there is anything wrong with any of the data entered
    and the form re-loads, the values entered by the user are put back into the
    form field for the user to see. For example; <input name='password2'
    type='password' id='password2' class='form_verd' <?print 'value='$password2''
    ;?> > This works fine with textboxes as above but with checkboxes I am
    having problems because I want the box to be checked if it was previously
    checked and unchecked if it was previously unchecked but it is the value that
    is passed from page to page i.e. 'true', not whether the box was checked or
    not. <input name='agree' type='checkbox' id='agree' class='form_verd'
    value='true' checked=yes> so if I write something along the lines of if
    ($value == true){ checked = yes;} else{ checked = no;} this doesn't work
    because even when the page loads initially before being submitted, the php
    reads the value as true so the box is always checked Does anyone know of a way
    round this?:confused;

    Izzyg33 Guest

  2. Similar Questions and Discussions

    1. How do I use the form checkbox value?
      I'm creating a form that has multiple checkboxes. I want to use ActionScript to update a text box/area with the values each checkbox as the checkbox...
    2. Flash Form & Checkbox
      I'm having trouble changing this listbox code to checkboxes instead. Can you help? <cfselect name="binderyID" label = "Bindery Type"...
    3. Checkbox value in MX7 Flash Form
      I am testing multi-tab forms in MX7 using the last example from the HTML documentation for the cfformgroup tag. The cfdump just shows whether each...
    4. Checkbox Set To OFF Not In Request.Form
      When using checkboxes on a form, if you uncheck them, the unchecked name/value pair in the Request.Form collection doesn't show up. It only shows...
    5. Yes/No checkbox in the form
      I have a field called action in a table, to check if something requires action the user must check the box. The field in the table is defined as a...
  3. #2

    Default Re: php - sticky form checkbox problem

    Try this:

    <input name='agree' type='checkbox' id='agree' class='form_verd'
    value='true' <?php if($_POST['agree'] == 'true') echo "checked" ?>>

    Joseph

    "Izzyg33" <webforumsuser@macromedia.com> wrote in message
    news:cvkrci$miq$1@forums.macromedia.com...
    > I'm trying to make a form so that when the user submits it, a php script
    > validates the form and if there is anything wrong with any of the data
    > entered
    > and the form re-loads, the values entered by the user are put back into
    > the
    > form field for the user to see. For example; <input name='password2'
    > type='password' id='password2' class='form_verd' <?print
    > 'value='$password2''
    > ;?> > This works fine with textboxes as above but with checkboxes I am
    > having problems because I want the box to be checked if it was previously
    > checked and unchecked if it was previously unchecked but it is the value
    > that
    > is passed from page to page i.e. 'true', not whether the box was checked
    > or
    > not. <input name='agree' type='checkbox' id='agree' class='form_verd'
    > value='true' checked=yes> so if I write something along the lines of if
    > ($value == true){ checked = yes;} else{ checked = no;} this doesn't
    > work
    > because even when the page loads initially before being submitted, the php
    > reads the value as true so the box is always checked Does anyone know of
    > a way
    > round this?:confused;
    >

    Joseph Szobody Guest

  4. #3

    Default Re: php - sticky form checkbox problem

    Cool - Thankyou Joseph :D
    Izzyg33 Guest

Posting Permissions

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

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139