Total members 10262 | Gratitudes |It is currently Thu May 24, 2012 9:38 am Login / Join Codemiles


All times are UTC [ DST ]




Post new topic Reply to topic  Quick reply  [ 1 post ] 
Author Question
 Question subject: cotact us html and javascript form
PostPosted: Mon Dec 01, 2008 12:15 am 
Offline
Mastermind
User avatar

Joined: Tue Mar 27, 2007 10:55 pm
Posts: 2279
Location: Earth
Has thanked: 39 time
Have thanks: 61 time

Here an html and javascript form , you can put it in your site to allow users to send mails to using this form and they can decide their topic and part ,you should action the form to any dynamic script like php to send mail .
Code:
<script language="javascript" type="text/javascript">
    function validateForm()
    {
         document.getElementById('errorDiv').innerHTML="";      
          var errorDiv = document.getElementById('errorDiv');
         var email = document.getElementById('email').value;
         var name = document.getElementById('name').value;
          var comment = document.getElementById('comment').value;
          var feedbackTypeindex = document.getElementById('FeedbackType').selectedIndex;                  
          var subject = document.getElementById('subject').value;          
         apos=email .indexOf("@");
         dotpos=email .lastIndexOf(".");
         var errorDiv = document.getElementById('errorDiv');

      if(feedbackTypeindex == 0)
      {
         //alert("Please select feedback type");
         //document.getElementById('errorDiv').innerHTML="<li><font color='red'>Please select feedback type</font></li>";
         errorDiv.innerHTML = "<li><font color='red'>Please select feedback type</font></li>";
         return false ;
      }
      
      if(name== null || name=="")
      {
         //alert("Please enter your name");
         errorDiv.innerHTML = "<li><font color='red'>Please enter your name</font></li>";
         return false;
      }
      
      if(email == null || email =="")
      {
         //alert("Please enter email address");
         errorDiv.innerHTML = "<li><font color='red'>Please enter email address</font></li>";
         return false;
      }
      else if (apos<1||dotpos-apos<2)
      {
         //alert("Please enter valid email address, ie.:yourname@yourdomain.com");
         errorDiv.innerHTML = "<li><font color='red'>Please enter valid email address, ie.:yourname@yourdomain.com</font></li>";
         return false;
      }
      
      
      
      
      if(subject == null || subject=="")
      {
         //alert("Please enter the subject");
         errorDiv.innerHTML = "<li><font color='red'>Please enter the subject</font></li>";
         return false;
      }
      
      if(comment== null || comment=="")
      {
         //alert("Please enter the message");
         errorDiv.innerHTML = "<li><font color='red'>Please enter the message</font></li>";
         return false;
      }      
    }
    </script>

   <div class="content" >

<div>
<table border="0">
<form name="contacts" action="<?=$HOST?>Services/mail.php" method="post" onSubmit="return validateForm();">
<tr><td colspan="2">
feedback type</td><td><select name="FeedbackType" id="FeedbackType">
<option value="0">- select -</option>
<option value="Sponsership">sponsorship</option>

<option value="ads">Advertise</option>
<option value="others">Others</option>
</select></td></tr>
<tr><td colspan="2">
name</td><td><input type="text" name="name" id="name" value="" maxlength="30" /></td></tr>
<tr><td colspan="2">
email</td><td><input type="text" name="email" id="email" value="" maxlength="30" />&nbsp;example: user@domain.com</td></tr>
<tr><td colspan="2">
subject</td><td><input type="text" name="subject" id="subject" value="" maxlength="30" /></td></tr>
<tr><td colspan="2">
comments</td><td><textarea name="comment" id="comment" rows="5" cols="30"></textarea></td></tr>
<tr><td colspan="2"></td><td><input type="submit" value="send" style="width:100px"  /></td></tr>
</form>
<tr><div id="errorDiv" name="errorDiv" style="margin-left:15px;" ></div> </tr>
</table>
</div>
</div>


Attachments:
File comment: form screenshot ,
form.GIF
form.GIF [ 5.33 KiB | Viewed 2334 times ]

_________________
Currenlty programming with : java , html , php , and javascript . (OCJP-6 certified )
TOP
 Profile Send private message  
Reply with quote  
Post new topic Reply to topic Quick reply  [ 1 post ] 
Quick reply


  

 Similar topics
 JavaScript fade out problem
 Usage of xmp html tag
 display code block using html
 read php file in asp and display it as html
 keywords and description of HTML page using meta tag
 javascript read file
 wrapping text around image in html
 draw a horizontal line in your html page
 Configuring the header html font
 multi-frameset and non-re-sizable html frame pages

All times are UTC [ DST ]


Users browsing similar posts

Users browsing this forum: No registered users and 2 guests



Jump to:  
Previous Question | Next Question 




Home
General Talks
Finished Projects
Code Library
Games
Tutorials

Java
C/C++
C-sharp
php
Script
JSP/Servlets
Ajax
ASP/ASP.net
Google SEO
Database
Communications
Phpbb3 styles
Photoshop tutorials
Flash tutorials
Find a job






Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
All copyrights reserved to codemiles.com 2007-2011
mileX v1.0 designed by codemiles team