Jump to content


  • Posts

  • Joined

  • Last visited

FeverZebra's Achievements


Newbie (1/7)



  1. Never got that <?php TEXTTEXTEX ?> inside a form to work... This is where my "issue" are: <?phpecho("<table width='700' border='0' cellspacing='0'><tr><td>");echo("<form action='' method='get'><p> <h2> Välj ras: </h2></p><p><table><tr><td><input type='radio' name='ras' value='alv' /> Alv<br /><input type='radio' name='ras' value='bhorgol' /> Bhorgol<br /><input type='radio' name='ras' value='dvarg' /> Dvärg<br /></td><td><input type='radio' name='ras' value='manniska' /> Människa<br /><input type='radio' name='ras' value='troll' /> Troll<br /><input type='radio' name='ras' value='ork' /> Ork</td></tr></table></p>);?> It just returns error if I add what you surguested. My whole code including the form is inside a PHP and everything works part from returning the selected value.
  2. Preserve, I will need a validate script later but at the moment I just want the button choice to be preserved after submit.
  3. So you mean I can have php check which one were marked and "retype" it when you press submit?
  4. Yeah, I understand that. My question were if it is possible to return the selected one when the page "reloads" as I do with the "echo "<input type='text' value='{$_GET['field']}' name='field' />";". Meaning: when I push submit with alot of values and 1/6 radio buttons selected it will return the results but still save what you typed inside the form, including which radio button you selected. Will defeat the purpose of having radio buttons. Radio buttons are OR not AND. If I want alternative 1 I won't be able to select alternative 2 aswell. If I wanted that type of function I'd use checkboxes instead
  5. Okay, gotta make me a JS then^^ But I've made it work now thanks to your input birbal. Can I do something similar with radio buttons? I've 6 alternatives, you must check one to proceede. Problem being they all have the same name...
  6. Right... I don't get it to work even if I put the HTML form inside php with everyting else. It works but I can't make the form keep whatever I wrote when I push submit, it's as if I reseted it. I struggle with understanding here:1. The page loads, code is read but no values are there yet so the only thing I see is the form.2. I add numbers in my form and push "submit". The page "reload" and now I can see an empty form and the results. If I add something like php inside the form which is inside a php to begin with it will not work. To me it seems like sence there's no value in the form to begin with it will not write a value. However, adding a value can only be done through the form... Like a circle with no begining or end. While on it, is it possible to prevent submiting (without reseting the fields) if something doesn't have a value? Must I make a script for that?
  7. Ups, I saw now what made it fail. Thanks for the colored texts, forgot how usefull they can be
  8. array(16) { ["ras"]=> string(3) "alv" ["halsa"]=> string(2) "10" ["uth"]=> string(2) "10" ["sb"]=> string(2) "10" ["inlar"]=> string(2) "10" ["ls"]=> string(2) "10" ["ska"]=> string(2) "10" ["ini"]=> string(2) "10" ["oe"]=> string(2) "11" ["ua"]=> string(2) "10" ["hugg"]=> string(2) "10" ["kross"]=> string(2) "10" ["katting"]=> string(2) "10" ["skold"]=> string(2) "10" ["stick"]=> string(2) "10" ["Submit"]=> string(6) "Submit" } Is what I get if I add "var_dump ($_GET);" in the begining, I assume this just types what every var have as value? Because it sure looks like it and it looks totally correct. I think the problem lies in the form. You have the php/form thing here normedico.com/are_calc.php as you can see the form have "<?php echo $ha; ?>" as starting value in one inputfield. However it disapears when you push submit and there will be no "reinput" of the value you type It is just frustrating... I'm sorry if I didn't understand your previous post fully but I'm fairely new to the thermonology and English isn't my native tongue :/
  9. Both those codes are on the same page, and the page is ".php". Yes, I understand the way it should work.You type something -> you press submit -> a variable $var gets the value of "something" -> php writes $var where you wrote "something" -> you'll see the result + you'll still have the "something" inside the form field. Right? To me it seems as if the <?php echo $var; ?> in my form as value does not work. Notpad++ don't show it as "grey", it's shown as code and the submitfield have that string"<?php echo..." as a starting text. And btw "GET" should not be a problem, should it?
  10. All? Right... I've only tested with the first line though. Looking through my code I can't see any differances :/ <form action="" method="get"><p> <h1> Välj ras: </h1></p><p><input type="radio" name="ras" value="alv" /> Alv<br /><input type="radio" name="ras" value="bhorgol" /> Bhorgol<br /><input type="radio" name="ras" value="dvarg" /> Dvärg<br /><input type="radio" name="ras" value="manniska" /> Människa<br /><input type="radio" name="ras" value="troll" /> Troll<br /><input type="radio" name="ras" value="ork" /> Ork</p><p> <h1> Fysik: </h1><table width="200" height="auto" border="0" cellspacing="0"> <tr style="background: #F0F0F0;"><td style="padding-top:5px">Hälsa:</td><td align="right"><input type="text" name="halsa" value="<?php echo $ha; ?>" size="5" maxlength="15" /></td></tr> <tr><td style="padding-top:5px">Uthållighet:</td><td align="right"><input type="text" name="uth" value="" size="5" maxlength="15" /></td></tr> <tr style="background: #F0F0F0;"><td style="padding-top:5px">Skadebonus:</td><td align="right"><input type="text" name="sb" value="" size="5" maxlength="15" /></td></tr></table></p><p> <h1> Intelligens: </h1><table width="200" height="auto" border="0" cellspacing="0"> <tr style="background: #F0F0F0;"><td style="padding-top:5px">Inlärningsförmåga:</td><td align="right"><input type="text" name="inlar" value="" size="5" maxlength="15" /></td></tr> <tr><td style="padding-top:5px">Ledarskap:</td><td align="right"><input type="text" name="ls" value="" size="5" maxlength="15" /></td></tr> <tr style="background: #F0F0F0;"><td style="padding-top:5px">Skarpsinne:</td><td align="right"><input type="text" name="ska" value="" size="5" maxlength="15" /></td></tr></table></p><p> <h1> Smidighet: </h1><table width="200" height="auto" border="0" cellspacing="0"> <tr style="background: #F0F0F0;"><td style="padding-top:5px">Initiativ:</td><td align="right"><input type="text" name="ini" value="" size="5" maxlength="15" /></td></tr> <tr><td style="padding-top:5px">Obeväpnad strid:</td><td align="right"><input type="text" name="oe" value="" size="5" maxlength="15" /></td></tr> <tr style="background: #F0F0F0;"><td style="padding-top:5px">Undvika Anfall:</td><td align="right"><input type="text" name="ua" value="" size="5" maxlength="15" /></td></tr> <tr><td style="padding-top:5px">Huggvapen:</td><td align="right"><input type="text" name="hugg" value="" size="5" maxlength="15" /></td></tr> <tr style="background: #F0F0F0;"><td style="padding-top:5px">Krossvapen:</td><td align="right"><input type="text" name="kross" value="" size="5" maxlength="15" /></td></tr> <tr><td style="padding-top:5px">Kättingvapen:</td><td align="right"><input type="text" name="katting" value="" size="5" maxlength="15" /></td></tr> <tr style="background: #F0F0F0;"><td style="padding-top:5px">Sköld:</td><td align="right"><input type="text" name="skold" value="" size="5" maxlength="15" /></td></tr> <tr><td style="padding-top:5px">Stickvapen:</td><td align="right"><input type="text" name="stick" value="" size="5" maxlength="15" /></td></tr></table></p><p><br /> <input type='submit' name='Submit' value='Submit' /></p></form> and the PHP script: <?php$ras = $_GET['ras'];$ha = $_GET['halsa'];$uth = $_GET['uth'];$sb = $_GET['sb'];$ska = $_GET['ska'];$ls = $_GET['ls'];$inl = $_GET['inlar'];$ini = $_GET['ini'];$oe = $_GET['oe'];$ua = $_GET['ua'];$hug = $_GET['hugg'];$kro = $_GET['kross'];$kat = $_GET['katting'];$sti = $_GET['stick'];$sko = $_GET['skold']; if($ras == "alv"){ $haA = $ha * 0.9; $uthA = $uth * 1.2; $sbA = $sb * 0.9; $skaA = $ska * 1.3; $lsA = $ls; $inlA = $inl * 1.5; $iniA = $ini * 1.4; $oeA = $oe * 1.1; $uaA = $ua * 1.5; $hugA = $hug * 1.2; $kroA = $kro; $katA = $kat; $stiA = $sti * 1.3; $skoA = $sko * 1.2; echo("<h1>Ras: Alv</h1>\n"); echo("<h2>Fysik:</h2>\n"); echo("<table width='300' height='auto' border='0' cellspacing='0'> <tr><td>Egenskap</td><td align='right'>Poäng</td><td align='right'><b>Ung</b></td><td align='right'>Vuxen</td><td align='right'><b>Medel</b></td></tr> <tr style='background: #F0F0F0;'><td>Hälsa:</td><td align='right'>$ha</td><td align='right'><b>" . floor($haA) . "</b></td><td align='right'>" . floor($haA*1.102) . "</td><td align='right'><b>" . $_GET['halsa']*0 . "</b></td></tr> <tr><td>Uthållighet:</td><td align='right'>$uth</td><td align='right'><b>" . floor($uthA) . "</b></td><td align='right'>" . floor($uthA*1.106) . "</td><td align='right'><b>" . $_GET['halsa']*0 . "</b></td></tr> <tr style='background: #F0F0F0;'><td>Skadebonus</td><td align='right'>$sb</td><td align='right'><b>" . floor($sbA) . "</b></td><td align='right'>" . floor($sbA*1.1) . "</td><td align='right'><b>" . $_GET['halsa']*0 . "</b></td></tr></table>"); echo("<h2>Intelligens:</h2>\n"); echo("<table width='300' height='auto' border='0' cellspacing='0'> <tr><td>Egenskap</td><td align='right'>Poäng</td><td align='right'><b>Ung</b></td><td align='right'>Vuxen</td><td align='right'><b>Medel</b></td></tr> <tr style='background: #F0F0F0;'><td>Inlärning:</td><td align='right'>$inl</td><td align='right'><b>" . floor($inlA) . "</b></td><td align='right'>" . floor($inlA*1.052) . "</td><td align='right'><b>" . $_GET['halsa']*0 . "</b></td></tr> <tr><td>Ledarskap:</td><td align='right'>$ls</td><td align='right'><b>" . floor($lsA) . "</b></td><td align='right'>" . floor($lsA*1.07) . "</td><td align='right'><b>" . $_GET['halsa']*0 . "</b></td></tr> <tr style='background: #F0F0F0;'><td>Skarpsinne:</td><td align='right'>$ska</td><td align='right'><b>" . floor($skaA) . "</b></td><td align='right'>" . floor($skaA*1.052) . "</td><td align='right'><b>" . $_GET['halsa']*0 . "</b></td></tr></table>"); echo("<h2>Smidighet:</h2>\n"); echo("<table width='300' height='auto' border='0' cellspacing='0'> <tr><td>Egenskap</td><td align='right'>Poäng</td><td align='right'><b>Ung</b></td><td align='right'>Vuxen</td><td align='right'><b>Medel</b></td></tr> <tr style='background: #F0F0F0;'><td>Initiativ:</td><td align='right'>$ini</td><td align='right'><b>" . floor($iniA) . "</b></td><td align='right'>" . floor($iniA*0.958) . "</td><td align='right'><b>" . $_GET['halsa']*0 . "</b></td></tr> <tr><td>Obeväpnad strid:</td><td align='right'>$oe</td><td align='right'><b>" . floor($oeA) . "</b></td><td align='right'>EI</td><td align='right'><b>" . $_GET['halsa']*0 . "</b></td></tr> <tr style='background: #F0F0F0;'><td>Undvika anfall:</td><td align='right'>$ua</td><td align='right'><b>" . floor($uaA) . "</b></td><td align='right'>" . floor($uaA*0.947) . "</td><td align='right'><b>" . $_GET['halsa']*0 . "</b></td></tr> <tr><td>Huggvapen:</td><td align='right'>$hug</td><td align='right'><b>" . floor($hugA) . "</b></td><td align='right'>" . floor($hugA*1.05) . "</td><td align='right'><b>" . $_GET['halsa']*0 . "</b></td></tr> <tr style='background: #F0F0F0;'><td>Krossvapen:</td><td align='right'>$kro</td><td align='right'><b>" . floor($kroA) . "</b></td><td align='right'>" . floor($kroA) . "</td><td align='right'><b>" . $_GET['halsa']*0 . "</b></td></tr> <tr><td>Kätting:</td><td align='right'>$kat</td><td align='right'><b>" . floor($katA) . "</b></td><td align='right'>EI</td><td align='right'><b>" . $_GET['halsa']*0 . "</b></td></tr> <tr style='background: #F0F0F0;'><td>Sköld:</td><td align='right'>$sko</td><td align='right'><b>" . floor($skoA) . "</b></td><td align='right'>EI</td><td align='right'><b>" . $_GET['halsa']*0 . "</b></td></tr> <tr><td>Stickvapen:</td><td align='right'>$sti</td><td align='right'><b>" . floor($stiA) . "</b></td><td align='right'>" . floor($stiA) . "</td><td align='right'><b>" . $_GET['halsa']*0 . "</b></td></tr></table>"); }elseif($ras == "ork"){ echo("Hälsa: " . $_GET['halsa'] . "<br />\n"); }else { echo ("<h1>Du har inte valt ras. Tryck bakåt så kommer dina värden att åter finnas och du behöver bara välja ras </h1><br />\n"); }echo("<h2>Övrigt:</h2>\nTotalt antal poäng: " . floor($ha+$uth+$sb+$ls+$ska+$inl+$ini+$oe+$ua+$hug+$kat+$sti+$kro+$sko) . "<br />");if ($ras == "alv"){ echo("Totalt antal poäng inklusive rasbonusar (som ung): ". floor($haA+$uthA+$sbA+$lsA+$skaA+$inlA+$iniA+$oeA+$uaA+$hugA+$katA+$stiA+$kroA+$skoA) . "");}else{ echo("Totalt antal poäng inklusive rasbonusar: fel");}?> My rhough would be to use (as you can see) the value input under "halsa", put it into "$ha" and use your small string as value, "<?php echo $ha; ?>". Must be missing something I guess...
  11. Trying this with "value". However, it do not work. This is what I've written: <form action="document.php" method="get"> <input type="text" name="txtName" value="<?php echo $name; ?>" /> <input type="submit" name="btnName" value="Click Me" /></form> With this PHP code: <?php $name = $_GET['txtName'];?> document.php is the same document the code is writen in. Is it because I use the method "get"? I want "GET" because then you can make more convinient links and bookmark stuff. I'm not that experianced with Java but I think i could figure stuff out with some help by google and asking around or simply try. That's also why I was unsure where to put this post^^ Btw, why is the row with "<input type="text" name="txtName" value="<?php echo $name; ?>" />" not colored?
  12. FeverZebra

    Realtime form

    Hello there. I've been trying to find useful information with google but I'm not sure what I should look for hence I've failed... Is it possible to make a form which gives results right away, without a "submit" button? Say for instance:34*X=Y X is the value you put into the "form inputbox".Y is the result. If I type 10, then klick another box then I want Y to become 340 without having to push a submit/calculate button. Is this possible? At the moment I've a form and a script on the same page. However, I've to push submit to se the results. When I submit the form is reseted. If I can't make a "realtime script" then can I have the form NOT reseting when I submit? Thanks a bunch, and sorry if I've posted in the wrong category!/W
  • Create New...