[HTML/JS] Remembering hidden INPUT values after F5 refresh

Custom Title Activated
Loyal Member
Joined
Apr 11, 2005
Messages
1,048
Reaction score
9
See examples in this file:

http://forum.ragezone.com/attachmen...-v0-61b-mu-interface-editing-demist_0.85b.zip

Code:
<input id="blah" type="hidden" value="blah">
<input type="button" onClick="alert(document.getElementById('blah').value)" value="click to display hidden value">
<input type="text" id="changer">
<input type="button" "value="click to change hidden value" onClick="alert(document.getElementById('blah').value + ' = ' + document.getElementById('changer').value);document.getElementById('blah').value = document.getElementById('changer').value">

This test code works, but it won't work in this page:

http://forum.ragezone.com/f380/dev-demist-v0-61b-mu-interface-editing-363796/

Any ideas? :huh: I can't see any code that's resetting the values of rPanel/lPanel, and it even works if I manually insert a value for the hidden value (in the HTML) but it won't 'remember' the value if it is changed with javascript then a warm refresh (F5) is done :sad:
 
It's not between <form> tags.

Also, be sure to double check hidden values, they can be changed using JS injections, so never trust it's value...I usually try to avoid using hidden's completely.

And: you use <map> tags before the <body> tag?
 
It's not between <form> tags.

Also, be sure to double check hidden values, they can be changed using JS injections, so never trust it's value...I usually try to avoid using hidden's completely.

And: you use <map> tags before the <body> tag?

The test file isn't between form tags and it works fine on my computer/browser (I'm only aiming for firefox, anyone wanting to use my program can install firefox to use it, good incentive).

Also it's for a local file-tool only, web security stuff is of no concern here, but thanks for the tip ;)

The map tags appear to work just fine as well, but if that's not the correct order of things then I'll change that, ta.

It works in the test file, but not in the main file. If I manually set the value of one of the hidden inputs (either in the inline html or by js) then it works after that for returning the value, until the page is refreshed...

The whole reason I used inputs in the first place was so this wouldn't happen, I want people to be able to change the open windows etc, then have those same windows stay open if they hit refresh (so when testing changes on skins in a certain window, they don't have to refresh, click 3 or 4 more buttons, then try to remember how it looked before the change)...

Any further advice is most welcome, I'll be glad when this particular quirk is nutted out :smile:


EDIT: aah... I think I remember something about needing a delay for this, hang on...

EDIT2: nope, just checked and I already have a delay for that... and if I set a value inline, the script works but only with the inline values and not what it's changed to... fukk it works fine in the test one :/

EDIT3: Tried putting the values in a form, no change either with or without inline values set. :doh:
 
Okay I'm thinking I might circumvent this issue by setting a custom refresh button, so when they hit (for example) Space, it will send the location to page.html?right=rPanel&left=lPanel :huh:

It doesn't have to be pretty, it just has to work :thumbsup:

Alrighty, 15 mins later and I'm almost done on that workaround, but damn it's annoying since I could have saved a heap of time earlier on by not having to make it use inputs :no:
 
If you can not, make it being remember, how about not making it hidden by revealed but encrypted.

My idea is to make it input: displayed but not enabled ( to prevent editing it ), and encrypt the content ;-)

http://forum.ragezone.com/f380/dev-demist-v0-61b-mu-interface-editing-363796/

Why does this need encryption? :huh:

P.S: YAY almost done :smile:

Okay well the actual problem isn't fixed/identified, but it does what it's supposed to now, that's all that matters really :tongue:

Code used (refresh key is now Enter):

Code:
[b]in captureKeys function:[/b]
if (KeyID == 13) {
location.href = (location.href.substr(0,location.href.lastIndexOf('.html')+5) + "?r=" + document.getElementById('right').value +
		"&l=" + document.getElementById('left').value + "&x=" +
		document.getElementById('extra').value);}

Code:
[b]in changeScreen function:[/b]
if (which == 'onload'){
  if (location.href.indexOf('r=')) changePanel(location.href.charAt(location.href.indexOf('r=')+2),1,0);
  if (location.href.indexOf('l=')) changePanel(location.href.charAt(location.href.indexOf('l=')+2),1,1);
  if (location.href.indexOf('x=')) showDialog(location.href.charAt(location.href.indexOf('x=')+2));
  return;}

Not the cleanest solution by far, but gets the job done! :yes:

EDIT (again): Okay for some reason it DOES need a delay before execution or it behaves arratically, 100ms seems to be enough on my comp, that should be good enough for most ppl :rolleyes:
 
Back