Blitz Posted October 14, 2005 Report Share Posted October 14, 2005 Lieta ir tada... forma select uninput lauki. Vajag taa lai lietotajs vienreiz izveloties select vertibu, vinam taa nebutu jamaina visu sesijas laiku, ertibas labad. Tip parejam uz nakamo lapu, tur tas pats selects bet ieprieks iestatitaa vertiba jau saglabajusies, un nav atkal jamekle pa selectu! Vai ir kads specials formas vai input atributs/funkcija, kas to visu izdara vai ari jataisa php skripts? Link to comment Share on other sites More sharing options...
Delfins Posted October 14, 2005 Report Share Posted October 14, 2005 (edited) cookie + JS function preloadForm() { var selIdx = getCookieVar( 'select_1_idx' ); var forma = document.forms["forma"]; forma.select_1.selectedIndex = selIdx; } getCookieVar() var atrast netā... Bet es nesaprotu, ja tev ir lapas un tiek izmantots PHP/whatever ... vieglāk ir serverside sesijā saglabāt... Edited October 14, 2005 by Delfins Link to comment Share on other sites More sharing options...
Blitz Posted October 14, 2005 Author Report Share Posted October 14, 2005 (edited) es jau vinu ari domaju glabat serverside sesijaa... Tas iznak padot selIdx pa $_SESSION['selIdx']... tas iznak kaut kas lidzigs... function preloadForm() { $selIdx=$_SESSION['selIdx']; forma.select_1.selectedIndex = $selIdx; } .. ja es pareizi saprotu! Papildjautajums nr1. selIdx veidojas kaa selecta value vai vai <option>selIdx<br>???? Papildjautajums nr2. Ja izmanto "forma.select_1.selectedIndex = $selIdx;", tad kaa lai vinu ievietoju php kodaa? Cik noprotu javaskripts... echo "<script> forma.select_1.selectedIndex = $selIdx; </script>" P.S. ar JavaScript pat neesu uz "juus" Edited October 14, 2005 by Blitz Link to comment Share on other sites More sharing options...
Delfins Posted October 14, 2005 Report Share Posted October 14, 2005 es neko nesaprotu no tava teksta.............. Tu vispār PHP tur izmanto? Un ko tas selekts dara ? Link to comment Share on other sites More sharing options...
v3rb0 Posted October 14, 2005 Report Share Posted October 14, 2005 kaa tu to formu taisi. parasti taadas fromas ar veertiibaam aizpilda genereejot formu (ar pliku php vai templateem vai veel kaa) bet ne caur klienta gala javascriptu (varbuut iznemot dazos gadijumos ar ajax, kad negribaas 2x rakstiit vienu un to pasu ij uz php ij uz js). Link to comment Share on other sites More sharing options...
Delfins Posted October 14, 2005 Report Share Posted October 14, 2005 Tā ir vieta kur tu taisi savu selektu while ( .. ) { $sel = ( $_SESSION['selIdx'] == $val ) ? 'selected' : ''; print '<option value="'.$val.'" '.$sel.'>'.$str.'</option>'; } Link to comment Share on other sites More sharing options...
Blitz Posted October 14, 2005 Author Report Share Posted October 14, 2005 protams php izmantoju... selektaa ir menesa nosaukumi... <form action='sum.php' method='POST'> <select name='Men'> <option value='01'>Janvaris<br> <option value='02'>Februaris<br> <option value='03'>Marts<br> <option value='04'>Aprilis<br> <option value='05'>Maijs<br> <option value='06'>Junijs<br> <option value='07'>Julijs<br> <option value='08'>Augusts<br> <option value='09'>Septembris<br> <option value='10'>Oktobris<br> <option value='11'>Novembris<br> <option value='12'>Decembris<br> </select>"; ieksh sum.php ir tads pats selekts, un vajag lai jau iprieks izveletais menesis ieksh sum.php paradas kaa defult... piemeram Augusts nevis Janvaris Link to comment Share on other sites More sharing options...
v3rb0 Posted October 14, 2005 Report Share Posted October 14, 2005 (edited) if( izveeleets ir augusts) { echo '<option selected="selected">augusts</option>' } Edited October 14, 2005 by v3rb0 Link to comment Share on other sites More sharing options...
goldy Posted October 14, 2005 Report Share Posted October 14, 2005 selected pieliec klaat izveeleetajam option un viss. ko tev tas <br> tur ieks option dara Link to comment Share on other sites More sharing options...
Blitz Posted October 14, 2005 Author Report Share Posted October 14, 2005 thanks, sitas laikam deres! Gan jau izdomasu, kaa talak realizet... PS <br> man strada taa pat kaa </option>, nezinu kapec no sakuma liku <br>, bet starda normali... Link to comment Share on other sites More sharing options...
zuiks Posted October 14, 2005 Report Share Posted October 14, 2005 Vai tā nevarētu: Pirmais fails: http://paste.php.lv/2638 sum.php fails http://paste.php.lv/2639 Link to comment Share on other sites More sharing options...
v3rb0 Posted October 14, 2005 Report Share Posted October 14, 2005 prieks kam to dropdownu divaas+ vietaas.. uztaisi f-ju ar vienu argumentu ar defaulto vertibu '-1' kas izgruuz aaraa meenesu sarakstu un ieselectee to meenesi kurs padots kaa arguments. Link to comment Share on other sites More sharing options...
Paulinjsh Posted October 14, 2005 Report Share Posted October 14, 2005 Tas 2. fails ir baigais murgs.. Link to comment Share on other sites More sharing options...
Delfins Posted October 14, 2005 Report Share Posted October 14, 2005 klausi v3rb0 :) A vēl labāk uztaisi klasi, kas mācēs i gadus, i mēnešus i dienas izavdīt Link to comment Share on other sites More sharing options...
Recommended Posts