Jump to content

Hyperjase

Members
  • Posts

    93
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

Hyperjase's Achievements

Member

Member (2/5)

0

Reputation

  1. How would I use the javascript on two different sets of drop down selects? Thanks ~ Jason
  2. Sorry I have a habit of making simple things sound over complicated! There are two sets of drop downs which need multiple counters, so one for each. I did try doing this myself but couldn't alter the JavaScript to pick up each drop down. Thanks, Jason
  3. Here's the entire form script (please excuse any syntax stuff - I'm still learning) <form id="nocupcakes" method="post" action="?step=3"> <table width="70%" align="center"> <tr> <td colspan="3"> Please select how many of each type of Cupcake topping you would like<br /> </td> </tr> <?php foreach ($_SESSION['topping'] as $value) { echo "<tr><td width='30%'>Topping</td><td width='50%'>$value</td><td width='20%'><select name='notopping[$value]'>"; $counter = 1; while ( $counter <= $_SESSION['cupcake'] ) { echo '<option value='.$counter.'>'.$counter.'</option>'; $counter++; } echo "</select></td></tr>"; } echo "<tr><td colspan='3' align='center'>Choices Left: <input type='text' id='total' class='dis' size='2' value='0' />/".$_SESSION['cupcake']."</td></tr>"; if (count($_SESSION['swtopping']) > 0) { ?> <tr> <td colspan="3"> <br /><br />Please select how many of each type of sweetie topping you would like<br /> </td> </tr> <?php foreach ($_SESSION['swtopping'] as $value) { echo "<tr><td width='30%'>Sweetie topping</td><td width='50%'>$value</td><td width='20%'><select name='noswtopping[$value]'>"; $counter = 1; while ( $counter <= $_SESSION['cupcake'] ) { echo '<option name="noswtopping" value="'.$counter.'">'.$counter.'</option>'; $counter++; } echo "</select></td></tr>"; } echo "<tr><td colspan='3' align='center'>Choices Left: <input type='text' id='total' class='dis' size='2' value='0' />/".$_SESSION['cupcake']."</td></tr>"; } ?> <tr><td colspan="3"><hr /></td></tr> <tr><td colspan="3">Would you like them delivered or would you prefer to collect?</td></tr> <tr><td colspan="2" align="right">Delivered</td><td><input name="delcol" type="radio" value="delivered" data-bvalidator="required" data-bvalidator-msg="Select delivery or collection please" /></td></tr> <tr><td colspan="2" align="right">Collection</td><td><input name="delcol" type="radio" value="collected" /><br /></td></tr> </div><tr><td colspan="3" align="center"><input type="submit" value="Next >>" class="submit" /></td></tr> </td> </table> </form> The Sweetie Topping drop down only appears if any have been selected, at least one Topping drop down will always show. Thanks for your time, Jason
  4. I also have another problem which I'm not sure how to solve. I have more than one drop down box that needs to show the total. At the moment, the second set of drop down boxes adds to the first total (which it will logically), but I've tried changing the code to reflect the name of the drop down (by using var selects = document.getElementsByTagName('select.topping') - but that doesn't work. The next small issue I can see is that each dropdown is dynamic (<select name='notopping[$value]'>). So one could be Chocolate, one could be Choc Orange. So can I associate two different drop down sets with two different counters? Thanks, Jason
  5. Perfect, I just need it to show without the input box - will check on formatting for that. Is there any way of disabling the submit button until the total number is reached? Thanks, Jason
  6. I've been trying the code but Dreamweaver keeps telling me there's an error with this line of code : $(".dropdown").change(function() { I wrapped it inside <script type="text/javascript">##</script> - thats when it spat out the error. Any ideas? I'm quite out of my depth with jquery. Thanks, Jason
  7. I think I have jquery there for another part of code so that should be fine .... just confused by the )); on the final line, after the </body> code - is that correct? Or should I disregard that part? Cheers! Jason
  8. Thanks for the code, do I need to wrap it within <javascript>? I've pased it directly in but not sure if it needs something around it! Cheers, Jason
  9. I could assign them all with the same class, thats easy as because it's in a foreach loop, the select will always be the same where I assign a manual value. I have no experience with jquery though, any pointers? Thanks, Jason
  10. Yeah that's the only real thing I'm missing, I just can't find anything that actually works! Thanks, Jason
  11. Rightho, Still WIP but I think it's worth seeing if I've done a good job or not -- this is an early attempt for me, still learning PHP. This does send an email and add to a database, I will clean the database out so nothing will be kept. http://cakesbyang.co.uk/cupcakemaker.php validation: http://cakesbyang.co.uk/phpfreaks.txt Let me know if you break it or find a weakness! Thanks, Jason
  12. Hi all, Trying to get a function going which will add up all the numbers from several drop down boxes. Here is the code: <?php foreach ($_SESSION['topping'] as $value) { echo "<tr><td width='30%'>Topping</td><td width='50%'>$value</td><td width='20%'><select name='notopping[$value]'>"; $counter = 1; while ( $counter <= $_SESSION['cupcake'] ) { echo '<option value='.$counter.'>'.$counter.'</option>'; $counter++; } When the option value is selected, it will select a number, from either 1 to 36. This is in a foreach loop as the number of drop down boxes is dynamic - chosen from a number of check boxes. How would I create a javascript function that when the drop down box is changed, the figures are added together and shown at the side. I want it to be that it shows the number selected in total. Thanks, Jason
  13. This is exactly what I need, I'm currently trying this code but it doesn't want to work, just no adding it up. http://www.mcfedries.com/javascript/ordertotals.asp When you select the drop down and a value, it automatically updates the total value. Thanks, Jason
  14. I have no experience with Ajax, only php - this is something I'm look to achieve and from reading up this is the most likely way of solving it .... I just have no idea how to do it! Thanks, Jason
  15. Hi all, I'm trying to create a way of showing the sum total of a number of drop down boxes. The number of drop down boxes is dynamic, created by two variables - one being how many cupcakes and how many toppings are selected. It then creates drop downs for each selected topping and the value is the number of cupcakes chosen. Here is the code I have: <?php foreach ($_SESSION['topping'] as $value) { echo "<tr><td width='30%'>Topping</td><td width='50%'>$value</td><td width='20%'><select name='notopping[$value]'>"; $counter = 1; while ( $counter <= $_SESSION['cupcake'] ) { echo '<option value='.$counter.'>'.$counter.'</option>'; $counter++; } echo "</select</td></tr>"; } echo "<tr><td colspan='3' align='center'>All must add up to ".$_SESSION['cupcake']."</td></tr>"; if (count($_SESSION['swtopping']) > 0) { ?> <tr> <td colspan="3"> <br /><br />Please select how many of each type of sweetie topping you would like<br /> </td> </tr> <?php foreach ($_SESSION['swtopping'] as $value) { echo "<tr><td width='30%'>Sweetie topping</td><td width='50%'>$value</td><td width='20%'><select name='noswtopping[$value]'>"; $counter = 1; while ( $counter <= $_SESSION['cupcake'] ) { echo '<option name="noswtopping" value="'.$counter.'">'.$counter.'</option>'; $counter++; } echo "</select></td></tr>"; } echo "<tr><td colspan='3' align='center'>All must add up to ".$_SESSION['cupcake']."</td></tr>"; } ?> I want a way when each drop down is changed it updates the total number selected. Also is there a way of not allowing the submit button to be pressed until the value of all the drop down boxes match the total number of cupcakes. Is this possible? Thanks, Jason
×
×
  • 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.