Go Back   CodingForums.com > :: Client side development > HTML & CSS

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 01-03-2013, 04:00 PM   PM User | #1
tifone7
New to the CF scene

 
Join Date: Jan 2013
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
tifone7 is an unknown quantity at this point
Problem with contacts form

Hi guys.
First of all it's been a long time since i follw you and your community.How many helps i f've found through these pages!!
So thank for any help you will able to give me in the future.I'm a newbie.Sorry for my english, i'm writing from Italy..
My problem is..I'm making a new site, full js based. In the contact form submit and clear buttons don't work. I'm pretty sure html code and php work, because they work well in onother site i made (html and css).
I think the problem is the instruction onClick="document.getElementById that doesn't work with js site..can you help me?

HTML code
Code:
<div class="wrapper contPad">
      <h2>Contattami</h2>
      <form id="form1" action="mail.php" method="post">
          <div>
    	   <fieldset>
			<label>NOME</label> 
									
    			<input name="field_name" input type="text" class="input" value="Almeno 3 caratteri" > 

    			<br>
										
			<label>E-MAIL:</label> 
										
                        <input name="field_email" input type="text" class="input" value="Indirizzo valido di posta elettronica"/>
    										
    			<br>
										
			<label>MESSAGGIO:</label>
										
    			<textarea name="field_message" cols="40" rows="7"></textarea>
    										
    			<br><br>
    								
                        <div class="btns right"> <a href="#" class="button" onClick="document.getElementById('ContactForm').reset()">clear</a>
							 <a href="#" class="button" onClick="document.getElementById('ContactForm').submit()">Send</a></div>
    	  </fieldset>
        </div>
    </form>
                          
</div>
PHP code
PHP Code:
<?php
$field_name 
$_POST['field_name'];
$field_email $_POST['field_email'];
$field_message $_POST['field_message'];
     
$mail_to 'deep_purple@tin.it';
$subject 'Richiesta di informazioni da parte di '.$field_name;
     
$body_message 'Nominativo: '.$field_name."\n";
$body_message .= 'E-mail: '.$field_email."\n";
$body_message .= 'Messaggio: '.$field_message."\n";


$headers 'From: '.$field_email."\r\n";
$headers .= 'Reply-To: '.$field_email."\r\n";
     
$mail_status mail($mail_to$subject$body_message$headers);
     
if (
$mail_status) { ?>
<script language="javascript" type="text/javascript">
alert('Grazie per la richiesta inoltrata. Sarete contattati quanto prima.');
window.location = 'contatti.html';
</script>
<?php
}
else { 
?>
<script language="javascript" type="text/javascript">
alert('Recapito fallito.Per favore riprovare ad eseguire la richiesta più tardi');
window.location = 'contatti.html';
</script>
<?php
}
?>

Last edited by tifone7; 01-03-2013 at 04:04 PM..
tifone7 is offline   Reply With Quote
Old 01-04-2013, 12:24 AM   PM User | #2
AndrewGSW
Senior Coder

 
Join Date: Apr 2011
Location: London, England
Posts: 2,120
Thanks: 15
Thanked 354 Times in 353 Posts
AndrewGSW will become famous soon enough
Your form has the id 'form1' but you are referring to

document.getElementById('ContactForm')

which does not exist.
__________________
"I'm here to save your life. But if I'm going to do that, I'll need total uninanonynymity." Me Myself & Irene.
Validate your HTML and CSS
AndrewGSW is offline   Reply With Quote
Old 01-04-2013, 08:39 AM   PM User | #3
tifone7
New to the CF scene

 
Join Date: Jan 2013
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
tifone7 is an unknown quantity at this point
Ok,thks Andrew.I've changed the error. However the problem remains.
If i keep the php file there's something in html code that i can change?.For exemple can i use input type="submit"? what do i have to change to make work the button "Send"?
Thank you
tifone7 is offline   Reply With Quote
Old 01-04-2013, 07:38 PM   PM User | #4
AndrewGSW
Senior Coder

 
Join Date: Apr 2011
Location: London, England
Posts: 2,120
Thanks: 15
Thanked 354 Times in 353 Posts
AndrewGSW will become famous soon enough
Code:
<input type="submit" id="bSubmit" name="bSubmit" value="Send">
will submit the form when clicked.
__________________
"I'm here to save your life. But if I'm going to do that, I'll need total uninanonynymity." Me Myself & Irene.
Validate your HTML and CSS
AndrewGSW is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 05:12 PM.


Advertisement
Log in to turn off these ads.