vvsh Posted July 22, 2008 Report Share Posted July 22, 2008 Как сделать временный текст в полях, как тут в мини-чате:http://saytbomba.at.ua/mchat/Спасибо. Quote Link to comment Share on other sites More sharing options...
0 Dimitry Wolotko Posted July 22, 2008 Report Share Posted July 22, 2008 Исходный код пропали Quote Link to comment Share on other sites More sharing options...
0 vvsh Posted July 22, 2008 Author Report Share Posted July 22, 2008 Поверь пробовал делать так как там, но только ничего не получилось. Quote Link to comment Share on other sites More sharing options...
0 Dimitry Wolotko Posted July 22, 2008 Report Share Posted July 22, 2008 А как ты делал? Quote Link to comment Share on other sites More sharing options...
0 vvsh Posted July 22, 2008 Author Report Share Posted July 22, 2008 Вот:<head><script type="text/javascript">function show_profile(uid){window.open('/index/8-'+uid);return false;}var wasclk=[];var init_val=['Имя','Email/WWW','Сообщение','Other 1','Other 2'];for(var ii=0;ii<init_val.length;ii++){init_val[ii]=init_val[ii].replace(/([0-9]+);/g,function (str,p1){return String.fromCharCode(parseInt(p1));} ).replace(/</g,'<').replace(/"/g,'"');}var fld_name=['uname','email','message','custom1','custom2'];function ffoc(e,i){if(wasclk[i]==0){e.value='';wasclk[i]=1;e.style.color='#000000'}if(tAct){clearTimeout(tID);tAct=false;document.getElementById("mchatRSel").selectedIndex=0;}}function fblur(e,i){if(e.value=='' && wasclk[i]==1){e.value=e.title;wasclk[i]=0;e.style.color='#808080';}}function initform() {f=document.forms['addform'];for(var i=0;i<init_val.length;i++) if(f[fld_name[i]]) {f[fld_name[i]].value=f[fld_name[i]].title=init_val[i];wasclk[i]=0;f[fld_name[i]].style.color='#808080';}var res=document.cookie.match(/(W|^)mcnm=([^;]+)/);if(res){ffoc(f.uname,0);f.uname.value=unescape(RegExp.$2);}res=document.cookie.match(/(W|^)mcem=([^;]+)/);if(res && f.email){ffoc(f.email,1);f.email.value=unescape(RegExp.$2);}}function checkform(f) {for(var i=0;i<init_val.length;i++)if(f[fld_name[i]]){if(wasclk[i]==0)f[fld_name[i]].value='';wasclk[i]=2;f[fld_name[i]].style.color='#000000';}var t=new Date((new Date()).getTime()+86400*90);document.cookie="mcnm="+(f.uname.value.length>0?escape(f.uname.value):'')+"; path=/mchat; expires="+t.toGMTString();document.cookie="mcem="+(f.email && f.email.value.length>0?escape(f.email.value):'')+"; path=/mchat; expires="+t.toGMTString();if(f[fld_name[1]])if(f[fld_name[1]].value.length>0 && !f[fld_name[1]].value.match(/^[a-z0-9_.-]+@[a-z0-9_.-]+$/i)){f[fld_name[1]].name='url';}if (document.getElementById('ajaxFlag') && document.getElementById('ajaxFlag').value==1){ if (document.getElementById('mchatBtn')){document.getElementById('mchatBtn').disabled=true;} uz.util.Connect.setForm('addform');var cObj=uz.util.Connect.asyncRequest('POST',document.addform.action,callback); return false;}else {window.open('','mchatmsg','width=300,height=140,top=0,left=0');}return true;}var tID=null;var tAct=false;function setT(s){var v=parseInt(s.options[s.selectedIndex].value);document.cookie="mcrt="+s.selectedIndex+"; path=/mchat";if(tAct){clearTimeout(tID);tAct=false;}if(v>0){tID=setTimeout("window.location.reload()",v*1000);tAct=true;}}function initSel() {var res=document.cookie.match(/(W|^)mcrt=([0-9]+)/);if(res){s=document.getElementById("mchatRSel");s.selectedIndex=parseInt(RegExp.$2);setT(s);}}</script></head><input name="name" type="text" value="" onfocus="ffoc(this,0)" onblur="fblur(this,0)" title="Имя" style="width:73px;margin:0;padding:1px;height:20px">У меня получается пустое поле. Quote Link to comment Share on other sites More sharing options...
0 Victor Ananiev Posted July 23, 2008 Report Share Posted July 23, 2008 Мне кажется там все легко, не вижу в чем загвоздка онБлур онФокус, обращение к обьекту, value. Вроде все назвал) Ну еще там со строкой состояния прикол, маусовер маусаут, self.status. Теперь все. Quote Link to comment Share on other sites More sharing options...
0 vvsh Posted July 23, 2008 Author Report Share Posted July 23, 2008 Я же дал свой код, который я брал с http://saytbomba.at.ua/mchat/Он не работает, почему? Quote Link to comment Share on other sites More sharing options...
0 Victor Ananiev Posted July 23, 2008 Report Share Posted July 23, 2008 Я не понял что нужно, если просто временный текст в полях, то сейчас сверстаю и выложу. А сказать почему не работает не могу, легче переверстать)) Quote Link to comment Share on other sites More sharing options...
0 vvsh Posted July 23, 2008 Author Report Share Posted July 23, 2008 Мне надо сделать также как на укозе, и чтобы не было такого что кто-то ввел имя, а потом написал сообщение, и увидел ошибку в имени, исправил, снова нажимает на поле с сообщением, а оно исчезает. Quote Link to comment Share on other sites More sharing options...
0 Victor Ananiev Posted July 23, 2008 Report Share Posted July 23, 2008 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"><html><head><title>Nokia 6300 - обзоры, софт, прошивки, игры, приложения.</title><meta http-equiv="Content-Type" content="text/html; charset=windows-1251"><style type="text/css"></style><script language="javascript" type="text/javascript">function blurfld(fldid){if(document.getElementById(fldid).value=="") { document.getElementById(fldid).value="Clear Field "; }}function focusfld(fldid){ if(document.getElementById(fldid).value=="Clear Field ") { document.getElementById(fldid).value=""; }}function loader(){blurfld("bla");}document.onload=loader;</script></head><body><form> <input onfocus="focusfld('bla');" onblur="blurfld('bla');" type="text" id="bla" /></form></body></html>У меня в опере работает. Пробелы вконце для перестраховки, если в поле будет вписано Clear Field, не думаю что 3 пробела, это будет обязательным атрибутом)) Quote Link to comment Share on other sites More sharing options...
0 vvsh Posted July 23, 2008 Author Report Share Posted July 23, 2008 Спасибо огромное. Quote Link to comment Share on other sites More sharing options...
0 Victor Ananiev Posted July 23, 2008 Report Share Posted July 23, 2008 Незачто) Quote Link to comment Share on other sites More sharing options...
0 Pavel_html Posted July 23, 2008 Report Share Posted July 23, 2008 Как сделать временный текст в полях, как тут в мини-чате:http://saytbomba.at.ua/mchat/Спасибо.и ты называешь себя Master? Quote Link to comment Share on other sites More sharing options...
0 vvsh Posted July 23, 2008 Author Report Share Posted July 23, 2008 Я не говорил что знаю JavaScript. Quote Link to comment Share on other sites More sharing options...
0 vvsh Posted July 23, 2008 Author Report Share Posted July 23, 2008 Да, в опере работает, а вот в Firefox нет. Quote Link to comment Share on other sites More sharing options...
0 Victor Ananiev Posted July 23, 2008 Report Share Posted July 23, 2008 Сейчас проверю))upd: там не работает событие онлоад.upd: вместо document.onload юзаем window.onload. Google >> Вторая страница Quote Link to comment Share on other sites More sharing options...
0 Pavel_html Posted July 23, 2008 Report Share Posted July 23, 2008 я сегодня добрый.<<form name="form"><input type="text" name="name" value="Имя" onClick="if(document.form.name.value=='Имя'){document.form.name.value=''}" onBlur="if(document.form.name.value==''){document.form.name.value='Имя'}"></form> Quote Link to comment Share on other sites More sharing options...
0 Victor Ananiev Posted July 23, 2008 Report Share Posted July 23, 2008 Ага, подскажите мне добрый, а при потере фокуса разве появляется слово имя?)) ваш пример надо доработать Quote Link to comment Share on other sites More sharing options...
0 Pavel_html Posted July 23, 2008 Report Share Posted July 23, 2008 я доработал Quote Link to comment Share on other sites More sharing options...
0 Pavel_html Posted July 23, 2008 Report Share Posted July 23, 2008 http://piskun-pavel.spb.ru Quote Link to comment Share on other sites More sharing options...
0 Maslakoff Posted July 23, 2008 Report Share Posted July 23, 2008 О_о не въехал, но могу написать упрощенный вариант:<input type="text" value="Имя" onfocus="this.value=(this.value=='Имя' ? '' : this.value);" onblur="this.value=(this.value=='' ? 'Имя' : this.value);" /> Quote Link to comment Share on other sites More sharing options...
0 vvsh Posted July 23, 2008 Author Report Share Posted July 23, 2008 Спасибо тебе огромное Maslakoff. Quote Link to comment Share on other sites More sharing options...
0 Victor Ananiev Posted July 23, 2008 Report Share Posted July 23, 2008 to pavel_htmlА если какой то вася вместо своего имени напишет слово Имя, тогда капец, надо писать несколько пробелов вконце. И у меня решение универсальней, прикинь если полей для заполнения 8, или даже 4. Сколько писать! А так только функции попрописывать, а если что то поменять надо в этом коде рытся? Ты что))По поводу сайта:1)Ты не думал про ускорение работы.2)Эту ссылку в обсуждение работ.to maslakoffну мне кажется что функции прописывать лучше) так загромаждение. Quote Link to comment Share on other sites More sharing options...
0 vvsh Posted July 23, 2008 Author Report Share Posted July 23, 2008 Никто не будет писать просто Имя. Quote Link to comment Share on other sites More sharing options...
0 vvsh Posted July 23, 2008 Author Report Share Posted July 23, 2008 Вот можете посмотреть:http://www.assassins-creed.net/news.php Quote Link to comment Share on other sites More sharing options...
0 Maslakoff Posted July 23, 2008 Report Share Posted July 23, 2008 Pavel_html, фото прикольные, но это разве в теме? Quote Link to comment Share on other sites More sharing options...
Question
vvsh
Как сделать временный текст в полях, как тут в мини-чате:
http://saytbomba.at.ua/mchat/
Спасибо.
Link to comment
Share on other sites
25 answers to this question
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.