By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,649 Members | 2,154 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,649 IT Pros & Developers. It's quick & easy.

How can I save the value of textbox when it is written in javascript

P: 43
Hi Sir,

Im just new in programming using javascript and php.Please help me. I have a problem here..Im doing a system using php and its important to have date and digital time inside a textbox whenever the page loads, so I used javascript to do that. The problem is i dont know how to call and save the value of the textbox. Can somebody help me..Thank You in Advance..
Here's the code..

<link rel = "stylesheet" href = "../study/style.css" type = "text/css">
<title>Free SMS</title>

<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">


<form name="main">
<table width="100%" border="0" class="forumline">
<td width="17%">Start Date/Time:</td>
<td width="33%"><input type="text" name="start">
function show2(){
var digital=new Date()
var month = digital.getMonth()
var dom = digital.getDate()
var year = digital.getYear()
var hours = digital.getHours()
var minutes=digital.getMinutes()
var seconds=digital.getSeconds()
var moy = new Array("01","02","03","04","05","06","07","08","09" ,"10","11","12")
year = (year+"").substring(2,4)

if (hours > 24){
// dn = "PM";
hours = hours -24;}
if (hours==0){
hours = 24;}
if (minutes<=9){ minutes = "0" + minutes}
if (seconds<=9){ seconds = "0" + seconds}
document.main.start2.value=moy[month]+"/" + dom + "/" +year+ " " + hours + ":" + minutes + ":" + seconds;
// document.main.clear.value =moy[month]+"/" + dom + "/" + year + " " + hours + ":" + minutes + ":" + seconds;
Dec 20 '06 #1
Share this Question
Share on Google+
1 Reply

Expert 2.5K+
P: 4,258
Posting Guidelines. Read carefully before you post in a forum!

JavaScript is running client side, PHP is running server side. So it is not just a question of saving it in a variable. You must pass it from the client to the server. One way of doing that is using httpRequest, thereby calling the server program and passing the value. The server program could then store it in a global array for later usage. When you use an Ajax library you don't have to code these httpRequests yourself, but you can call the Ajax library.

See the httpRequest tutorial at Calling a server-side Script without refreshing the page

Ronald :cool:
Dec 20 '06 #2

Post your reply

Sign in to post your reply or Sign up for a free account.