473,383 Members | 1,735 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,383 software developers and data experts.

passing form date data

I have created an app with date range fields.

Here is the javascript used to get current date. ( works fine )

function setCurrDate()
{
var d = new Date();
var currMonth = d.getMonth() + 1;
var currDate = d.getDate();
var currYear = d.getFullYear();

time =
(currMonth < 10 ? "0" : "") + currMonth + "/" +
(currDate < 10 ? "0" : "") + currDate + "/" +
currYear + " " ;

theInput = document.getElementById("EndDate");
theInput.value = time;
}

This is part of the form...

<form>

<INPUT TYPE="text" NAME="EndDate" Size="8" Value="<%=EndDate%>">

</form>


What I need to do is store any updates to the EndDate by the user (if any).

Right now all it's doing is being overwritten during the load or submit of the page because I'm using the <body onload="setCurrDate()"> and it overwrites the EndDate field data.

Any suggestions?

Thanks in advance.
Jun 13 '07 #1
9 1552
acoder
16,027 Expert Mod 8TB
Hi swebster, welcome to TSDN!

Do you mean you want to update EndDate in a database?
Jun 13 '07 #2
Hi swebster, welcome to TSDN!

Do you mean you want to update EndDate in a database?
No, I use the EndDate as part of a query string to submit a search query.
So basically, on form load I need the field to equal the current date and if the user updates the date to be something earlier I need to dynamically store the new date in the EndDate variable.

clear as mud? :-)
Jun 13 '07 #3
acoder
16,027 Expert Mod 8TB
So how are you going to use this EndDate variable? If it's part of a form, it will get passed to the next page on submit.
Jun 14 '07 #4
Yes, but I can't have the users date over written in EndDate field after the initial results are rendered. Also, I am encoding the string in the URL and the users update to the date field is being captured in the result string but when the form refreshes the current date is placed back in the EndDate field.

I know I am passing the EndDate parameter correctly, so it's just that I need a way to if/else it rather than using the onload option.

I am getting closer... just getting snagged on the syntax.

String EndDate = request.getParameter("EndDate");
if(EndDate == null)
{
EndDate = "" need to set the current date here "" ;
}

This way I would be able to use else and manage the users entry.
Jun 14 '07 #5
It's really more like;

String EndDate = request.getParameter("EndDate");
if(EndDate == null)
{
EndDate = setCurrDate(); // execute js function if EndDate field is null.
}
Jun 14 '07 #6
acoder
16,027 Expert Mod 8TB
In that case, set the value with the server code as you already have done and in your onload function, check if EndDate has already been set by checking the input text field.
Jun 14 '07 #7
Yes that is the direction I am leaning towards but none of my syntax is working.

I just tried adding an if statement in the <body tag but that doesn't work.

<body if (EndDate == null) { onload="setCurrDate()" } >

---- or ----

set it in the jsp like this..

String EndDate = request.getParamter("EndDate");
if (EndDate == null )
{ EndDate = setCurrentDate() };

But neither work.
Jun 14 '07 #8
Thanks for all your replies aCoder!

I have successfully added an if statement to the function and it's working now with the onload.


function setCurrDate()
{
if ( queryForm.EndDate.value == '' ) {

var d = new Date();
var currMonth = d.getMonth() + 1;
var currDate = d.getDate();
var currYear = d.getFullYear();

time =
(currMonth < 10 ? "0" : "") + currMonth + "/" +
(currDate < 10 ? "0" : "") + currDate + "/" +
currYear + "" ;

theInput = document.getElementById("EndDate");
theInput.value = time;

}
}


<body onload="setCurrDate()">
Jun 14 '07 #9
acoder
16,027 Expert Mod 8TB
Thanks for all your replies aCoder!

I have successfully added an if statement to the function and it's working now with the onload.
No problem, glad you got it working.
Jun 15 '07 #10

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

Similar topics

2
by: Renie83 | last post by:
Hi I really am going crazy! I'm using VBScript, ASP, and SQL My page reminds me of a shopping cart but looking at shopping cart examples has not helped! What I have is a page that brings in...
2
by: zlatko | last post by:
There is a form in an Access Project (.adp, Access front end with SQL Server) for entering data into a table for temporary storing. Then, by clicking a botton, several action stored procedures...
12
by: Kevin Lyons | last post by:
Hello, I am trying to get my select options (courses) passed correctly from the following URL: http://www.dslextreme.com/users/kevinlyons/selectBoxes.html I am having difficulty getting the...
1
by: Kevin Lyons | last post by:
Hello, I am trying to get all of my form elements passed correctly from the following URL: http://www.dslextreme.com/users/kevinlyons/selectBoxes.html to the following URL:...
2
by: Bob | last post by:
I'm new to Access projects and SQL server and am not a veteran VB programmer. There's a cry for help! I'm attempting to print the current form on screen by using a command button which the user...
2
by: The KID | last post by:
Hi All So I'm new to this. What I am trying to is the user will fill in a series of text boxes or drop downs. Lets say for this instance begin date and end date. Then they would click a button and...
5
by: jmartmem | last post by:
Greetings, I have built an Update Record Form in an ASP page. This form contains a number of fields, such as text boxes and menus, to name a few. Upon clicking the 'submit' button, I want the...
3
by: ToddFur | last post by:
I see several postings on this but I am still unable to figure out my problem. I can pass the values of my text field but not radio button (or even checkboxes). My PHP file <?php //declare...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

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.