BleepingComputer.com: Making a javascripted date appear in an e-mailed form

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Making a javascripted date appear in an e-mailed form

#1 User is offline   DnDer 

  • Distinguished Member
  • PipPipPipPipPip
  • Find Topics
  • Group: Members
  • Posts: 605
  • Joined: 25-October 08

Posted 17 February 2010 - 04:10 PM

The e-mail I send it to only receives two lines, and I need to add the date onto this:

Name=
SUBMIT=SEND

If I could also elimintate the line that says "sumbit=send" that'd be extra awesome, right there. Can anyone help?


<form method="post" enctype="text/plain" action="mailto:address@domain.com?subject=5 Things to Do Today"	onSubmit="window.alert('This form is being sent via email.  You only need to hit SUBMIT once.  Hit OK at the next prompt and then you can clear the form.')"> 
	<CENTER>
	<table cellpadding="0" cellspacing="0">
	<tr>
	
	  <TR>
	  <TD>Name:
	  </TR>
	
	  <TD> <INPUT TYPE="TEXT" NAME="Name" VALUE="" SIZE="50">
	  </TR>
	
	  <TR>
	  <TD>Date: </TD>
	  <TD>
			&lt;script LANGUAGE="Javascript">
			<!-- 
			
			// Array of day names
			var dayNames = new Array("Sunday","Monday","Tuesday","Wednesday",
							"Thursday","Friday","Saturday");
			
			// Array of month Names
			var monthNames = new Array(
			"January","February","March","April","May","June","July",
			"August","September","October","November","December");
			
			var now = new Date();
			document.write(dayNames[now.getDay()] + ", " + 
			monthNames[now.getMonth()] + " " + 
			now.getDate() + ", " + now.getFullYear());
			
			// -->
			</SCRIPT>
	  </TD>
	  </TR>
	  </TABLE>
	  </CENTER>
	
<br>
<center>
<input id="submit" class="button" type="submit" name="SUBMIT" value="SEND">        
<input id="reset" class="button" type="reset" name="CLEAR FORM" value="CLEAR FORM">

</center>

</FORM>


#2 User is offline   groovicus 

  • Hail Groovicus!
  • PipPipPipPipPipPip
  • Find Topics
  • Group: Moderator
  • Posts: 9,605
  • Joined: 05-June 04
  • Gender:Male
  • Location:Centerville, SD

Posted 17 February 2010 - 07:01 PM

I would use a function to fill in what ever field you wanted, for instance:
var d = new Date();
document.getElementById('date').value = d.getDate();


Your form then would have a field something like:
<TD> <INPUT TYPE="TEXT" ID="date"></TD>

"Take the risk of thinking for yourself, much more happiness, truth, beauty, and wisdom will come to you that way" - Christopher Hitchens

#3 User is offline   Romeo29 

  • Learning To Bleep
  • PipPipPipPipPipPip
  • Find Topics
  • Group: BC Advisor
  • Posts: 2,834
  • Joined: 06-July 08
  • Gender:Not Telling
  • Location:127.0.0.1

Posted 17 February 2010 - 09:09 PM

If you want the Submit=Send removed remove the name="SUBMIT" from the <input> tag.

#4 User is offline   DnDer 

  • Distinguished Member
  • PipPipPipPipPip
  • Find Topics
  • Group: Members
  • Posts: 605
  • Joined: 25-October 08

Posted 18 February 2010 - 12:34 PM

My boss found his own answer before I could give him yours, goovicus. Thanks anyway, though.

Here's what he whipped up, if you were curious:
<script language = "javascript" type="text/javascript">
 
<!--
	
   
	   today = new Date
 
	  weekDayName = new Array ("Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday")
 
 
		monthName = new Array ("January","February","March","April","May","June","July","August","September","October","November","December")
 
 
 
	   function printDate()
 
			  {
 
			 document.write("<b>" + weekDayName[today.getDay()]+ ", " + monthName[today.getMonth()] + " " + today.getDate()+ "</b>")
 
 
 
			 }
 
	 
 
		   
		  -->
 
		</script>
 
<script language = "javascript" type="text/javascript">
 
<!--
function hide_date()
	  {
		document.getElementById('sysDt').value=weekDayName[today.getDay()]+ ", " + monthName[today.getMonth()] + " " + today.getDate();
	   }
  
 -->
 
		</script>
</head>
 
<body  onload="hide_date()">


  <form name="5things" method="post" enctype="text/plain" action="mailto:address@domain.com?subject=5 Things to Do Today";	
	  onSubmit="window.alert('This form is being sent via email.  You only need to hit SUBMIT once.  Hit OK at the next prompt and then you can clear the form.')"> 
	<CENTER>
	<table cellpadding="0" cellspacing="0">
	<tr>
	
	  <TR>
	  <TD>Name:
	  </TR>
	
	  <TD> <INPUT TYPE="TEXT" NAME="Name" VALUE="" SIZE="50">
	  </TR>
	
	  <TR>
	  <TD>Date: 
	  <TD> 
			<script LANGUAGE="JAVASCRIPT">printDate()</SCRIPT>
 
	  </TD>
	  </TR>
	  <input id="sysDt" name="Form_Date" type="hidden" />


EDIT: Sorry, I posted it verbatim, so it doesn't look very clean. I'd try to clean it up, but I don't know if that'd mess up how you'd read it to know what's going on.

This post has been edited by DnDer: 18 February 2010 - 12:35 PM


Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users