Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to populate a date after fill out the one field in the form to oth 2

Status
Not open for further replies.

yogi564

Programmer
Oct 16, 2001
48
AU
HI ALL,

I wondering how to populate date, after filling out the first field. For example I have six fields with the same name given in the form called DATE. What I need to happen is to get all the six fields to fill up when I enter in the date in the first field.

Therefore the other five field should be the same date filled out as the first field. The field name for other five are all the same called Date. IS There a way to do it.If so How? This is a text box not a dropdown box.Thank's
 
Hello yogi564,

I hope this is what you need.Try this:


<html>
<head>
<title>DATE PAGE</title>
<script language=&quot;javascript&quot;>
<!----
function showdate(thedate)
{
dateform=document.myform;
dateform.date1.value=thedate;
dateform.date2.value=thedate;
dateform.date3.value=thedate;
dateform.date4.value=thedate;
dateform.date5.value=thedate;
}
//---->
</script>
</head>
<body onload=&quot;document.myform.date.focus();&quot;>
<br>
<br>
<div align=&quot;center&quot;>
<form name=&quot;myform&quot; method=&quot;post&quot;>
<input type=&quot;text&quot; name=&quot;date&quot; size=&quot;20&quot; maxlenght=20&quot; onblur=&quot;showdate(this.value)&quot;>
<br>
<input type=&quot;text&quot; name=&quot;date1&quot; size=&quot;20&quot; maxlenght=20&quot;>
<br>
<input type=&quot;text&quot; name=&quot;date2&quot; size=&quot;20&quot; maxlenght=20&quot;>
<br>
<input type=&quot;text&quot; name=&quot;date3&quot; size=&quot;20&quot; maxlenght=20&quot;>
<br>
<input type=&quot;text&quot; name=&quot;date4&quot; size=&quot;20&quot; maxlenght=20&quot;>
<br>
<input type=&quot;text&quot; name=&quot;date5&quot; size=&quot;20&quot; maxlenght=20&quot;>
<br>
<input type=&quot;submit&quot; value=&quot;Submit&quot;>
 
<input type=&quot;reset&quot; value=&quot;Reset&quot;>
</form>
</div>
</body>
</html>


The script doesn't work if you assign the same name 'date' to all of the text fields.I gave the name 'date' to the first field,date1 to the second one and so on.

There are many ways of doing this.I just tried to be clear.

I hope this helps.

Happy New Year!

Kindest Regards :)

alexfusion
 
Hi Alexfusion

I am get an error. It is saying an Object expected in Line 13 character 1. How to fix that?

Happy New Year 1
 
Hi alexfusion

The real problem is this showdate is not defined in Line 13 of the coding.

From
Yogi
 
Hi Yogi,

Sorry I took me some time to write you back.
I checked the code in IE and NN and it works fine.
You're telling me that you get the error: showdate is not defined.
Please check your code.Javascript is case sensitive,so if you define the function showdate() and then you reference it later as Showdate(),this is not correct.

showdate() is not the same than Showdate(),for instance.

Let me know how are you going.

Best Regards

alex
 


Hi alexfusion
I am testing the same coding as what you have given me, but according to your answer I cannot find any problem. Is your script error checking on in IE as Well as Netscape. Thank's
From
Yogi
<html>
<head>
<title>DATE PAGE</title>
<script language=&quot;javascript&quot;>
<!----
function showdate(thedate)
{
dateform = document.myform;

dateform.date1.value=thedate;
dateform.date2.value=thedate;
dateform.date3.value=thedate;
dateform.date4.value=thedate;
dateform.date5.value=thedate;

}
//---->
</script>
</head>
<body onload=&quot;document.myform.date.focus();&quot;>
<br>
<br>
<div align=&quot;center&quot;>
<form name=&quot;myform&quot; method=&quot;post&quot;>
<input type=&quot;text&quot; name=&quot;date&quot; size=&quot;20&quot; maxlenght=20&quot; onblur=&quot;showdate(this.value)&quot;>
<br>
<input type=&quot;text&quot; name=&quot;date1&quot; size=&quot;20&quot; maxlenght=20&quot; >
<br>
<input type=&quot;text&quot; name=&quot;date2&quot; size=&quot;20&quot; maxlenght=20&quot; >
<br>
<input type=&quot;text&quot; name=&quot;date3&quot; size=&quot;20&quot; maxlenght=20&quot; >
<br>
<input type=&quot;text&quot; name=&quot;date4&quot; size=&quot;20&quot; maxlenght=20&quot; >
<br>
<input type=&quot;text&quot; name=&quot;date5&quot; size=&quot;20&quot; maxlenght=20&quot; >
<br>
<input type=&quot;submit&quot; value=&quot;Submit&quot;> <input type=&quot;reset&quot; value=&quot;Reset&quot;>
</form>
</div>
</body>
</html>
 
