•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the JavaScript / DHTML / AJAX section within the Web Development category of DaniWeb, a massive community of 402,621 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,277 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our JavaScript / DHTML / AJAX advertiser: Lunarpages Web Hosting
Views: 1185 | Replies: 5 | Solved
![]() |
•
•
Join Date: Mar 2008
Posts: 8
Reputation:
Rep Power: 0
Solved Threads: 0
I am using html and javascript for a simple application. I made a dropdown list on one page say "homepage.html" I want that the value selected from the dropdown be passed to a new page say "newpage.html" and appear in a text area there. I don't want to use php etc. plz NOTE that i am not going to upload it on internet. These are just going to be offline pages.
i will deeply appreciate any help.
Asad
i will deeply appreciate any help.
Asad
Re: sending data of a dropdown list from one html page to another without data base
#2
May 26th, 2008
You would need to use cookies for this purpose. When the drop down on your page is selected, you can set the required value in the cookie, navigate to that page and read the value from that cookie when the second page loads to populate the text box.
For more information / code snippets on cookies, visit http://www.quirksmode.org/js/cookies.html
For more information / code snippets on cookies, visit http://www.quirksmode.org/js/cookies.html
"I don't accept change. I don't deserve to live."
"Working a real job is a win if you're lazy, greedy, or unmotivated. If you're average, you fit right in. And if you're above average, the basic terms of employment and premise of the arrangement is against your interests."
"Working a real job is a win if you're lazy, greedy, or unmotivated. If you're average, you fit right in. And if you're above average, the basic terms of employment and premise of the arrangement is against your interests."
•
•
Join Date: Mar 2008
Posts: 8
Reputation:
Rep Power: 0
Solved Threads: 0
Re: sending data of a dropdown list from one html page to another without data base
#3
May 27th, 2008
Thanx for your reply !
Because i have no experience of this work, so some questions arise in mind regarding using cookies ...
1) should the code for cookie be written in a separate cookie file or should it be written in one of the two files that pass and recieve data.
2) If it is to be written in a separate file that means that once the cookie is deleted, the only way that the whole stuff works is to rewrite the cookie file. what if i hand over my files to a friends who absolutely has no idea about html but he just uses the files to quickly check out some data. If the cookie is deleted, he will do nothing but curse me
3)How will the data be received in the target file ? can it be stored in some variable in a target file ?
Kindly guide me through the steps. i would really appreciate ur help
Regards,
Asad
Because i have no experience of this work, so some questions arise in mind regarding using cookies ...
1) should the code for cookie be written in a separate cookie file or should it be written in one of the two files that pass and recieve data.
2) If it is to be written in a separate file that means that once the cookie is deleted, the only way that the whole stuff works is to rewrite the cookie file. what if i hand over my files to a friends who absolutely has no idea about html but he just uses the files to quickly check out some data. If the cookie is deleted, he will do nothing but curse me
3)How will the data be received in the target file ? can it be stored in some variable in a target file ?
Kindly guide me through the steps. i would really appreciate ur help
Regards,
Asad
•
•
Join Date: Mar 2008
Posts: 8
Reputation:
Rep Power: 0
Solved Threads: 0
Re: sending data of a dropdown list from one html page to another without data base
#4
May 27th, 2008
Re: sending data of a dropdown list from one html page to another without data base
#5
May 27th, 2008
> should the code for cookie be written in a separate cookie file or should it be written in
> one of the two files that pass and receive data.
The code for cookie management would come in both the HTML documents; in the first one for writing to the cookie and in the second one for reading from the cookie.
> what if i hand over my files to a friends who absolutely has no idea about html but he just
> uses the files to quickly check out some data. If the cookie is deleted, he will do nothing
> but curse me
The cookie creation code would take care of writing the value to the cookie every time the first page is run.
> How will the data be received in the target file ? can it be stored in some variable in a
> target file ?
If by the target file you mean the second HTML document, then yes, you would call a function when the body loads which would read the required data from the cookie written by the first HTML document.
> one of the two files that pass and receive data.
The code for cookie management would come in both the HTML documents; in the first one for writing to the cookie and in the second one for reading from the cookie.
> what if i hand over my files to a friends who absolutely has no idea about html but he just
> uses the files to quickly check out some data. If the cookie is deleted, he will do nothing
> but curse me
The cookie creation code would take care of writing the value to the cookie every time the first page is run.
> How will the data be received in the target file ? can it be stored in some variable in a
> target file ?
If by the target file you mean the second HTML document, then yes, you would call a function when the body loads which would read the required data from the cookie written by the first HTML document.
<!-- second html file -->
<html>
<head>
<script type="text/javascript">
function readCookie() {
var valueReadFromCookie = ... // read data from cookie
var frm = document.forms["frm"];
var txtBox = frm.elements["txt"];
txt.value = valueReadFromCookie;
}
</script>
</head>
<body onload="readCookie();">
<form id="frm" name="frm" action="#">
<span>Value read: </span>
<input name="txt" id="txt">
</form>
</body>
</html> "I don't accept change. I don't deserve to live."
"Working a real job is a win if you're lazy, greedy, or unmotivated. If you're average, you fit right in. And if you're above average, the basic terms of employment and premise of the arrangement is against your interests."
"Working a real job is a win if you're lazy, greedy, or unmotivated. If you're average, you fit right in. And if you're above average, the basic terms of employment and premise of the arrangement is against your interests."
•
•
Join Date: Mar 2008
Posts: 8
Reputation:
Rep Power: 0
Solved Threads: 0
Re: sending data of a dropdown list from one html page to another without data base
#6
May 28th, 2008
![]() |
•
•
•
•
•
•
•
•
DaniWeb JavaScript / DHTML / AJAX Marketplace
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
•
•
•
•
access advice broadband code combo crime css cult of the dead cow daniweb data data protection data transfer database development div dreamweaver drive dropdownlist encryption europe forensic forensics google checkout vat hacking hard hardware help hitachi html html api information internet linux module net news privacy reuse security storage symantec tables terabyte tv w3c web wikipedia wysiwyg xml
- Previous Thread: How to get Id of Div
- Next Thread: Array



Linear Mode