I am redoing my website and trying to get it to do something more
exciting using Javascript. I did normal Java at university and code at
work in VB.NET. I have got reasonably far into what I want to do but am
having some issues.
Firstly
I am using an XmlHttpRequest to pull html fragments out of files and
wish to put them into the main doccument inplace of a <span></span>
which has a given id. The user enters a "command" into a TextField and
when the onchange event is thrown I am using the contents of the text
field in a switch statement to decide which fragment should be loaded.
This works ok when TAB is pressed to throw the onchange event, apart
from the text field losing focus (which I don't want). However when
return or enter are pressed the fragment is loaded and placed in the
correct place, then the page seems to reload or refresh and loses it
again. To make this work will I need to store the loaded data so it
gets displayed again on the <body onload> event? I need someway of
getting around this refresh issue.
Secondly I get a strange duplication of information when the fragment
is loaded. The top part (main fragment that is loaded with the <body
onload> event. It does not get duplicated as text, but as some strange
unselectable object.
Ill try and get some dribbles of code up soon but I am not writing this
from my development machine.
Any help would be greatly appretiated.
Oh and can some one tell me, what is the life of a javascript variable?
Does it survive past refresh? When the script is loaded is that version
of it always used for the viewing session or does each refresh destroy
everything? If it does destroy everyting what is the best place to
store stuff - will I have to use a cookie?
Cheers
Phil.