Hi alex fusion

I miss interpeted this sentence &quot; I cannot find a problem&quot; it should be, I cannot solve this problem. Can you help me.

Thank's
From Yogi
 
Hi Yogi

Could you tell me exactly the problem you have,so I would have a better aidea about how to find the possible solution.

I checked the script line line by line and I didn't find any error.
Please explain me what is the exact problem.
I will do the best.


Kind Regards

alexfusion
 
Hi alexfusion,

The exact problem is mentioned above. The error is coming up with showdate is not defined in Netscape and in IE it is pointing to line 13 char 1. I know that you ran this code using Netscape and IE, but did you see anything appearing in the bottom of the bar. Otherwise can you give me your url of the working code, so I can test it out alexfusion. Then I could see what I am doing wrong! Thank's

From
Yogi
 
Hello Yogi again,

I'm sorry I didn't realize about the possible error.You were right.
IE is more generous when you write HTML,but not NN.

This should be work fine:

<html>
<head>
<title>DATE PAGE</title>
<script language=&quot;javascript&quot;>
<!----
function showdate(thedate)
{
dateform=document.myform;
dateform.date1.value=thedate;
dateform.date2.value=thedate;
dateform.date3.value=thedate;
dateform.date4.value=thedate;
dateform.date5.value=thedate;
}
//---->
</script>
</head>
<body onload=&quot;document.myform.date.focus();&quot;>
<br>
<br>
<div align=&quot;center&quot;>
<form name=&quot;myform&quot; method=&quot;post&quot;>
<input type=&quot;text&quot; name=&quot;date&quot; size=&quot;20&quot; maxlenght=&quot;20&quot; onblur=&quot;showdate(this.value)&quot;>
<br>
<input type=&quot;text&quot; name=&quot;date1&quot; size=&quot;20&quot; maxlenght=&quot;20&quot;>
<br>
<input type=&quot;text&quot; name=&quot;date2&quot; size=&quot;20&quot; maxlenght=&quot;20&quot;>
<br>
<input type=&quot;text&quot; name=&quot;date3&quot; size=&quot;20&quot; maxlenght=&quot;20&quot;>
<br>
<input type=&quot;text&quot; name=&quot;date4&quot; size=&quot;20&quot; maxlenght=&quot;20&quot;>
<br>
<input type=&quot;text&quot; name=&quot;date5&quot; size=&quot;20&quot; maxlenght=&quot;20&quot;>
<br>
<input type=&quot;submit&quot; value=&quot;Submit&quot;>
<input type=&quot;reset&quot; value=&quot;Reset&quot;>
</form>
</div>
</body>
</html>

I had forgotten the double quotation for the &quot;maxlenght&quot; attribute.
Anyway I uploaded the code for you.You can check it at:

If you submit the form using this url you will get an error from the web server but not due to the script.

If you run the script on your own computer,it should work fine.(No web server error).I tried it in IE 5,IE 5.5,IE 6 and NN 6.

Once again my apologies :)

Kindest Regards

alexfusion
 
Hi alex fusion

Thank you very much for your help, now it is working. Is there a way to name all the fields as Dates rather than Date 1, 2,3,4,5 e.t.c. because this is going to be submit into a datbase table. i know it could be a bit tricky. That would be quite ideal. Anyway I will give it a go to see if I can have the same fieldname for all the others.

Thank's

From
Yogi
 
Hi alexfusion,

