2 Replies - 2182 Views - Last Post: 23 January 2010 - 09:53 AM

#1 pavithra_mdn   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 25-October 09

How to copy the data entered in a textbox to a select box using Javasc

Posted 20 January 2010 - 09:46 PM

Hi,

I have a web page that has a select box and a textbox to add data into the select box. What I want to do is when I enter some data say a "valid date" in the textbox and click on Add button it should copy the same to the textbox such that ,when I navigate to a different link in the web interface and visit the same page again, the value that I had entered earlier should remain in the select box and be visible.

I have been able to copy the data from the textbox to the select box, but when I revisit the same page the value entered earlier does not remain in the page. Once the values are stored in the select box, those values in the select box should be copied to a structure written in C language in the backend.

Can anyone tell me how can I store the values entered during runtime in the select box using javascript.

Thanks in Advance,
Pavithra :)

Is This A Good Question/Topic? 0
  • +

Replies To: How to copy the data entered in a textbox to a select box using Javasc

#2 JMRKER   User is offline

  • D.I.C Addict
  • member icon

Reputation: 134
  • View blog
  • Posts: 868
  • Joined: 25-October 08

Re: How to copy the data entered in a textbox to a select box using Javasc

Posted 21 January 2010 - 06:27 PM

I think you are looking for a 'cookie' to store the information into.

Keep in mind that the cookie is only available on the local computer that created it in the first place.

You will need some sort of server-side code to keep the information available for all users.
Was This Post Helpful? 0
  • +
  • -

#3 jordangomm   User is offline

  • New D.I.C Head
  • member icon

Reputation: 6
  • View blog
  • Posts: 24
  • Joined: 12-January 10

Re: How to copy the data entered in a textbox to a select box using Javasc

Posted 23 January 2010 - 09:53 AM

Hi Pavithra,

Save the value into a Javascript or Server side cookie.

Javascript
var givenDate = THEDATETHEYINPUT;
var expdate = new Date();
expdate.setTime(date.getTime()+(1000*60*60*24*30));
document.cookie = 'mydate='+givenDate+';  expires='+expdate.toGMTString()+' path=/';


PHP:
setcookie("mydate","THEDATETHEYINPUT", time()+60*60*24*30);


Both would expire in a month from setting (30 days).

Then read them later on:

Javascript (This code presumes that you haven't set any other Javascript cookies):
function getDate()
var givenDate = getDate();



PHP:


Was This Post Helpful? 0
  • +
  • -

Page 1 of 1