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

Date operations: display current date and last month's date in textbox

100+
P: 115
i'm using ASP with MSAccess as database.
i have two buttons and two textbox in my page.
when i press my first button (First month) i need to display the current month in one textbox and last one months date in another textbox.
and while pressing the second button (submit) i need to display the date displayed in the textbox as itself and the records between thoses two dates. if that date is still there in the textbox only i can sort the records.
in vbScript i tried to display the current date and last months date like this.

Expand|Select|Wrap|Line Numbers
  1. <script language="VBScript">
  2. sub onemonth() 
  3. form1.datefrom.value = dateadd("m",-1,date())
  4. form1.dateto.value = date() 
  5. end sub 
  6. </script>
  7.  
so any idea how to write this function in javascript.....
if you know please help me.
Thanks in advance...
May 3 '07 #1
Share this Question
Share on Google+
3 Replies


100+
P: 115
i'm using ASP with MSAccess as database.
i have two buttons and two textbox in my page.
when i press my first button (First month) i need to display the current month in one textbox and last one months date in another textbox.
and while pressing the second button (submit) i need to display the date displayed in the textbox as itself and the records between thoses two dates. if that date is still there in the textbox only i can sort the records.
in vbScript i tried to display the current date and last months date like this.

<script language="VBScript">
sub onemonth()
form1.datefrom.value = dateadd("m",-1,date())
form1.dateto.value = date()
end sub
</script>

so any idea how to write this function in javascript.....
if you know please help me.
Thanks in advance... sub onemonth() form1.datefrom.value = dateadd("m",-1,date()) form1.dateto.value = date() end sub
May 3 '07 #2

acoder
Expert Mod 15k+
P: 16,027
See this link for the javascript Date object. When you create a new Date object, it defaults to today's date, then you can use the methods for what you require.
May 4 '07 #3

100+
P: 115
i'm able to display the corresponding dates in two textbox while clicking the buttons "Last 1 Month" and "Last 3 Month".
and while pressing the Submit button the dates displayed in the textbox should be display in that textbox itself.
if we changed the date after the display in that textbox , then the new dates should be displayed while pressing the submit button.
this is the code i tried to get the value displayed i the textbox and display it while we press submit button.

[HTML]<html>
<head>

<script language="VBScript">
sub onemonth()
form1.datefrom.value = dateadd("m",-1,date())
form1.dateto.value = date()
end sub
sub threemonth()
form1.datefrom.value = dateadd("m",-3,date())
form1.dateto.value = date()
end sub
sub viewrecord()
form1.datefrom.value = strdatefrom
form1.dateto.value = sttrdateto
end sub
</script>

</head>
<body>

<form name="form1" method="post">
<BR>
<input type="button" value="Last 1 Month" name="buttonname" onclick="onemonth"/>
<input type="button" value="Last 3 Month" name="buttonname" onclick="threemonth"/>
<input id="datefrom" type="text" name="datefrom" size="20"/>
<input id="dateto" type="text" name="dateto" size="20"/>
<input name="b2" type="button" VALUE="Submit" onclick="viewrecord()"/>

<% Dim strdatefrom, strdateto
strdatefrom = trim(Request.form("datefrom"))
strdateto = trim(Request.form("dateto")) %>

</form>
</body>
</html>
[/HTML]
but its not taking the values Request.form("datefrom").
and if we use button, it will display the dates in textbox. but if we use submit it will show the date a glance and make the textbox blank. we wont be able to see the date if we give submit.
and we post will be done by submit button, and if we give button, it wont post the value.
if you have any idea what wrong in my code just help me.
how can i make this display the content in the textbox to the same textbox after clicking a button or submit button.
thanks in advance
May 4 '07 #4

Post your reply

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