sfx Posted December 19, 2005 Report Share Posted December 19, 2005 Ir shaada forma: <form name="FormName" action="myscript.php" method="post"> <input name="Name1" type="radio" value="111" unchecked> <input name="Name1" type="radio" value="112" unchecked> <input name="Name2" type="radio" value="221" unchecked> <input name="Name2" type="radio" value="222" unchecked> ... <input name="Name99" type="radio" value="991" unchecked> <input name="Name99" type="radio" value="992" unchecked> </form> Kaa es varu izdrukaat visus iechekotos $Name[num] Link to comment Share on other sites More sharing options...
php_Stopp Posted December 19, 2005 Report Share Posted December 19, 2005 (edited) echo $_POST['Name1']; echo $_POST['Name2']; utt. aa.. iechekotos.. ;) atkal lasu pēc postēšanas :P Edited December 19, 2005 by php_Stopp Link to comment Share on other sites More sharing options...
sfx Posted December 19, 2005 Author Report Share Posted December 19, 2005 Njaa, tur jau taa lieta ka visi nebuus iechekoti. Link to comment Share on other sites More sharing options...
Klez Posted December 19, 2005 Report Share Posted December 19, 2005 echo $_POST['Name1']; echo $_POST['Name2']; echo $_POST['Name3']; //..... echo $_POST['Name99']; echo $_POST['Name100']; izdrukaasies iechekoto raadio veertiibas. nekaa neparasta tur nau ... primitiivs html .... no visas radio pogu grupas var atziimeet tikai vienu ... http://www.w3schools.com/html/html_forms.asp Link to comment Share on other sites More sharing options...
sfx Posted December 19, 2005 Author Report Share Posted December 19, 2005 <form name="FormName" action="myscript.php" method="post"> <input name="Name1" type="radio" value="111" unchecked> dati no DB <input name="Name1" type="radio" value="112" unchecked> dati no DB <input name="Name2" type="radio" value="221" unchecked> dati no DB <input name="Name2" type="radio" value="222" unchecked> dati no DB ... <input name="Name99" type="radio" value="991" unchecked> dati no DB <input name="Name99" type="radio" value="992" unchecked> dati no DB </form> Vienu nevar iechekot, var tikai iechekot vienu no, kam $name ir vienaadi (VALUE=111 vai VALUE 112). bet ir vel viena probleema - visi arii var nebuut iechekoti, bet man vajag tikai iechekotos un saskaitiit summu. Kaa to var panaakt. Link to comment Share on other sites More sharing options...
vladimirs Posted December 19, 2005 Report Share Posted December 19, 2005 domaat vaig. Link to comment Share on other sites More sharing options...
Delfins Posted December 20, 2005 Report Share Posted December 20, 2005 (edited) <input type="radio" name="name[1]" value="111" unchecked> <input type="radio" name="name[1]" value="211" unchecked> .. <input type="radio" name="name[99]" value="199" unchecked> <input type="radio" name="name[99]" value="299" unchecked> if ( !empty($_POST['name']) && is_array($_POST['name']) ) { $arr = $_POST['name']; $summa = array_sum( $arr ); $skaits = count( $arr ); } vladimirs, beidz vienreiz spamot ne pa temu Edited December 20, 2005 by Delfins Link to comment Share on other sites More sharing options...
bubu Posted December 20, 2005 Report Share Posted December 20, 2005 Delfins, aļo? Tur ir RADIO buttoni, nevis CHECKbokši :) Link to comment Share on other sites More sharing options...
Delfins Posted December 20, 2005 Report Share Posted December 20, 2005 a kāda starpība ? <input type="radio" name="name[1]" value="111" unchecked> <input type="radio" name="name[1]" value="122" unchecked> pie otrā radio čekošanas būs pieejama vērtība `122` .. un sumējam tāpat... PS: manā gadījumā kļūda bija iekš tā, ka bija name[].. jo biju domājis, ka tur bija checkboxi... ;) pamainam bišku name uz [X] .. un sumēšana paliek vecā... Link to comment Share on other sites More sharing options...
Klez Posted December 20, 2005 Report Share Posted December 20, 2005 primitiivs html: <input type="radio" name="name[1]" value="111" unchecked> <input type="radio" name="name[1]" value="122" unchecked> no shitaam divaam raadio pogaam var atķeksēt tikai vai nu vienu vai otru! sfx tev vaig paarbaudiit. ja tev taas pogas ir 100 tad vari ar ciklu taisiit tshis straadaas ja to pogu veertiibas buus tikai cipari <input type="radio" name="name_1" value="111" unchecked> <input type="radio" name="name_2" value="122" unchecked> $tot = FALSE; for($i=1;$i<=100;$i++){ if ($_POST['name_'.$i] == is_numeric($_POST['name_'.$i])){ //radio poga ir iekekseeta $tot .= $tot + $_POST['name_'.$i]; } } if ($tot) echo 'Kopaa sakekseets: ' . $tot; ceru ka bija tas ko vaig .. testeejis neesmu, bet vaidzeetu straadaat! Link to comment Share on other sites More sharing options...
Delfins Posted December 20, 2005 Report Share Posted December 20, 2005 Klez, nafig tā? to garo penteri/ciklu aiztājam ar count($_POST['name']) PS: neredzu jēgu skaitīt cik, jo vajag summa... array_sum lieliski tiks galā.. Link to comment Share on other sites More sharing options...
bubu Posted December 20, 2005 Report Share Posted December 20, 2005 Delfins, bet tur jau visiem nav vienādi name! (pirmajā postā). Tur ir vairākas grupas radiobuttonu! Link to comment Share on other sites More sharing options...
Delfins Posted December 20, 2005 Report Share Posted December 20, 2005 vai tad nedrīkst pamainīt radiobuttonu name ? Kāpēc autors to nepasaka uzreiz? PS: līka pieeja formai anyway... Klez variants der... bet es pamainītu Name tiem radiobuttoniem.. Link to comment Share on other sites More sharing options...
hmnc Posted December 20, 2005 Report Share Posted December 20, 2005 tik tiešām galīgi kreiss variants formai. ja autors tos 100 buttonus ir taisījis kā piemēru, tad iesaku padomāt par labāku piemēru, bet ja tas ir reāli tad man ir žēl lietotāju :) neko dižāku par caurbraukšanu ar foreach/for neuztaisīs, ja vajag zināt kas tieši ir iečekots. Link to comment Share on other sites More sharing options...
sfx Posted December 20, 2005 Author Report Share Posted December 20, 2005 (edited) Kas vainas ir formai [forma attachaa]. P.S. laikam nevar ielikt :( tomeer. Edited December 20, 2005 by sfx Link to comment Share on other sites More sharing options...
Recommended Posts