User Name Password Register
DaniWeb IT Discussion Community
All
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
Reply
Join Date: Mar 2008
Posts: 8
Reputation: Asad__ is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
Asad__ Asad__ is offline Offline
Newbie Poster

sending data of a dropdown list from one html page to another without data base

  #1  
May 26th, 2008
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
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Jun 2006
Location: India
Posts: 6,812
Reputation: ~s.o.s~ is a splendid one to behold ~s.o.s~ is a splendid one to behold ~s.o.s~ is a splendid one to behold ~s.o.s~ is a splendid one to behold ~s.o.s~ is a splendid one to behold ~s.o.s~ is a splendid one to behold ~s.o.s~ is a splendid one to behold 
Rep Power: 23
Solved Threads: 339
Moderator
Featured Poster
~s.o.s~'s Avatar
~s.o.s~ ~s.o.s~ is offline Offline
Rebellion Revamped

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
"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."
Reply With Quote  
Join Date: Mar 2008
Posts: 8
Reputation: Asad__ is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
Asad__ Asad__ is offline Offline
Newbie Poster

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
Reply With Quote  
Join Date: Mar 2008
Posts: 8
Reputation: Asad__ is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
Asad__ Asad__ is offline Offline
Newbie Poster

Re: sending data of a dropdown list from one html page to another without data base

  #4  
May 27th, 2008
Also how would it be achieved that by selecting a value from a drop down or by clicking a button on one page and the cookie will be created, the second page will be opened with the value being displayed in some text area there ?
Reply With Quote  
Join Date: Jun 2006
Location: India
Posts: 6,812
Reputation: ~s.o.s~ is a splendid one to behold ~s.o.s~ is a splendid one to behold ~s.o.s~ is a splendid one to behold ~s.o.s~ is a splendid one to behold ~s.o.s~ is a splendid one to behold ~s.o.s~ is a splendid one to behold ~s.o.s~ is a splendid one to behold 
Rep Power: 23
Solved Threads: 339
Moderator
Featured Poster
~s.o.s~'s Avatar
~s.o.s~ ~s.o.s~ is offline Offline
Rebellion Revamped

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.
<!-- 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."
Reply With Quote  
Join Date: Mar 2008
Posts: 8
Reputation: Asad__ is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
Asad__ Asad__ is offline Offline
Newbie Poster

Re: sending data of a dropdown list from one html page to another without data base

  #6  
May 28th, 2008
thanx alot dear !!!
hope it will help others too who r in search of the solution for a similar problem ...
Regards,
Asad
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

DaniWeb JavaScript / DHTML / AJAX Marketplace
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

Thread Tools Display Modes

Other Threads in the JavaScript / DHTML / AJAX Forum

All times are GMT -4. The time now is 1:14 am.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC