4 Replies - 1194 Views - Last Post: 02 August 2007 - 05:55 AM

#1 RuthdaWebbie  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 3
  • Joined: 01-August 07

JavaScript Variable in Form

Post icon  Posted 01 August 2007 - 12:27 PM

I am trying to get a Javascript variable to sent via email through an HTML form by way of a hidden input tag. I just can't find how to reference the variable. I've tried value="+var+" and value='+var+' and value=var, but of course it just takes it as a literal and not a variable. Help!
Is This A Good Question/Topic? 0
  • +

Replies To: JavaScript Variable in Form

#2 PsychoCoder  Icon User is offline

  • Google.Sucks.Init(true);
  • member icon

Reputation: 1639
  • View blog
  • Posts: 19,853
  • Joined: 26-July 07

Re: JavaScript Variable in Form

Posted 01 August 2007 - 01:18 PM

Welcome to </dream.in.code> RuthdaWebbie.

To help me in helping you can you please post what you have so far so I can look at it and get a better understanding of what you're attempting to do. When you post it put it in code tags (the button with a # on it in the toolbar).

Thanks :)
Was This Post Helpful? 0
  • +
  • -

#3 RuthdaWebbie  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 3
  • Joined: 01-August 07

Re: JavaScript Variable in Form

Posted 01 August 2007 - 02:17 PM

<html><head>

<!-- CHANGE THE NEXT THREE LINES -->

<title>Girls Night Out Parties</title>
<meta name="Description" content="Girl's Night Out Parties offers Adult Women Home Parties offering sensual products.">
<meta name="KeyWords" content="sex toy,vibrators,home based business,home business,sex toy party,butt plugs,work at home business,dildo,love oils,glass sex toy,sexual toy,bondage toy,sex toy parties,dildo vibrator,viacreme,anal sex toy,home business opportunity,adult toys,vibrating bullet,adult sex toy,sex positions literature,anal sex toys,sex toys,home business and party plan,viagra for women,rabbit vibrator,sex toy store">

<!-- CHANGE THE ABOVE THREE LINES -->



<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<META name="Publisher" content="Girl's Night Out Parties http://www.girlsnightoutparties.com">
<META name="revisit-after" content="15 days">
<META name="robots" content="index, follow">
<META name="Robots" content="All">

<!-- this stylesheet has been altered to add form validation styles -->
<link rel=StyleSheet href="../coolstyle.css" type="text/css" media="screen">
<!-- 
========================================================================= 
-->
<!-- this section is for form validation -->
<script language="Javascript" src="../validate.js"></script>
<script language="Javascript" type="text/Javascript">
//Gets DistID from URL
var query = window.location.search;
  // Skip the leading ?, which should always be there,
  // but be careful anyway
  if (query.substring(0, 1) == '?') {
	query = query.substring(1);
  }
  var DistID = query.split(',');
  for (i = 0; (i < data.length); i++) {
	DistID[i] = unescape(data[i]);
  }
function isValid() {
	var objForm = document.forms["myForm"];
	objForm.err = "Please complete the following fields:\n\n";
	objForm.FirstName.required = 1;
	objForm.FirstName.regexp = /^\w*$/;	
	objForm.DayPhone.required = 1;
	objForm.EveningPhone.required = 1;
	objForm.EmailAddress.required = 1;
	objForm.EmailAddress.regexp = "email";
	objForm.IAmOver18.required = 1;
	objForm.IAmOver18.exclude = '-1';

 }
 
function show(layerName){
	document.getElementById(layerName).style.display="block";
	 }		 
</script>
<!-- this section is for form validation -->
<!-- ========================================================================= -->


<script language="Javascript" src="javascripts.js"></script>
<script language="Javascript" src="pop-closeup.js"></script>


<script language="Javascript" type="text/Javascript">
<!--
//Gets DistID from URL
var query = window.location.search;
  // Skip the leading ?, which should always be there,
  // but be careful anyway
  if (query.substring(0, 1) == '?') {
	query = query.substring(1);
  }
  var DistID = query.split(',');
  for (i = 0; (i < data.length); i++) {
	DistID[i] = unescape(data[i]);
  }
  
function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
	d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
	var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
	if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
//-->
</script>
</head>

<BODY BGCOLOR="d60094" background="picts/background-center_long.gif" TEXT="#000000" leftmargin="0" topmargin="0" rightmargin="0" bottommargin="0" marginwidth="0" marginheight="0" onload="MM_preloadImages('picts/shop_online_down.gif','picts/about_us_down.gif','picts/become_a_distributor_down.gif','picts/home_down.gif');isValid()">
<!-- OUTER TABLE-->
<TABLE cellpadding="0" cellspacing="0" border="0" width="800">
  <tr>
	<td VALIGN="TOP"> 
	  <!-- top TABLE-->
	  <!-- top TABLE-->
	  <img src="picts/fadebar.jpg" HEIGHT="17" WIDTH="100%" alt="image"><br>





<!-- PICTURE TABLE-->
<TABLE cellpadding="0" cellspacing="0" border="0" width="100%" class="picturebar" background="picts/main.jpg">
<tr><td ALIGN="left">
<img src="picts/main.jpg" HEIGHT="100" WIDTH="750" alt="image"><br>
</td></tr></table>
	  <!-- PICTURE TABLE-->
	  <img src="picts/fadebar.jpg" HEIGHT="17" WIDTH="100%" alt="image"><br>





<!-- MAIN TABLE-->
	  <TABLE cellpadding="0" cellspacing="5" border="0" width="100%">
		<tr> 
		  <td width="30" height="1251" align="center" valign="TOP">
<p align="left"> <a href="enter_storefront_agreement.htm" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('Shop_online1','','picts/shop_online_down.gif',1)"><img src="picts/shop_online.gif" alt="Shop Online!" name="Shop_online1" width="140" height="20" border="0" class="style" id="Shop_online1"></a></p>
			<p align="left"><a href="about.htm" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('About Us1','','picts/about_us_down.gif',1)"><img src="picts/about_us.gif" alt="About Us" name="About Us1" width="140" height="20" class="style" id="About Us1"></a></p>
			<p align="left"><a href="become_a_distributor.html" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('Become_A_Distributor1','','picts/become_a_distributor_down.gif',1)"><img src="picts/become_a_distributor.gif" alt="Become A Distributor" name="Become_A_Distributor1" width="140" height="20" class="style" id="Become_A_Distributor1"></a> 
			</p>
			<p align="left"><a href="host_a_party.htm" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('Party','','picts/host_a_party_down.gif',1)"><img src="picts/host_a_party.gif" alt="Host A Party!" name="Host A Party!" width="140" height="20" class="style"></a></p>
			<p align="left"><a href="subscribe_1.html" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('subscribe','','picts/join_mailing_list_down.gif',1)"><img src="picts/join_mailing_list.gif" alt="Join Our Emailing List!" name="Join Our Emailing List" width="140" height="20" class="style"></a></p>
			<p align="left"><a href="index.html" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('Home1','','picts/home_down.gif',1)"><img src="picts/home.gif" alt="Home" name="Home1" width="140" height="20" class="style" id="Home1"></a></p>
			<p></p>
			<TABLE cellpadding="0" cellspacing="0" border="1" bordercolor="#0000FF" style="border-collapse: collapse">
			  <tr> 
				<td height="212" valign="top"> <img src="picts/testimonial_party_1.jpg" border="1" width="140" height="210"></td>
			  </tr>
			</table>
			<!-- PICTURE TABLE 1 -->
			<br> 
			<!-- PICTURE TABLE 2 -->
			<TABLE cellpadding="0" cellspacing="0" border="1" bordercolor="#0000FF" style="border-collapse: collapse">
			  <tr> 
				<td height="142" valign="top" bordercolor="#0000FF"> <img src="picts/testimonial_party_2.jpg" border="1" width="140" height="140"></td>
			  </tr>
			</table>
			<!-- PICTURE TABLE 2 -->
			<br> <br>
		  </td>
		  <td width="476" ALIGN="LEFT" VALIGN="TOP"> <p align="center"> <strong>If 
			  you are interested in Hosting A Party and/or Becoming A Distributor, 
			  please complete our online form and you will be contacted by a representative 
			  in your area within 24 hours, excluding weekends.</strong></p>
			<p>We appreciate your interest in Girl's Night Out! Thank you for 
			  your inquiry.</p>
			<form action="http://formmail.monstercommerce.com/cgi-bin/ntformmail/ntformmail.pl" method="post" id="myForm" onsubmit="return validateCompleteForm(this, 'error');">
			  <input type="hidden" name="switch" value="Inquiry">
			  <input name="dir" type="hidden">
			  <table border="0" cellpadding="2" cellspacing="0" height="878" width="105%">
				<tbody>
				<tr>
				<td colspan="2"><span class="mandatory">* -- required</span></td>
				</tr>
				  <tr> 
					<td align="left" width="32%"><strong>First Name:</strong> <span class="mandatory">*</span></td>
					<td align="left" width="68%"><strong> 
					  <input name="FirstName" type="text" id="FirstName"  realname="First Name" size="30">
					  </strong></td>
				  </tr>
				  <tr> 
					<td align="left"><strong>Last Name:</strong></td>
					<td align="left"> <strong> 
					  <input name="LastName" type="text" id="LastName" size="30">
					  </strong></td>
				  </tr>
				  <tr> 
					<td align="left"><strong>Address:</strong></td>
					<td align="left" height="26" valign="top"> <strong> 
					  <input name="Address" type="text" id="Address" size="30" maxlength="30">
					  Apt # 
					  <input name="Apt" type="text" id="Apt" size="6">
					  </strong></td>
				  </tr>
				  <tr> 
					<td align="left"><strong>City:</strong></td>
					<td align="left"> <strong> 
					  <input name="City" type="text" id="City" size="9" maxlength="50">
					  </strong></td>
				  </tr>
				  <tr> 
					<td align="left"><strong>State/Province</strong></td>
					<td align="left"> <strong> 
					  <input name="State" type="text" id="State" size="30">
					  </strong></td>
				  </tr>
				  <tr> 
					<td height="42" align="left"><strong>Zip Code:</strong></td>
					<td align="left"><input name="Zipcode" type="text" id="Zipcode"  size="12"></td>
				  </tr>
				  <tr> 
					<td height="41" align="left"><strong>Cell Phone:</strong></td>
					<td align="left"><input name="Cellphone" type="text" id="Cellphone" size="30"></td>
				  </tr>
				  <tr> 
					<td height="42" align="left"><strong>Day Phone:</strong> <span class="mandatory">*</span></td>
					<td align="left"> <strong> 
					  <input name="Dayphone" type="text" id="DayPhone" realname="Day Phone" size="30">
					  </strong></td>
				  </tr>
				  <tr> 
					<td align="left"><strong>Evening Phone:</strong> <span class="mandatory">*</span></td>
					<td align="left"> <strong> 
					  <input name="EveningPhone" type="text" id="EveningPhone" realname="Evening Phone" size="30">
					  </strong></td>
				  </tr>
				  <tr> 
					<td align="left"><strong>Best Time To Call:</strong></td>
					<td align="left"> <strong> 
					  <select name="BestTimeToCall" size="1" id="BestTimeToCall">
						<option selected>Choose One</option>
						<option value="Morning">Morning</option>
						<option value="Afternoon">Afternoon</option>
						<option value="Evening">Evening</option>
					  </select>
					  </strong></td>
				  </tr>
				  <tr> 
					<td align="left"><strong>My Time Zone Is:</strong></td>
					<td align="left"> <strong> 
					  <select name="MyTimeZoneIs" size="1" id="MyTimeZoneIs">
						<option selected>Choose One</option>
						<option value="Eastern">Eastern</option>
						<option value="Central">Central</option>
						<option value="Pacific">Pacific</option>
						<option value="Mountain">Mountain</option>
					  </select>
					  </strong></td>
				  </tr>
				  <tr> 
					<td align="left"><strong>I Am Over 18:</strong> <span class="mandatory">*</span></td>
					<td align="left">
					  <select name="IAmOver18" id="IAmOver18" realname="I Am Over 18">
						<option value="-1">Choose One</option>
						<option value="Yes">Yes</option>
						<option value="No">No</option>
					  </select>
					  </td>
				  </tr>
				  <tr> 
					<td align="left"><strong>Email Address:</strong> <span class="mandatory">*</span></td>
					<td align="left"><input name="EmailAddress" type="text" id="EmailAddress" realname="Email Address" size="40"></td>
				  </tr>
				  <tr> 
					<td align="left"><strong>Date of Birth:</strong></td>
					<td align="left"><strong> 
					  <input name="DateofBirth" type="text" id="DateofBirth" size="10">
					  MM/DD/YYYY</strong></td>
				  </tr>
				  <tr> 
					<td height="52" align="left"><strong>I Am Interested In:<br>
					  (check all that apply) </strong></td>
					<td align="left"><p><strong> 
						<input name="IAmInterestedIn" id="IAmInterestedIn" value="Hosting A Party" type="checkbox" onclick="show('partyLocale');">
						Hosting A Girl's Night Out Party<br />
						<div id="partyLocale" style="display:none;">
						<br />
						Party location? <br />
						<span class="label">Address</span><br /> <input type="text" name="PartyAddress" size="35"><br />
						<span class="label">City</span><br />
						<strong>
						<input type="text" name="PartyCity" size="35">
						</strong><br />
						<span class="label">State</span><br /><input type="text" name="PartyState" size="20"><br />
						</div>
						<br />
						<input name="IWouldLikeToBecomeA" id="IWouldLikeToBecomeA" value="Distributor" type="checkbox">
						Becoming A Romance Specialist</strong></p></td>
				  </tr>
				  <tr> 
					<td align="left"><strong>I Heard About Girls Night Out Parties 
					  From:</strong></td>
					<td align="left"><p> 
						<input type="radio" name="IHeardAboutGNO" value="Attended A Party">
						Attending A Party 
						<input type="radio" name="IHeardAboutGNOBy" value="Purchasing Products">
						Purchasing Products</p></td>
				  </tr>
				  <tr> 
					<td align="left">&nbsp;</td>
					<td align="left"><p><strong>Name of Distributor:</strong><strong> 
						<input name="Distributor" id="Distributor" size="30" type="text">
						</strong></p></td>
				  </tr>
				  <tr> 
					<td height="61" align="left">&nbsp;</td>
					<td align="left"><p><strong> Search Engine:</strong><br>
						<strong> 
						<select name="SearchEngine" id="SearchEngine">
						  <option selected>Please Select</option>
						  <option value="Yahoo">Yahoo</option>
						  <option value="Google">Google</option>
						  <option value="MSN">MSN</option>
						  <option value="Alta Vista">Alta Vista</option>
						  <option value="Netscape">Netscape</option>
						  <option value="Hot Bot">Hot Bot</option>
						  <option value="Inktomi">Inktomi</option>
						  <option value="Lycos">Lycos</option>
						  <option value="Overture">Overture</option>
						</select>
						</strong> </td>
				  </tr>
				  <tr> 
					<td align="left">&nbsp;</td>
					<td align="left"><p><strong> Recommended By A Friend: <br>
						</strong><strong>Name of Friend<br>
						</strong> 
						<input name="FriendName" id="Friend" size="30" type="text"></strong> 
					  </p></td>
				  </tr>
				  <tr> 
					<td height="42" align="left">&nbsp;</td>
					<td align="left"><p><strong> Other:</strong><strong> </strong><br>
						<strong> 
						<input name="Other" id="Other" size="30" type="text">
						</strong></td>
				  </tr>
				  <tr> 
					<td height="42" align="left"><strong>Comments Here.</strong></td>
					<td align="left"><strong> 
					  <textarea name="Comments" rows="5" cols="35" wrap="soft" class="textarea"></textarea>
					  </strong></td>
					 <!---Trying to get variable DistID to be sent in email-->
					 <input type="hidden" name="Dist ID" value='DistID'>
				  </tr>
				</tbody>
			  </table>
			  <strong> </strong> 
			  <p> <br>
				<input type=hidden name="recipient" value="ruthscott@gnoparties.com">
				<input type=hidden name="redirect"value="http://girlsnightoutparties.com/thanks.html">
				<input type=hidden name="email" value=Email>
				<input type=hidden name="subject" value="Inquiry">
				<input name="submit" class="button" onmouseover="this.className='buttonon'" onmouseout="this.className='button'" value="Submit" type="submit">
				  
				<input name="reset" class="button" onmouseover="this.className='buttonon'" onmouseout="this.className='button'" value="Clear" type="reset">
				<br>
			  </p>
			  <p>  </p>
			</form></td>
		  <td valign="top" align="center"><br> </td>
		  <td width="143" valign="top" align="center"> <span class="title"> 
			<!-- START IMAGE AREA -->
			<br>
			<img src="picts/front-pic1.jpg" width="70" height="70" alt="image" hspace="3" class="style"><br>
			<a href="become_a_distributor.html">Become A Distributo</a><a href="become_a_distributor.html">r</a> 
			<!-- START IMAGE AREA -->
			<br>
			</span> <span class="title"><img src="picts/front-pic4.jpg" alt="image" width="70" height="70" hspace="3" class="style"></span><span class="title"><br>
			<a href="host_a_party.htm">Host A Party</a><br>
			</span> 
			<!-- START IMAGE AREA -->
			<br> <span class="title"> <img src="picts/front-pic3.jpg" alt="image" width="70" height="70" hspace="3" class="style"><br>
			<a href="testimonials.htm">Testimonials</a><br>
			</span> 
			<!-- START IMAGE AREA -->
			<br> <span class="title"><img src="picts/front-pic2.jpg" alt="image" width="70" height="70" hspace="3" class="style"></span> 
			<span class="title"> <a href="win_a_vacation.htm"> <br>
			Win A Vacation</a><br>
			</span> 
			<!-- START IMAGE AREA -->
			<br> <span class="title"> <img src="picts/front-pic5.jpg" alt="image" width="70" height="70" hspace="3" class="style"><br>
			<a href="events.htm">Upcoming Events</a><br>
			</span> 
			<!--- COPY AND PASTE THE AREA BELOW TO ADD A FOURTH PICTURE -->
			<br> </td>
		</tr>
	  </table>
	  <br>



