Sasa Posted January 2, 2008 Report Share Posted January 2, 2008 <TEXTAREA class=MsoTextbox id=file_name title="Jāievada faila nosaukumu zem kāda vēlaties saglabāt failu.Failu zem šī paša nosaukuma varēs atrast arī iekš CutPalnnera!" style="FONT-SIZE: 10pt; Z-INDEX: 12; OVERFLOW: hidden; WIDTH: 3.253cm; HEIGHT: 0.529cm; BACKGROUND-COLOR: #ffcc99; TEXT-ALIGN: left" tabIndex=26 cols=2></TEXTAREA> Ir textarea, un pie kāda nebūt ieraksta pievienošanās vajadzētu to textarea iekrāsot zaļā krāsā, bet nevaru izdomāt kādam ir jāiskatās javascriptam, kas man to realizētu! Link to comment Share on other sites More sharing options...
Aleksejs Posted January 2, 2008 Report Share Posted January 2, 2008 onchange="this.style.color='green';" Kaut kā tā.... Link to comment Share on other sites More sharing options...
andrisp Posted January 2, 2008 Report Share Posted January 2, 2008 (edited) Tas tev kaut kāds automātiski ģenerēts kods? Izskatās drausmīgi (un lieki piebilst - daudz kas tur ir nevajadzīgs.) Es darītu kaut kā šādi: el.onchange = function() { hasFilled(this); } el.onkeyup = function() { hasFilled(this); } function hasFilled(el) { if (el.value != '') { el.style.backgroundColor = 'green'; } } Edited January 2, 2008 by andrisp Link to comment Share on other sites More sharing options...
Sasa Posted January 2, 2008 Author Report Share Posted January 2, 2008 onChenge events man šķiet ka nederēs, jo tas tiek izsaukts tad kad jau ir izmainīts lauks un kursors novadīts no lauka prom. Varbūt var kaut kā sataisīt tā ka ja tiek kaut kas rakstīts tad automātiski notiek izmaiņas, nevis pēc tam kad vis ir izmainīt un sākts darīts kaut kas cits?! Link to comment Share on other sites More sharing options...
andrisp Posted January 2, 2008 Report Share Posted January 2, 2008 (edited) Un kā tu domā kāpēc tur ir arī tas onkeyup events ? Cik esmu testējis, tad vislabākā kombinācija ir tieši ar onchange un onkeyup (šie eventi tiks izsaukti gan rakstot, gan pazaudējot focusu(onblur), gan peistojot tekstu no citurienes). Edited January 2, 2008 by andrisp Link to comment Share on other sites More sharing options...
Aleksejs Posted January 2, 2008 Report Share Posted January 2, 2008 onKeyUp Link to comment Share on other sites More sharing options...
Paulinjsh Posted January 2, 2008 Report Share Posted January 2, 2008 onkeydown vai onkeyup neder? varbūt der onfocus un/vai onblur? Link to comment Share on other sites More sharing options...
marcis Posted January 2, 2008 Report Share Posted January 2, 2008 Pavisam teorētiski elementam textarea nav events onchange, tiek izmantots onblur. onchange laikam praktiski tiek izmantots tikai dropdown ( elements select ) Link to comment Share on other sites More sharing options...
Sasa Posted January 2, 2008 Author Report Share Posted January 2, 2008 realizēju šo lietu šādi: nezinu cik pareizi bet strādā (gribētos, lai darbojas on the flay, tas ir tā ka man lauks pārkrāsojas neatkarīgi vai ir laukā kursors vai nav): <script language=JavaScript event=onkeypress for=file_name> document.getElementById('file_name').style.background = '#caf1b3'; </SCRIPT> <script language=JavaScript event=onblur for=file_name> if(document.getElementById('file_name').value == ""){ document.getElementById('file_name').style.background = '#ffcc99'; } </SCRIPT> Link to comment Share on other sites More sharing options...
andrisp Posted January 2, 2008 Report Share Posted January 2, 2008 marcis, ko nu muldi :). Izgriezums no http://www.w3.org/TR/html4/interact/scripts.html: The onchange event occurs when a control loses the input focus and its value has been modified since gaining focus. This attribute applies to the following elements: INPUT, SELECT, and TEXTAREA. Link to comment Share on other sites More sharing options...
marcis Posted January 2, 2008 Report Share Posted January 2, 2008 Itkā jā, taču atceros, ka taisiju textarea ar eventu onchange - kautkas tur gļukoja.. Link to comment Share on other sites More sharing options...
Paulinjsh Posted January 2, 2008 Report Share Posted January 2, 2008 marcis nekad nekas nav gļukojis :) Link to comment Share on other sites More sharing options...
andrisp Posted January 2, 2008 Report Share Posted January 2, 2008 marcis, un tikai tāpēc pieņēmi, ka onchange nav paradzēts priekš textarea ? Vēl pietams piebilstot, ka "teorētiski" - it kā būtu kādā specifikācijā izlasījis. :) Link to comment Share on other sites More sharing options...
marcis Posted January 2, 2008 Report Share Posted January 2, 2008 Textarea events Link to comment Share on other sites More sharing options...
Aleksejs Posted January 2, 2008 Report Share Posted January 2, 2008 Mārci, un tevis norādītā lapa ir specifikācija? ;) Link to comment Share on other sites More sharing options...
Recommended Posts