473,411 Members | 1,949 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,411 software developers and data experts.

Function call in Asp from Button

115 100+
i'm using ASP and Ms Access as database.
i created a submit button like this

<input name="b1" type="submit" VALUE="Submit" />

and while clicking this button, i need to fill two textbox the curent date and last one months date. eg: if today is 5/1/2007 then last month date is 4/1/2007. and while pressing another button, need to display the records in between that dates.

so how can i write a function while clicking this button "submit" or "last one month button".
can you help me to find a solution. i dont have much idea about ASP.

so if you have any idea please help me, how to write functions in ASP for the button click event.

thanks in advance.
May 1 '07 #1
2 3110
JamieHowarth0
533 Expert 512MB
Hi remya,

Your best bet is to use Javascript's onclick event handler to populate the two fields. Your other option is to use ASP server-side date retrieval and manipulation but this creates a performance hit on the server when the client's computer can do it more quickly using Javascript.
When the user clicks a button, Javascript code retrieves today's date, month and year, and stores this in one field in your form.
It then subtracts 1 from the month value, and saves the data again to your second field.
Finally, you can use Javascript's document.forms().submit() method to submit the form to your server for database processing.
If you would like me to try and produce some sample code PM me and I will see what I can do.

All the best,

medicineworker
May 2 '07 #2
remya1000
115 100+
Right now what i did is that, VbScript like this

<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 viewrecords()

end sub
</script>

created buttons and textbox like this.

<form name="form1" method="post">
<input type="button" value="Last 1 Month" name="buttonname" onclick="onemonth"/>
<input type="button" value="Last 3 Month" name="buttonname" onclick="threemonth"/>
<input type="text" name="datefrom" size="20">
<input type="text" name="dateto" size="20">
<input name="b2" type="submit" VALUE="Submit" onclick="viewrecords"/>
<Br><Br>
..........................................
</form>

right now while pressing any button called "onemonth" or "threemonth", its displaying the datefrom and dateto in the textbox. but when i press submit it should display the records in between thoses days. and i need to sort each fiels in that displayed records.
but while pressing submit, the textbox is getting empty. and its not taking the textbox value for the sql. i tried this for checking...
sub onemonth()
a3 = ""
b3 = ""
form1.datefrom.value = dateadd("m",-1,date())
form1.dateto.value = date()
a1 = dateadd("m",-1,date())
b1 = date()
end sub
sub viewrecord()
if a1<>"" and b1<>"" then
form1.datefrom.value=a1
form1.dateto.value=b1
end if
end sub
but the submit is not getting this value at all.

and i have no idea about javascript. if you can please help me in this. i'm really stuck now. if you have any idea how to do this let me know about that. if possible get me some eg: also. that will be very help full to me.
thanks in advance
May 2 '07 #3

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

Similar topics

1
by: cheezebeetle | last post by:
ok, so I am having problems passing in an ASPX function into the Javascript in the codebehind page. I am simply using a confirm call which when they press "OK" they call this ASPX function, when...
3
by: David N | last post by:
Hi All, I just wonder if in C#, I can develop a user defined control that can call its parent function which is not yet developed. For example, how do I make my user control call a...
4
by: John | last post by:
Hi all, This really is quite an urgent matter. I have a page with multiple, dynamically-loaded user controls and when a user clicks on a button, the whole form is submitted. Now at this stage...
6
by: grist2mill | last post by:
I want to create a standard tool bar that appears on all pages that is a control. The toolbar has a button 'New'. What I wolud like when the user clicks on 'New' depends on the page they are on. I...
5
by: siaj | last post by:
Hello, I have a javascript function for a validation in the HTML page of the asp.Net page.. I call this function in a Savebutton click When the validation fails No postback should happen ( ie...
6
by: SimonZ | last post by:
How can you call function from aspx page? For example: button on aspx page: <asp:button Visible="<% =funcVisible()%>" id="btnNew" Runat="server"></asp:button> code behind function:
24
by: John Gabriel | last post by:
CreateDialogIndirect() fires my Radio button click function without the radio button having being clicked. I am using VC++ 2003.NET. I believe this is yet another Microsoft bug. Have checked dialog...
28
by: Larax | last post by:
Best explanation of my question will be an example, look below at this simple function: function SetEventHandler(element) { // some operations on element element.onclick = function(event) {
10
by: evicailieva | last post by:
A have a php scrip where I call a JavaScript function. I don't know why, but it doesn't work. At the beginning, when I was writing the script it was working but now it's not. I don't know wхat to do....
4
by: soni2926 | last post by:
hi, is it possible to pass a function into another function as a parameter? Say i have these: function SaveMe(text) {...} function SaveMeNow(text) {...}
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.