think-digitally Posted May 28, 2008 Share Posted May 28, 2008 Hi. Can anyone help me with this: I need a script that can add the values of drop down boxes, and show the overall value next to them. Is this possible? Thanks Quote Link to comment https://forums.phpfreaks.com/topic/107630-solved-confused/ Share on other sites More sharing options...
soycharliente Posted May 28, 2008 Share Posted May 28, 2008 Do you have some code that you've been working on? Quote Link to comment https://forums.phpfreaks.com/topic/107630-solved-confused/#findComment-551684 Share on other sites More sharing options...
jonsjava Posted May 28, 2008 Share Posted May 28, 2008 could you post your code, so we could work on it? Also, this may be better suited as a javascript, if you are wanting it to do it automatically. Quote Link to comment https://forums.phpfreaks.com/topic/107630-solved-confused/#findComment-551685 Share on other sites More sharing options...
think-digitally Posted May 28, 2008 Author Share Posted May 28, 2008 No, I have a very limited knowledge, and was hoping it would be relatively easy to code Quote Link to comment https://forums.phpfreaks.com/topic/107630-solved-confused/#findComment-551686 Share on other sites More sharing options...
prcollin Posted May 28, 2008 Share Posted May 28, 2008 No, I have a very limited knowledge, and was hoping it would be relatively easy to code can you expand on what you need alittle more. Ill try to work out a code for you and then let the vultures pick me apart lol jk you guys are great. Quote Link to comment https://forums.phpfreaks.com/topic/107630-solved-confused/#findComment-551688 Share on other sites More sharing options...
think-digitally Posted May 28, 2008 Author Share Posted May 28, 2008 All I need really is to be able to add values to drop down boxes, so for example A drop down box that has a vlue of 12, and another drop down list with a value of 6, then next to them it displays 18 But each dropdown box would obviously have multiple values. Does this explain better? Quote Link to comment https://forums.phpfreaks.com/topic/107630-solved-confused/#findComment-551689 Share on other sites More sharing options...
jonsjava Posted May 28, 2008 Share Posted May 28, 2008 example: <?php if ($_POST['no1']){ $result = $_POST['no1'] + $_POST['no2'] + $_POST['no3']; print $result; } ?> <form method="POST" action="?"> <center> <table border="0"> <tr> <td> <select name="no1"> <option id="1" selected="selected">1</option> <option id="2">2</option> <option id="3">3</option> <option id="4">4</option> <option id="5">5</option> <option id="6">6</option> <option id="7">7</option> <option id="8">8</option> <option id="9">9</option> <option id="10">10</option> </select> </td> <td> <select name="no2"> <option id="1" selected="selected">1</option> <option id="2">2</option> <option id="3">3</option> <option id="4">4</option> <option id="5">5</option> <option id="6">6</option> <option id="7">7</option> <option id="8">8</option> <option id="9">9</option> <option id="10">10</option> </select> </td> <td> <select name="no3"> <option id="1" selected="selected">1</option> <option id="2">2</option> <option id="3">3</option> <option id="4">4</option> <option id="5">5</option> <option id="6">6</option> <option id="7">7</option> <option id="8">8</option> <option id="9">9</option> <option id="10">10</option> </select> </td> </tr> <tr> <td><input type="submit" value="submit" name="submit"></td></tr> </table> </center> </form> am I on the right track? Quote Link to comment https://forums.phpfreaks.com/topic/107630-solved-confused/#findComment-551691 Share on other sites More sharing options...
think-digitally Posted May 28, 2008 Author Share Posted May 28, 2008 Yes thats perfect, I just need them to add together and display at the end Quote Link to comment https://forums.phpfreaks.com/topic/107630-solved-confused/#findComment-551693 Share on other sites More sharing options...
jonsjava Posted May 28, 2008 Share Posted May 28, 2008 <?php if ($_POST['no1']){ $result = $_POST['no1'] + $_POST['no2'] + $_POST['no3']; } ?> <form method="POST" action="?"> <center> <table border="0"> <tr> <td> <select name="no1"> <option id="1" selected="selected">1</option> <option id="2">2</option> <option id="3">3</option> <option id="4">4</option> <option id="5">5</option> <option id="6">6</option> <option id="7">7</option> <option id="8">8</option> <option id="9">9</option> <option id="10">10</option> </select> </td> <td> <select name="no2"> <option id="1" selected="selected">1</option> <option id="2">2</option> <option id="3">3</option> <option id="4">4</option> <option id="5">5</option> <option id="6">6</option> <option id="7">7</option> <option id="8">8</option> <option id="9">9</option> <option id="10">10</option> </select> </td> <td> <select name="no3"> <option id="1" selected="selected">1</option> <option id="2">2</option> <option id="3">3</option> <option id="4">4</option> <option id="5">5</option> <option id="6">6</option> <option id="7">7</option> <option id="8">8</option> <option id="9">9</option> <option id="10">10</option> </select> </td> <td><input type="text" maxlength="4" size="4" value="<?php print $result;?>" readonly></td> </tr> <tr> <td><input type="submit" value="submit" name="submit"></td> </tr> </table> </center> </form> Quote Link to comment https://forums.phpfreaks.com/topic/107630-solved-confused/#findComment-551695 Share on other sites More sharing options...
think-digitally Posted May 28, 2008 Author Share Posted May 28, 2008 Fantastic thankyou very much That will work perfectly, is there anyway of just having the final figure as just text? Quote Link to comment https://forums.phpfreaks.com/topic/107630-solved-confused/#findComment-551698 Share on other sites More sharing options...
jonsjava Posted May 28, 2008 Share Posted May 28, 2008 <?php if ($_POST['no1']){ $result = $_POST['no1'] + $_POST['no2'] + $_POST['no3']; } ?> <form method="POST" action="?"> <center> <table border="0"> <tr> <td> <select name="no1"> <option id="1" selected="selected">1</option> <option id="2">2</option> <option id="3">3</option> <option id="4">4</option> <option id="5">5</option> <option id="6">6</option> <option id="7">7</option> <option id="8">8</option> <option id="9">9</option> <option id="10">10</option> </select> </td> <td> <select name="no2"> <option id="1" selected="selected">1</option> <option id="2">2</option> <option id="3">3</option> <option id="4">4</option> <option id="5">5</option> <option id="6">6</option> <option id="7">7</option> <option id="8">8</option> <option id="9">9</option> <option id="10">10</option> </select> </td> <td> <select name="no3"> <option id="1" selected="selected">1</option> <option id="2">2</option> <option id="3">3</option> <option id="4">4</option> <option id="5">5</option> <option id="6">6</option> <option id="7">7</option> <option id="8">8</option> <option id="9">9</option> <option id="10">10</option> </select> </td> <td><?php print $result;?></td> </tr> <tr> <td><input type="submit" value="submit" name="submit"></td> </tr> </table> </center> </form> Quote Link to comment https://forums.phpfreaks.com/topic/107630-solved-confused/#findComment-551700 Share on other sites More sharing options...
think-digitally Posted May 28, 2008 Author Share Posted May 28, 2008 Thats perfect, thankyou very much. Quote Link to comment https://forums.phpfreaks.com/topic/107630-solved-confused/#findComment-551702 Share on other sites More sharing options...
jonsjava Posted May 28, 2008 Share Posted May 28, 2008 please mark topic solved. Oh, and glad to help! Quote Link to comment https://forums.phpfreaks.com/topic/107630-solved-confused/#findComment-551704 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.