Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Get value hidden text field

Status
Not open for further replies.

jelledaems

Programmer
Nov 13, 2006
11
BE
Dear sir/madam,

I have create one page, but this page gets reloaded occasionally when different action are performed on this page.

But I have a variable that needs to be remembered each time despite the fact that the page is reloaded.

Now I've been told that this was possible by working with hidden text field. But how can you retrieve a value from a hidden text field of a previous page.

In my case the hidden text field gets its default value every time the page is reloaded and not the value I've set in it before reloading the page...

there are however some restrictions:
- I cannot make use of cookies
- I cannot change the link of the webpage
- I cannot implment Vbscript (no <% %> tags)

is this possible what i want to do?

kind regards
Jelle
 
What kind of variable do you have to begin with? is it something submitted with the form? is it some other programming language? is it a javascript variable?

you can get the value of a hidden text field the same way as a visible input field:
Code:
myValue = document.forms["name_of_form"].elements["name_of_hidden_field"].value;

_______________
_brian.
 
Well, I have a string variable that I need to rememeber. I can adjust the webpage, but it's a web page within an existing application and this application has some limitations:
- you do not know the name of the webpage
- it does not accept asp, vbscript, asp.net
- working with cookies

You can write some Javascript in it and so I wanted to remember how I can store a string variable, so that I can remember it zhen the page gets submitted of posted or refreshed.

And someone mentioned the use of hidden text fields, but did not explain on how to use those.

If I write the code like you explained, wouldn't it just retrieve an empty string? I give something in into that text field, I push the button and then this code gets executed, but then it retrieved the value that is currently in the text element and not that what was in it before I pushed the button, no?

Thanks for the help
 
You say: Well, I have a string variable that I need to rememeber.

Where does the string come from? Is it something the user is giving you?

Also, if you can use javascript, is there some strange reason why you couldn't use a cookie? JavaScript can write a cookie...

Really, to store a variable, there are only a few ways:
Session Variables - Server Side
Database - Server Side
Flat Text File - Server Side
GET & POST Variables - Server Side

Cookie - Client Side
Telling the user to write a string down on paper, then enter it again on the next screen. - Client Side

Only one of these is pretty universal, no matter what type server you have.

Hidden text fields are exactly the same as normal text fields, except they are hidden. You can always view source to see the value of that field, so they're only good for useful stuff to the application that the user doesn't need to see, but not for things that you want to hide from the user. And the value of these fields can only be set by your script. So, you have to know what you want to put in these fields before they get a value. There's no way for it to remember, on its own, the value from the previous page. You could use javascript to write a value to that field, without the user really knowing, however you have to know the value beforehand. The only way for that to occur is, well, the variables mentioned above.

_______________
_brian.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top