Question on submitting form info. to an email.

Please support our JavaScript / DHTML / AJAX advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
Reply

Join Date: Jul 2009
Posts: 5
Reputation: Matsui is an unknown quantity at this point 
Solved Threads: 0
Matsui Matsui is offline Offline
Newbie Poster

Question on submitting form info. to an email.

 
0
  #1
Jul 21st, 2009
i know that there is a mailto: script to use but it is unsecure and all that, so what would be the best way to go about sending form information to an email address in javascript?
Reply With Quote Quick reply to this message  
Join Date: Aug 2008
Posts: 954
Reputation: essential will become famous soon enough essential will become famous soon enough 
Solved Threads: 131
Featured Poster
essential's Avatar
essential essential is offline Offline
Posting Shark

Re: Question on submitting form info. to an email.

 
0
  #2
Jul 21st, 2009
Javascript can filter all the information you need along with your form mailer. But securing those data with this script, is not advisable. Try PHP instead..
Reply With Quote Quick reply to this message  
Join Date: Jul 2009
Posts: 5
Reputation: Matsui is an unknown quantity at this point 
Solved Threads: 0
Matsui Matsui is offline Offline
Newbie Poster

Re: Question on submitting form info. to an email.

 
0
  #3
Jul 21st, 2009
Originally Posted by essential View Post
Javascript can filter all the information you need along with your form mailer. But securing those data with this script, is not advisable. Try PHP instead..
I have only been learning this kind on my own for the past month or so. How would i use PHP in it. I will put in some of what i have:

  1. <script type="text/javascript" language="JavaScript">
  2. //
  3.  
  4. // Function for Form F2
  5.  
  6. function checkTotal() {
  7. document.listForm.total.value = '';
  8. var sum = 0;
  9. for (i=0;i<document.listForm.choice.length;i++) {
  10. if (document.listForm.choice[i].checked) {
  11. sum = sum + parseInt(document.listForm.choice[i].value);
  12. }
  13. }
  14. document.listForm.total.value = sum;
  15. }
  16.  
  17. </script>
  18.  
  19. </HEAD>
  20. <BODY bgcolor="beige">
  21.  
  22. <form name="listForm">
  23. <input type="checkbox" name="choice" value="30" onclick="javascript: checkTotal(listForm)"/> (30.00)<br>
  24. <input type="checkbox" name="choice" value="20" onclick="javascript: checkTotal(listForm)"/> (20.00)/each<br>
  25. <input type="checkbox" name="choice" value="0" onclick="javascript: checkTotal(listForm)"/> (free)<br>
  26. <input type="checkbox" name="choice" value="0" onclick="javascript: checkTotal(listForm)"/> (free)<br>
  27. <input type="checkbox" name="choice" value="12" onclick="javascript: checkTotal(listForm)"/>(free)<br>
  28. Total: <input type="text" size="5" name="total" value="20"/>
  29. </form>

Thank you for your help!!
Last edited by peter_budo; Jul 22nd, 2009 at 2:31 pm. Reason: Keep It Organized - For easy readability, always wrap programming code within posts in [code] (code blocks) and [icode] (inline code) tags.
Reply With Quote Quick reply to this message  
Join Date: Jul 2009
Posts: 5
Reputation: Matsui is an unknown quantity at this point 
Solved Threads: 0
Matsui Matsui is offline Offline
Newbie Poster

Re: Question on submitting form info. to an email.

 
0
  #4
Jul 21st, 2009
Originally Posted by essential View Post
Javascript can filter all the information you need along with your form mailer. But securing those data with this script, is not advisable. Try PHP instead..

i have attached the html document form that i am working with and needing to do the mailing with; it is in word doc though (but it is out of notepad originally).
Attached Files
File Type: doc formcode.doc (31.0 KB, 0 views)
Reply With Quote Quick reply to this message  
Join Date: Aug 2008
Posts: 954
Reputation: essential will become famous soon enough essential will become famous soon enough 
Solved Threads: 131
Featured Poster
essential's Avatar
essential essential is offline Offline
Posting Shark

Re: Question on submitting form info. to an email.

 
0
  #5
Jul 21st, 2009
Hi Matsui,

That problem is that i cannot perform actual run in PHP. I only provide solutions in which i can run first, and that's probably with JavaScript.

I'll provide you with a brief example of validating forms fields using javascript.

But im kinda busy right now, so i'll just post back later...

essential
Reply With Quote Quick reply to this message  
Join Date: Aug 2008
Posts: 954
Reputation: essential will become famous soon enough essential will become famous soon enough 
Solved Threads: 131
Featured Poster
essential's Avatar
essential essential is offline Offline
Posting Shark

Re: Question on submitting form info. to an email.

 
0
  #6
Jul 22nd, 2009
Hi Matsui,

here's a little exercise for you, in where you can apply some experiments on the form elements using different approaches.

