Jump to content


 


Register a free account to unlock additional features at BleepingComputer.com
Welcome to BleepingComputer, a free community where people like yourself come together to discuss and learn how to use their computers. Using the site is easy and fun. As a guest, you can browse and view the various discussions in the forums, but can not create a new topic or reply to an existing one unless you are logged in. Other benefits of registering an account are subscribing to topics and forums, creating a blog, and having no ads shown anywhere on the site.


Click here to Register a free account now! or read our Welcome Guide to learn how to use this site.

Photo

Making a javascripted date appear in an e-mailed form


  • Please log in to reply
3 replies to this topic

#1 DnDer

DnDer

  • Members
  • 646 posts
  • OFFLINE
  •  
  • Local time:02:17 PM

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>


BC AdBot (Login to Remove)

 


#2 groovicus

groovicus

  • Security Colleague
  • 9,963 posts
  • OFFLINE
  •  
  • Gender:Male
  • Location:Centerville, SD
  • Local time:01:17 PM

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>


#3 Romeo29

Romeo29

    Learning To Bleep


  • Members
  • 3,194 posts
  • OFFLINE
  •  
  • Gender:Not Telling
  • Location:127.0.0.1
  • Local time:02:17 PM

Posted 17 February 2010 - 09:09 PM

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

#4 DnDer

DnDer
  • Topic Starter

  • Members
  • 646 posts
  • OFFLINE
  •  
  • Local time:02:17 PM

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.

Edited by DnDer, 18 February 2010 - 12:35 PM.





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users