Navigacija
Lista poslednjih: 16, 32, 64, 128 poruka.

Span to Input to Span replace

[es] :: Javascript i AJAX :: Span to Input to Span replace

[ Pregleda: 1725 | Odgovora: 1 ] > FB > Twit

Postavi temu Odgovori

Autor

Pretraga teme: Traži
Markiranje Štampanje RSS

sojic
Dalibor Sojic
Makedonija

Član broj: 7051
Poruke: 796
80.77.156.*

Sajt: right-sock.net


+1 Profil

icon Span to Input to Span replace21.09.2008. u 21:29 - pre 189 meseci
Trebam napraviti neki formular, ali hocu da to ne bude klasicni formular sa input boxova, vec da bude text. Kad se klikne "u polje" da se zameni sa input box-a, a kad se "defokusira" da se vrati u span.

Nasao sam takvu skriptu, ali jednosmarna. Span pretvara u Input, ali meni treba "dodatak" koji ce, kad se promeni input, i "onblur" da se vrati span.

Evo skripte
Code:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<title>Span to Text Box - Demo - DOM</title>
<script type="text/javascript">
/* © John Davenport Scheuer */
function exchange(el){
var nodeI=el.parentNode, inputC=document.createElement('input'), text=el.innerHTML;
el.style.font='.9em "ms sans serif", "sans"'
el.innerHTML+='\x20'
with (inputC){
setAttribute('value', text, 0)
setAttribute('size', text.length-1, 0)
style.width=document.all&&!window.opera? el.offsetWidth-2+'px' : el.offsetWidth+2+'px'
setAttribute('type', 'text', 0)
setAttribute('id', el.id, 0)
setAttribute('readonly', true, 0)
}
nodeI.replaceChild(inputC, el)
}
</script>
</head>
<body>
<span id="itm1" onclick="exchange(this)">House</span><br>
<span id="itm2" onclick="exchange(this)">SpantoTextBox-Demo</span><br>
<span id="itm3" onclick="exchange(this)">Span to Text Box - Demo exchange(this)</span><br>
<input id="itm4" type="text" value="Existing Text Box"><br>
<span id="itm5" onclick="exchange(this)">In Line Test</span>
<span id="itm6" onclick="exchange(this)">In Line Test Too</span>
<span id="itm7" onclick="exchange(this)">In Line Test Also</span>
</body>
</html>

routing protocols enable routers to route routed protocols!
 
Odgovor na temu

sojic
Dalibor Sojic
Makedonija

Član broj: 7051
Poruke: 796
80.77.156.*

Sajt: right-sock.net


+1 Profil

icon Re: Span to Input to Span replace21.09.2008. u 23:15 - pre 189 meseci
Nasao sam. Evo "demo"-a http://www.dalibor-sojic.info/formulari/baranje-za-gradba.htm
routing protocols enable routers to route routed protocols!
 
Odgovor na temu

[es] :: Javascript i AJAX :: Span to Input to Span replace

[ Pregleda: 1725 | Odgovora: 1 ] > FB > Twit

Postavi temu Odgovori

Navigacija
Lista poslednjih: 16, 32, 64, 128 poruka.