JavaScript / DHTML / AJAX Syntax (Toggle Plain Text)
  1. <?xml version="1.0" encoding="utf-8" standalone="no"?>
  2. <?xml-stylesheet type="text/css" href="#css21" media="screen"?>
  3. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  4. "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  5. <html id="xhtml10S" xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
  6. <head profile="http://www.w3.org/2005/10/profile">
  7. <meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7" />
  8. <meta http-equiv="Window-target" content="_top" />
  9. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  10. <meta http-equiv="Content-Style-Type" content="text/css" />
  11. <meta http-equiv="Content-Script-Type" content="text/javascript" />
  12. <title>Free Live Help!</title>
  13. <style id="css21" type="text/css" media="screen">
  14. /* <![CDATA[ */
  15. body { background-color : beige; }
  16. fieldset {
  17. padding : 1em; }
  18. form {
  19. margin : 0;
  20. }
  21.  
  22. ul {
  23. list-style : none;
  24. margin : 1em 0 0 0;
  25. padding : 0; }
  26. li {
  27. margin-bottom : .500em; }
  28.  
  29. /* ]]> */
  30. </style>
  31. <script type="text/javascript">
  32. // <![CDATA[
  33. var modern = Boolean(( !!document.all === true && !!!document.getElementById ) ? 0 : 1 ); /*
  34.   -Checks whether the browser is IE based or not.
  35.   -Primitive values return stricter results over the statement. */
  36.  
  37. var checkTotal = function() {
  38. var dom = 0;
  39. var eLen;
  40. var form; // Declare form variable
  41. try { // Evaluating form variable with a couple statements, so that we can make it available for all types of browser.
  42. dom = 1;
  43. form = document.listForm; // DOM form manipulation.
  44. } // If the try {...} statement fails, catch( error ).
  45. catch( e ) { // catching errors, from the try statement
  46.  
  47. // OBJECT Detection
  48. if ( modern ) // Check if it does support the getElementById method.
  49. form = document.getElementById( "listForm" );
  50. else // referred as IE
  51. form = document.all.listForm;
  52. } // The form has been clarified.
  53.  
  54.  
  55. if ( form ) { // See if we get some result over the form. If it does, then we can start performing validations on the fields'.
  56. if ( dom ) { // Lets walk the DOM.
  57. form.total.value = "";
  58. eLen = form.elements.length; // Getting all the numbers of elements inside the form.
  59. for ( i = 0; i < eLen; ++i ) { // loop around the entire elements.
  60. if ( form.elements[ i ].type === "checkbox" ) { // if the type of element belongs to checkbox group.
  61. form.elements[ i ].onclick = ( function() { // Installing onclick event and skipping the inline callback to your form.
  62. var sum = this.value * 1;
  63. var amount = form.total.value * 1;
  64.  
  65. // A shorthand staments
  66. form.total.value = (( this.checked ) ? amount + sum : amount - sum ); // if this checkbox is checked add its value to the form total, otherwise subtract it to the form "total" field.
  67. form.total.value = (( form.total.value * 1 ) ? form.total.value : "" ); // if current value is not equal to 0, then show the value, or show nothing.
  68. } );
  69. continue; // skip the incrementing procedure if the type of element is different from "checkbox" class.
  70. }
  71. } delete i; // clears up the i variable.
  72. return
  73. } alert( "To be continue!" );
  74. }
  75. };
  76. onload = checkTotal; // Initiating function.
  77.  
  78. // ]]>
  79. </script>
  80. </head>
  81. <body>
  82. <div id="main">
  83.  
  84. <form id="listForm" name="listForm" action="#">
  85. <fieldset><legend>Test Form</legend>
  86. <ul>
  87. <li><label for="c0"><input type="checkbox" id="c0" name="choice" value="30" /> (30.00)</label></li>
  88. <li><label for="c1"><input type="checkbox" id="c1" name="choice" value="20" /> (20.00)/each</label></li>
  89. <li><label for="c2"><input type="checkbox" id="c2" name="choice" value="0" /> (free)</label></li>
  90. <li><label for="c3"><input type="checkbox" id="c3" name="choice" value="0" /> (free)</label></li>
  91. <li><label for="c4"><input type="checkbox" id="c4" name="choice" value="0" /> (free)</label></li>
  92. <li><label for="total"><input type="text" id="total" name="total" value="20" size="6" maxlength="6" /> free</label></li>
  93. </ul>
  94. </fieldset>
  95. </form>
  96. </div>
  97. </body>
  98. </html>

sorry but i am unable to open your attached file, i can only attend on the codes that is posted here.

P.S. it's always nice to submit your form using a function, so that you can prevent the user of getting the form to be submitted with a non-validated entry, if they have turned off the javascript support on their browser. Doing it with a fuction submitted form will ensure that you wont get any spam in form mailer...

essential
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



Tag cloud for JavaScript / DHTML / AJAX
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC