localhero Posted February 28, 2008 Report Share Posted February 28, 2008 Ka varetu izveidot dinamiskas formas handleri. Tipa ir forma kurai lauku skaits mainas. Ir iespejams ka formai ir tikai viens <input> lauks iespejams ka 10. Link to comment Share on other sites More sharing options...
black Posted February 28, 2008 Report Share Posted February 28, 2008 (edited) Izmanto Javascript. Piemēram, pieliec zem inputiem kādu a elementu, tad uztaisi tam onclick eventu. Pēc tam izmanto document.createElement('input') lai izveidotu elementu un kaut kur formā pievienotu. EDIT: Cik advancētu to handleri vēlies? Edited February 28, 2008 by black Link to comment Share on other sites More sharing options...
localhero Posted March 1, 2008 Author Report Share Posted March 1, 2008 Tātad formu var aplūkot šeit(nav mans domeins): http://tobis.lv/zt/ Jautājums kā lai nosubmito šādu formu nerakstot ziljons rindiņu kodu ? Link to comment Share on other sites More sharing options...
Pentiums Posted March 1, 2008 Report Share Posted March 1, 2008 $darbs1 = "Cirkonijs"; $darbs2 = "Alumīnija gāze"; utt... Link to comment Share on other sites More sharing options...
localhero Posted March 1, 2008 Author Report Share Posted March 1, 2008 Ja bet ir iespejams ka visos 10 laukos ir cirkonijs vai aluminija gaze, katram darbam var but savs skaits + katram darbam ir savi specifiski papildus darbi ar savu skaitu. var protams katram darbam rakstit atsevisku handleri bet tas ir daudzrindiski. Es domāju to darīt ar funkcijas palīdzību, bet nevaru saprast kā lai padod $_POST vertibas. Link to comment Share on other sites More sharing options...
andrisp Posted March 1, 2008 Report Share Posted March 1, 2008 Izmanto HTML masīvus (name="field_name[]") un pēc tam PHP pusē ciklo cauri visiem elementiem. Link to comment Share on other sites More sharing options...
localhero Posted March 1, 2008 Author Report Share Posted March 1, 2008 Ok sapratu domu bet ka piesaistit darbam vertibu kas tiek izveleta ar citu <select> ? Link to comment Share on other sites More sharing options...
localhero Posted March 4, 2008 Author Report Share Posted March 4, 2008 (edited) Pēc vairāku dienu eksperimentiem risinājums ir šāds: if(isset($_POST['pievienot_pasutijumu'])) { $rezultats = mysql_query("INSERT INTO $pasutijumi(arsts, pacients, status) VALUES('" . $_POST['arsts'] . "','" . $_POST['pacients'] . "', 'jauns')"); $pasutijuma_id = mysql_insert_id(); $i = 0; $c = 0; $r = 0; foreach($_POST['darbs'] as $darbs) { if($darbs !== '') { echo $_POST['darbs']["$i"]; if($_POST['darbs']["$i"] !== '') { $rezultats = mysql_query("INSERT INTO $pd(nosaukums, vertiba, tips, pasutijuma_id) VALUES('" . $_POST['darbs']["$i"] . "', '" . $_POST['darba_vertiba']["$i"] . "', '32', '$pasutijuma_id')"); $darba_id = mysql_insert_id(); //Ieklaujam katra darba papildus darbu skaitu. include('reizes.php'); for($f = 0; $f <= $reizes; $f++) { if($_POST['pd_select']["$c"] == "ja") { $rezultats = mysql_query("INSERT INTO $pap_d32(nosaukums, vertiba, darba_id, pasutijuma_id) VALUES('" . $_POST['papd_nosaukums']["$r"] . "', '" . $_POST['papd_select']["$r"] . "', '$pasutijuma_id','$darba_id')"); $r++; } $c++; } } } $i++; } } Paldies andrisp par uzvedināšanau uz domu masīvi + cikli; Edited March 4, 2008 by localhero Link to comment Share on other sites More sharing options...
Recommended Posts