• Inputting data into a form and getting data back as a set of combinations
    7 replies, posted
Title is probably making you go "huh?" so I'll try to explain. As a bit of background information, I play a game that deals with animal coat color genetics and some members want an accurate way of knowing what possible color combinations they could get. What I'm wanting to do is have a list of possible colors, input the parent genetics, then have the website spit out what the possible combinations are. For example, if I put in: Sire: Ee Dam: Ee The possible outcomes would be: EE (25%), Ee(50%), and ee(25%) However, in the game there's 18 different genes to deal with, but I figure what works with one set of genes would work with all of them. The only problem is that I have no idea how to do this. I'm assuming that I won't be able to do this purely in HTML and would need to use some sort of other programming language. Can anyone give me some suggestions/point me in the right direction? Here's a website that already does what I'm wanting to do, partially: [url]http://www.animalgenetics.us/CCalculator1.asp[/url]
I did an example using php. I think it's similar to what you want but I'm not sure due to not knowing anything about that genetic stuff. What the example does is take values from 2 dropdown boxes then the php finds the correct output. In the example if red and blue are selected it'll output purple. But it should point you in the right direction like you asked. [code] <body> <form action='color.php' method='POST'> <!-- Create our form **change the "color.php" to whatever this file is called.**--> <select name='color1'> <!-- Create first selection dropbox--> <option value="red">red</option> <option value="blue">blue</option> <option value="green">green</option> </select> <select name='color2'> <!-- Create second selection dropbox--> <option value="red">red</option> <option value="blue">blue</option> <option value="green">green</option> </select> <input type='submit' value='Submit'> <!-- Create submit button--> </form> <?php $color1 = $_POST['color1']; //Assign our data from the form to variables $color1 and $color2 $color2 = $_POST['color2']; if ((($color1 == "red") && ($color2 == "blue")) || (($color1 == "blue") && ($color2 == "red"))) { //If color one is equal to red and color two is equal to blue continue. (or vice-versa) echo ("purple"); //Print "purple" on the screen. } ?> </body> [/code]
I have no idea if that would work or not, to be perfectly honest. A full line of genetics would look like this: Extension: ee Agouti: Aa Creme: CcrC Roan: rnrn Dun: Dd Pearl: PrlPrl Silver: zz Champagne: chch Grey: gg White: ww Tobiano: toto Splash White: splspl Sabino: sbsb Rabicano: rbrb Frame: oo Leopard Complex: lplp PATN-1: patn-1patn-1 PATN-2: patn-2patn-2 You'd have to input two of these, one for the father, and one for the mother. Each line is an individual input with several different variations per line.
( [url]http://en.wikipedia.org/wiki/Punnett_square[/url] ) [img]http://upload.wikimedia.org/wikipedia/commons/thumb/2/22/Punnett_Square.svg/220px-Punnett_Square.svg.png[/img]
[QUOTE=cas97;25462484]( [url]http://en.wikipedia.org/wiki/Punnett_square[/url] ) [img_thumb]http://upload.wikimedia.org/wikipedia/commons/thumb/2/22/Punnett_Square.svg/220px-Punnett_Square.svg.png[/img_thumb][/QUOTE] Not everyone has the time or patience to do a square for each line of genetics, then put it all together. You'd be at it all day.
I'm still thinking about how to do this, but forget PHP. This can be done in javascript, there's no point in making additional requests to the server, using server resources and forcing the user to wait for a response when it can all be done quickly and safely on the client's side.
I've dealt with javascript before, but always premade scripts. Lol It's half tempting to e-mail the people that did the color calculator I linked to and see if they'll tell me how they did their calculator.
PHP can easily do it if a coherent programmer was to work at it.
Sorry, you need to Log In to post a reply to this thread.