hackerman Posted November 10, 2006 Report Share Posted November 10, 2006 (edited) print("<tr><td class=rowhead>UpSpeed</td><td colspan=2 align=left><select name=upspeed>\n"); print("<option value=0>------</option>\n"); print("<option value=2>2MBit(~100kb/s+)</option>\n"); print("<option value=5>5MBit(~500kb/s)</option>\n"); print("<option value=10>10Mbit(~1mb/s+)</option>\n"); print("<option value=50>50Mbit(~5mb/s+)</option>\n"); print("<option value=100>100Mbit(~7mb/s+)</option>\n"); print("</select></tr>\n"); itka viss ok, bet, kad refresho vins nomainas uz ------ kads var ludzu pateikt ka izdarit lai paliek uz izveleto opciju? Edited November 10, 2006 by hackerman Link to comment Share on other sites More sharing options...
Delfins Posted November 10, 2006 Report Share Posted November 10, 2006 cookie+js vai php PS: `selected` atribūts Link to comment Share on other sites More sharing options...
hackerman Posted November 10, 2006 Author Report Share Posted November 10, 2006 eem...kaa jau man...nu kaa vienmer :D:D luudzu vari tieshaak paskaidrot? :D Link to comment Share on other sites More sharing options...
ray Posted November 10, 2006 Report Share Posted November 10, 2006 luudzu vari tieshaak paskaidrot? :D <option value="2" selected> Link to comment Share on other sites More sharing options...
Grey_Wolf Posted November 11, 2006 Report Share Posted November 11, 2006 (edited) :) Sii ir Ljoti biezji sastopama probleema :) Taadeelj jau sen esmu uzrakstijis nelielu f-ju kas ljau bez liekaam probleemaam atrisinaat so probzu... funkkciju skatiit SEIT ---- hackerman --> kaadeelj visu vadi aaraa ar Print? domaa taa buus programmesana ar PHP? tev tachu tur nav pat mainiigo.... (slikt stils + lieki noslogots serveris... + Print f-ja tur vispaar nav vajadziiga pietiktu ar Echo...) ---- Es dariitu shaadi: <?php // includojam f-ju GW_selectbokss_strings_string().. // skat : http://paste.php.lv/4691 $option_masivs[0][0]='----'; $option_masivs[0][1]='0'; $option_masivs[1][0]='2MBit(~100kb/s+)'; $option_masivs[1][1]='2'; $option_masivs[2][0]='5MBit(~500kb/s)'; $option_masivs[2][1]='5'; $option_masivs[3][0]='10Mbit(~1mb/s+)'; $option_masivs[3][1]='10'; ?> <html> <body> mans HTML <form > <select name="upspeed"> <?php GW_selectbokss_strings_string($option_masivs,$_POST['upspeed']); ?> </select> HTML turpinaas neskjiet ka saadi ir optimaalaak? Edited November 11, 2006 by Grey_Wolf Link to comment Share on other sites More sharing options...
KAC Posted November 11, 2006 Report Share Posted November 11, 2006 Grey_Wolf un ja peekshnji tam boxam vajag pielikt style vai ko citu, taisiisi jaunu f-ju? :) Link to comment Share on other sites More sharing options...
hackerman Posted November 11, 2006 Author Report Share Posted November 11, 2006 (edited) grey wolf negribu tevi apbeedinaat, bet izmantojot tavu piedaavaato versiju , man atkal neraadaas izveeleetais options bet gan ---- ... pagaidam izmantoju shitadu print("<tr><td class=rowhead>UpSpeed</td><td colspan=2 align=left><select name=upspeed>\n"); print("<option value=0" . ($user["upspeed"] == 0 ? " selected" : "") . ">------</option>\n"); print("<option value=2" . ($user["upspeed"] == 2 ? " selected" : "") . ">2MBit(~100kb/s+)</option>\n"); print("<option value=5" . ($user["upspeed"] == 5 ? " selected" : "") . ">5MBit(~500kb/s)</option>\n"); print("<option value=10" . ($user["upspeed"] == 10 ? " selected" : "") . ">10Mbit(~1mb/s+)</option>\n"); print("<option value=50" . ($user["upspeed"] == 50 ? " selected" : "") . ">50Mbit(~5mb/s+)</option>\n"); print("<option value=100" . ($user["upspeed"] == 100 ? " selected" : "") . ">100Mbit(~7mb/s+)</option>\n"); print("</select></tr>\n"); zinu ka neidomaajami noobiski , bet nu man nekad nav padevushies arrayi utt .. ;) bus kkad japamacas bet tagad pietruukst laika , ja vari luudzu uzraksti kaa nedaudz paarveerst to manu kodu , thx Edited November 11, 2006 by hackerman Link to comment Share on other sites More sharing options...
Grey_Wolf Posted November 12, 2006 Report Share Posted November 12, 2006 (edited) Grey_Wolf un ja peekshnji tam boxam vajag pielikt style vai ko citu, taisiisi jaunu f-ju? :) Nah... jaunu domaa ka nevar vinju papildinaat? Elementarna Vatson ;) Preciizi 19 simboli ;) function GW_selectbokss_strings_string($masivs,$izvele, $stils='') Un '<option '.$select1.' value="'.$masivs[$i][1].'" '.$stils.'>' Viss... + iisti pareizi nebuutu pa taisno gruust aaraa ar echo ... tapec: } #26 $bla_bla=$bla_bla. '<option '.......... #27 } #28 return $bla_bla; #29} Un pie izvades: echo GW_selectbokss_strings_string($masivs,$izvele) ;// Nevajag stilu echo GW_selectbokss_strings_string($masivs,$izvele,'class="mans krutais option stils vai cita draza ko gribu piekabinaat option tagaa "') ;// Vajag stilu Edited November 12, 2006 by Grey_Wolf Link to comment Share on other sites More sharing options...
andrisp Posted November 12, 2006 Report Share Posted November 12, 2006 Varbūt labāk būtu kautkā šādi: $select_tag = '<select name="selekts" class="bla">[options]</select>'; $option_tag = '<option value="[value]">[display_value]</option>'; echo GW_selectbokss_strings_string($options,$selected, $select_tag, $option_tag); // $select_tag un $option_tag ir definētas defaultās vērtības (lai obligāti nebūtu jāpadod) // izmantotu str_replace, lai aizvietotu [name] vērtības Šādi, domāju, būtu daudz fleksiblāk. Link to comment Share on other sites More sharing options...
Grey_Wolf Posted November 12, 2006 Report Share Posted November 12, 2006 andrisp --> nesaprati manu Domu gajienu ;) (un Es laikam tavu :( ) Es speciaali izvadu f-ja tikai <option> .... Jo Biezji naaks tos datus ielasiit no DB respektiivi: Logiskaa Dalja: Ielasam datus 2 dimensiju Masiivaa no DB (vienkarshi Nepilnas 10 koda rindinjas...) + nolasam defalto vertiibu.. Un peec tam HTML daljaa tikai ieliekam 1 PHP iespraudumu... kas izvada doto <option>.... <select> padodam plain teekstaa atkariibaa no Dizaina vajadziibaam.... P.S. 90% gadijumos mana f-ja ir Pilniigi atbilstosha darba specefikaacijai... un nodroshina vajadziigo funkcionalitaati.... (neba Esmu teicis ka taa Ir Panaceja....) Link to comment Share on other sites More sharing options...
andrisp Posted November 12, 2006 Report Share Posted November 12, 2006 Ā, nedaudz pārpratu gan tevi :). Bet neatsaucu savu piedāvāto skriptu, jo liekas labāk $option_tag = '<option value="[value]">[display_value]</option>'; echo GW_selectbokss_strings_string($options,$selected,$option_tag); nekā function GW_selectbokss_strings_string($masivs,$izvele, $stils='') Un '<option '.$select1.' value="'.$masivs[$i][1].'" '.$stils.'>' Link to comment Share on other sites More sharing options...
Recommended Posts