I tried to change the extension from html to Cfm, when I go to save it.When I run with the extension CFM(Cold Fusion MarkUp Language, It seems to run back to the old problem saying that 'showdate is not defined', I don't understand why this should happen? Could you explain to me what going on. thank's. All my other javascript seems to work well with CFM files but this seems to dislike it.
 
Hi Yogi,
I'm glad the script worked out finally.
Please could you post the code you are working with?
About if you can rename the page form .htm to .cfm,there is no problem.I'm programming too in Cold Fusion and it's great.
This could be very obvious,but if you rename from .htm to .cfm ,either you are running ColdFusion Aplication Server on your own computer along with a web server,such as Internet Information Server,Personal Web Server,Apache,etc.so all of your .cfm code can be processed properly or you will have to upload the page to a web server with CFML support.
If you have in the same page the script and CFML code,you must rename to .cfm.Otherwise it'wont work.
if you don't have CFML code,let the .htm extension.It's no necessary to overload the server.

About the field names,I think there is not much possibilities.
If you are going to insert the form data by using CFINSERT,you must name all of the field different and they must have the corresponding name in the table fields of the database.As a CF programmer you know this much better than me.I have working with CF for a while.
If you are going to use the 'INSERT' SQL statement,there is no difference with the case above.
In short,I suggest strongly that you name the form fields as date,date1,etc,or whatever you want but it must be different names.If you do this way,you'll avoid many SQL and javascript problems.


Kind Regards

alexfusion
 
Hi alex fusion

this is same code as what working with the html extension but when I rename it to cfm. The error come up saying showdate is not defined in Nescape and in IE the error in char 13 line 1.

<!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.0 Transitional//EN&quot;>
<!-- saved from url=(0036) -->
<HTML><HEAD><TITLE>DATE PAGE</TITLE>
<META http-equiv=Content-Type content=&quot;text/html; charset=windows-1252&quot;>
<SCRIPT language=javascript>
<!----
function showdate(thedate)
{
dateform=document.myform;
dateform.date1.value=thedate;
dateform.date2.value=thedate;
dateform.date3.value=thedate;
dateform.date4.value=thedate;
dateform.date5.value=thedate;
}
//---->
</SCRIPT>

<META content=&quot;MSHTML 5.50.4134.600&quot; name=GENERATOR></HEAD>
<BODY onload=document.myform.date.focus();><BR><BR>
<DIV align=center>
<FORM name=myform method=post><INPUT onblur=showdate(this.value) name=date
maxlenght=&quot;20&quot;> <BR><INPUT name=date1 maxlenght=&quot;20&quot;> <BR><INPUT name=date2
maxlenght=&quot;20&quot;> <BR><INPUT name=date3 maxlenght=&quot;20&quot;> <BR><INPUT name=date4
maxlenght=&quot;20&quot;> <BR><INPUT name=date5 maxlenght=&quot;20&quot;> <BR><INPUT type=submit value=Submit> <INPUT type=reset value=Reset>
</FORM></DIV></BODY></HTML>
 
Hello Yogi,

What it comes to my eyes at first is that you should use double quotations.

Here is the code with double quotations:

<!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.0 Transitional//EN&quot;>
<HTML>
<HEAD>
<TITLE>DATE PAGE</TITLE>
<META http-equiv=&quot;Content-Type&quot; content=&quot;text/html; charset=windows-1252&quot;>
<META content=&quot;MSHTML 5.50.4134.600&quot; name=&quot;GENERATOR&quot;>
<SCRIPT language=javascript>
<!----
function showdate(thedate)
{
dateform=document.myform;
dateform.date1.value=thedate;
dateform.date2.value=thedate;
dateform.date3.value=thedate;
dateform.date4.value=thedate;
dateform.date5.value=thedate;
}
//---->
</SCRIPT>
</HEAD>
<BODY onload=&quot;document.myform.date.focus();&quot;>
<BR><BR>
<DIV align=&quot;center&quot;>
<FORM name=&quot;myform&quot; method=&quot;post&quot;>
<INPUT onblur=&quot;showdate(this.value)&quot; name=&quot;date&quot; maxlenght=&quot;20&quot;>
<BR>
<INPUT name=&quot;date1&quot; maxlenght=&quot;20&quot;>
<BR>
<INPUT name=&quot;date2&quot; maxlenght=&quot;20&quot;>
<BR>
<INPUT name=&quot;date3&quot; maxlenght=&quot;20&quot;>
<BR>
<INPUT name=&quot;date4&quot; maxlenght=&quot;20&quot;>
<BR>
<INPUT name=&quot;date5&quot; maxlenght=&quot;20&quot;>
<BR>
<INPUT type=&quot;submit&quot; value=&quot;Submit&quot;>
<INPUT type=&quot;reset&quot; value=&quot;Reset&quot;>
</FORM>
</DIV>
</BODY>
</HTML>

I hope this helps

Kind Regards

alexfusion
 
Hi alexfusion

Have you tried changing the extension to cfm and try running it in IE and Netscape. It is still giving the same problem mentioned above when I rename the extension and run the page. I don't think it is to do with double quotation for this extension. The showdate needs to be defined in a different way for the extension of cfm. Can you give me a working URl with the extension CFM so I can see what happening. Thank's

From
Yogi
 
Hi Yogi,
I just saw what gerrygerry was pointing.He is right.
The correct syntax is 'maxlength'.My mistake.
Try with that correction.
At this moment I can't give you a working URL for the cfm file.But if you have the chance of testing the cfm document in your own server,try correcting the syntax error that gerrygerry indicated.

I trying to do my best.

Please let me know how you go.

Thank you

alexfusion
 
Hi alexfusion,

Still giving the same error. have you tried it with cfm extension, if so did you get the same errors as I am. Keep the error checker on when you test this example using the cfm extension. Thanks
 
Hi Yogi,

Still can't check the error with the cfm extension.

Let me know if you solved the problem.

alexfusion
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top