Getting the value of a Label in new page
Hi,
I have a very long HTML code which I cannot understand what's going on. But I need to do a modification: I have a label <label id="current"></label> and the code stores some value in this label (list of words). When the user clicks on a button a new php page opens. In this new page I would like to reach the value of this label. How can do that?
Best,
-halit
Re: Getting the value of a Label in new page
The only way a new page can get that information is if the previous page passes it through GET or POST. This would be through a form, or even hard coded into the URL. Your best option is to pass it through the URL.
Code:
http://www.domain.com/page.php?list=one,two,three
Alternatively, you could use the PHP page to read the contents of the other and then parse the data. That would be a little bit more code. And, mostly likely a waste of time.
Re: Getting the value of a Label in new page
But the problem with labels is that they do not have a "name" attribute therefore I could not use GET and POST. Any suggestions how to use GET or POST to get the value of a label of the previous page?
Re: Getting the value of a Label in new page
You misunderstand my point...You will have to refer that information directly yourself.
Re: Getting the value of a Label in new page
Oh, sorry for that. But I could not understand what you mean since I am a newbie in html and php. Can you be more specific? Thank you very much
Re: Getting the value of a Label in new page
You will have to grab the labels yourself, using JavaScripts getElementById(), and pass that through GET or POST.
Re: Getting the value of a Label in new page
Ok: I followed these steps:
1) I have created a hidden input variable with the id = "h1" and name = "hidden" in HTML. And "l1" is the id of the label that I want to get the value in the new page.
2) Then I set a function called "set()" for the a button. So when the button is clicked the function will be called.
3) inside the function I did the following:
Code:
document.getElementById("h1").innerHTML = document.getElementById("l1").innerHTML;
Then I tried the get the value of hidden variable in the new page using its name ("hidden"). But it does not work?
Re: Getting the value of a Label in new page
You cannot use innerHTML for <input> tags because there is no HTML on the inner side. Example of innerHTML...<p> is innerHTML of <div>.
The <input> tag only has properties. You want...
Code:
document.getElementById("h1").value...