Jump to content

H3LL

New Members
  • Posts

    7
  • Joined

  • Last visited

    Never

Everything posted by H3LL

  1. I used this: <input type="checkbox" name="verhuur" value="" <?php if (isset($_POST['verhuur'])) { echo 'checked="checked"'; } ?> /> That was actually the code that i used before but was uncheckable, i made a very stupid copy paste mistake ($_POST['Averhuur']) with Averhuur instead of verhuur >.< Thanks for for the help everyone ^^
  2. well, im back from my break I've tried PFMaBiSmAd's way and it worked nicely, thanks I've also tried some ways to get the checkbox working, but i didn't get it working correctly. in my best attempt i got it working so it would stay checked, but after that it remained checked, even if i unchecked it and resubmitted, so ye, i could still use some help with it.
  3. I did it another way: <tr> <td> <input type="checkbox" name="verhuur" value="" /></td> <td>Verhuur</td> <td>€ 60,00</td> <td> <select name="Averhuur"> <option value="1" <?php if ($Averhuur == "1") { echo 'selected="selected"'; } ?> >1</option> <option value="2" <?php if ($Averhuur == "2") { echo 'selected="selected"'; } ?>>2</option> <option value="3" <?php if ($Averhuur == "3") { echo 'selected="selected"'; } ?>>3</option> <option value="4" <?php if ($Averhuur == "4") { echo 'selected="selected"'; } ?>>4</option> <option value="5" <?php if ($Averhuur == "5") { echo 'selected="selected"'; } ?>>5</option> </select> </td> </tr> I'll give ur way a try as well to make it a lot easier for me in the future ^^ After that i'll need to get the checkbox working as well, haven't tried that yet!
  4. I tried this, but instead of remembering the value it adds a new blank, valueless option which is preselected after the submit
  5. Right now i got the code posted below. It works alright, but it has 1 problem. When i press the submit button the form resets, but what i want is that the checkboxes which were checked remain checked and the values selected in the dropdown box keep that value. How can you do this? Is it even possible with php or am i going to need js? <?php $verhuur = 60.00; $Totaal = 0; $Averhuur = ""; if (isset($_POST['Averhuur'])) { $Averhuur = $_POST['Averhuur']; } if (isset($_POST['verhuur'])) { $verhuur = $verhuur * $Averhuur; $Totaal = $Totaal + $verhuur; } ?> <form action="test.php" method="post"> <table> <tr> <td> <input type="checkbox" name="verhuur" value="" /></td> <td>Verhuur</td> <td>€ 60,00</td> <td> <select name="Averhuur"> <option value="1">1</option> <option value="2">2</option> <option value="3">3</option> <option value="4">4</option> <option value="5">5</option> </select> </td> </tr> <tr> <td> </td> <td><strong>Totaal:</strong></td> <td> <strong> <?php $formatnumber = number_format($Totaal, 2, ',', ''); echo "€ "; if($Totaal!=0){ echo $formatnumber; } else { echo "0,00"; } ?> </strong> </td> </tr> <tr> <td> </td> <td><input type="submit" value="Bereken" /></td> </tr> </table> </form>
  6. H3LL

    Form Problem

    Thanks for that, but i already had it working that way before. What i am trying to achieve is that the totalcost echo gets updated as soon as you check a checkbox, not when you press submit
  7. Below here is the php and form i got right now. What i want to achieve is that when i check a checkbox that the TotalCosts will be updated by the matching value, and when i checked multiple boxes that those vallues will be added together. But the most important thing what i want to achieve right now is that when you check a box that the TotalCosts echo on the screen will be updated right away with the correct vallues. I tried some things i found while looking here and on other sites, but nothing seems to be working the way i want. Anyways, here is my php, i hope someone can help me <?php $hire = 60.00; $hire1 = 20.00; $hire2 = 22.50; $TotalCosts = 0.00; ?> <form action="index.php" method="post"> <input type="checkbox" name="hire" value="" />Hire <br /> <input type="checkbox" name="hire1" value="" />Hire1 <br /> <input type="checkbox" name="hire2" value="" />Hire2 <br /> </form> <?php if (isset($_POST['hire'])) { $TotalCosts = $TotalCosts + $hire; } if (isset($_POST['hire1'])) { $TotalCosts = $TotalCosts + $hire1; } if (isset($_POST['hire2'])) { $TotalCosts = $TotalCosts + $hire2; } echo $TotalCosts; ?>
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.