PDA

View Full Version : javascript hide problem


ragtek
11-19-2007, 07:17 AM
i've made an ajax profileditor

http://www.ragtek.org/tutorials/editor.htm
the fields are coded like this: <div class="smallfont"><span id="usertitle">test</span></div>Einladungen: <span id="einladungen">200</span>

now when i want to edit the "Einladungen" field, its working fine
but for usertitle im getting this error:
usertitle.style has no properties
[Break on this error] usertitle.style.display = '';
the strange thing is:

usertitle.style.display = 'none'; is working,
usertitle.innerHTML = xml_sender.fetch_data(fetch_tags(xml_sender.handle r.responseXML, 'linkhtml')[0]); is also working,
but usertitle.style.display = ''; isn't working

the fields are updated, just the showpart isn't working :/

Analogpoint
11-19-2007, 07:29 PM
You can try
usertitle.style.display = 'inline';
// or
usertitle.style.display = 'block';
But this shouldn't be happening. There must be something else in your code causing this problem.

ragtek
11-19-2007, 07:39 PM
hi
thx for answer

i don't know
as i said its the same function as my edit
edit() is working
edittitle() not
http://www.ragtek.org/forum/clientscript/profilajax.js

Analogpoint
11-19-2007, 07:44 PM
Could there be a problem with using the same global variable inputobj in both functions? Try declaring them as local variable in the functions with var inputobj = 'xxxx';

ragtek
11-19-2007, 07:57 PM
i changed it=> same error
i think i'm missing something

Analogpoint
11-20-2007, 01:13 PM
Add some debugging stuff:

function savetitle(){
if (editstate==true){

if (xml_sender.handler.readyState == 4 && xml_sender.handler.status == 200)
{
if (xml_sender.handler.responseXML)
{
alert(usertitle); // should say HTML object or somthing
usertitle.innerHTML = xml_sender.fetch_data(fetch_tags(xml_sender.handle r.responseXML, 'linkhtml')[0]);
container1.removeChild(editobj);
alert(usertitle.innerHTML);
alert(usertitle.style);
alert(usertitle.style.display);
usertitle.style.display = 'block';
editstate=false;
}
}
}
}

ragtek
11-20-2007, 03:10 PM
1. alert= my input
2,3 => undefined

--------------- Added 1195581708 at 1195581708 ---------------

problem solved
i used a wrong variable so usertitle was the object + the input
shame on me

Analogpoint
11-20-2007, 04:51 PM
Good.

A suggestion also for you. You can make your edit, presave & save functions more generic, or even encapsulate them in an object, so you can reuse the same code for each of your fields Einladung, title etc.

ragtek
11-20-2007, 05:02 PM
hi

thx 4 the tipp, (i wanted to make it with objects) but atm i don't realy understand the oop part :/
i can use it by copy & paste ( i'm doing it for my ajax prefix addon http://www.ragtek.org/tutorials/select.htm ) but one thing is just copy,paste and change the objects and the other thing is to realy understand it and to use it by own things:D