</TD></TR><TR>
	<TD VALIGN="BOTTOM"> 
	  <!-- OUTER TABLE-->
	  <!-- COPYRIGHT -->
	  <TABLE cellpadding=4 cellspacing="0" border="0" width="100%" class="footertext"><tr><td WIDTH="3">
<img src="picts/spacer.gif" HEIGHT="10" WIDTH="3" border="0" alt="image"><BR>

</td><td ALIGN=LEFT VALIGN=TOP>

<script language="Javascript" src="copyright.js"></script>


</td>
		  <td ALIGN=RIGHT VALIGN=TOP>&nbsp; </TD>
		  <td WIDTH="3">

<img src="picts/spacer.gif" HEIGHT="10" WIDTH="3" border="0" alt="image"><BR>

</td></tr></table>
	  <!-- COPYRIGHT -->
	  <!-- OUTER TABLE-->
	</td>
  </tr></table>
</BODY>
</HTML> 

Was This Post Helpful? 0
  • +
  • -

#4 PsychoCoder  Icon User is offline

  • Google.Sucks.Init(true);
  • member icon

Reputation: 1639
  • View blog
  • Posts: 19,853
  • Joined: 26-July 07

Re: JavaScript Variable in Form

Posted 01 August 2007 - 02:26 PM

Let me apologize RuthdaWebbie, I wanted you to post the Javascript in question and give a better explanation of what you're trying to accomplish. Sorry for the confusion, I'll try to be more clear next time :)
Was This Post Helpful? 0
  • +
  • -

#5 RuthdaWebbie  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 3
  • Joined: 01-August 07

Re: JavaScript Variable in Form

Posted 02 August 2007 - 05:55 AM

I hope this helps.

This code gets a variable from the URL called "DistId".
//Gets DistID from URL
var query = window.location.search;
  // Skip the leading ?, which should always be there,
  // but be careful anyway
  if (query.substring(0, 1) == '?') {
	query = query.substring(1);
  }
  var DistID = query.split(',');
  for (i = 0; (i < data.length); i++) {
	DistID[i] = unescape(data[i]);
  } 


What I need to do is figure out how to call "DistId" so it will be sent in an email. I am attempting to go about by using:

<!---Trying to get variable DistID to be sent in email-->
					 <input type="hidden" name="Dist ID" value='DistID'>



Any suggestions about calling it or another way to get the variable "DistId" to be sent in an email?
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1