[Javascript] sending of variables via email...(makes more sense)

Mark mark_weinstock at yahoo.com
Wed Jan 22 09:32:52 CST 2003


See below... Hope this helps.


--- Jamesjackson73 at aol.com wrote:
> Mark or anyone else.
> how do I set the value then? I thought the below lines was good
> enough...

In the JavaScript, I think you need something similar to (but not
exactly):
document.form2mail.formnumber.value=formNumber

> and what dyou mean by 'check to make sure you have register.globals
> on in your php.ini'

If this is a hosted environment, nevermind. Your hosting company
probably took care of any environmental issues. If not, and you're
using PHP version 4.2.0 or higher (I think), there are differnt ways
that it handles passing variables between pages. Chekc www.php.net
for info if you are setting this up on your own.

> ***********
> formNumber = (date + "" + month + "" + hour + "" + minute + "" +
> second);
> document.write(formNumber); // writes to screen - works fine!
> // End -->
> </script>
> <input type="hidden" name="formNumber" id="formNumber"> // doesn't
> work!
> ***********
> If someone can change the code below to show me how that would be
> great.
> I'm also no expert
> Thanx in advance
> Jim
> 
> In a message dated 1/21/2003 12:05:57 PM Eastern Standard Time,
> mark_weinstock at yahoo.com writes:
> 
> > I'm not a JavaScript expert, but you don't set the VALUE of
> > formNumber anywhere. You set the id, but not a value. I thought
> you
> > needed a Name and Value to set a value for a variable to be
> passed
> > via a form.
> > 
> > Also, check to make sure you have register.globals on in your
> php.ini
> > if you have any problems passing variables properly in PHP.
> > 
> > Mark
> > 
> > --- Jamesjackson73 at aol.com wrote:
> > > Javascript/php/html experts... your'e bound to know how to...
> > > 
> experts
> I have a form in which Ive used the Date() function to create a
> unique numbering system which is different everytime a user
> access's a page. but then (along with other form fields - not shown
> below) the contents of the fields entered would be shown when
> submit was pressed i.e. you entered... etc AND emailed using php,
> but I can't seem to transfer the complete value of 'formNumber'.
> The HTML & HTML with PHP code is below. Please help!
> Regards jimjacksonis at hotmail.com
>  
>  
> ***HTML***form2.html***
> <html>
> <head>
> <title>form2</title>
> </head>
> <body>
> <form name="form2mail" method="post"
> action="http://www.uni.ac.uk/php-cgiwrap/form2mail.php3">
>  
> <script language="JavaScript1.2">
> <!-- Gets now date&time -->
> var time=new Date();
> var date=time.getDate();
> if (date<10)
> date="0"+date
> var month=time.getMonth() +1;
> if (month<10)
> month="0"+month
> var hour=time.getHours();
> if (hour<10)
> hour="0"+hour
> var minute=time.getMinutes();
> if (minute<10)
> minute="0"+minute
> var second=time.getSeconds();
> if (second<10)
> second="0"+second
> formNumber = (date + "" + month + "" + hour + "" + minute + "" +
> second);
> document.write(formNumber); // writes number to screen - works
> fine!
> // End -->
> </script>
>      <input type="hidden" name="formNumber" id="formNumber">
>  
>      <input name="submit" type="submit" id="submit" value="Submit
> Form">
> </form>
> </body>
> </html>
>  
> ***PHP Script***form2mail.php3***
> <html>
> <head>
> <title>form2mail</title>
> </head>
> <body>
> <?php
>  $formcontent = "";
>  $formcontent .= "Form Number: $formNumber\n"; //Should take value
> of formNumber variable
>  $toaddress = "myemailaddress at aol.com";
>  $subjectline = "Form completed by me";
>  $headers = "From: sender\n";
>  mail( $toaddress, $subjectline, $formcontent, $headers);
> 
>  echo "
>  <b>Thank you, The following email has been sent to 
>  $toaddress:</b>
>  <pre>$formcontent</pre>
>  "; // end echo statement
> ?> // end php
> </body>
> </html>
> _______________________________________________
> Javascript mailing list
> Javascript at LaTech.edu
> https://lists.LaTech.edu/mailman/listinfo/javascript


=====
Mark Weinstock
mark_weinstock at yahoo.com
***************************************
You can't demand something as a "right" unless you are willing to fight to death to defend everyone else's right to the same thing.
-Stolen from the now-defunct Randy's Random mailing list.
***************************************

__________________________________________________
Do you Yahoo!?
Yahoo! Mail Plus - Powerful. Affordable. Sign up now.
http://mailplus.yahoo.com



More information about the Javascript mailing list