PDA

View Full Version : Form question


pauldf
12-09-2011, 01:18 AM
Hi Guys

I hope this is the right place to post this question. A friend of mine did up this script for me, my ones are usually done in dreamweaver/php, form insert etc., I think he built this in/using jquery. I'll hold my hands up here and say I'm only starting into the jquery side of things and my knowledge is fairly limited. Unfortunately I won't be able to get in touch with my friend who did this up for about 4 - 6 weeks (he's off traveling). I have been trying to dig through the code to see will anything stand out but the more I look at it the worse the brain gets.

I just have a few questions if someone can help me. The first thing I noticed is there is no "action" in the top line of the form id

<form id="contact-form" enctype="multipart/form-data" method="post" >

Is this an over sight by him or is this the way these forms work and if so how do you tell it to go to the php action script? Or is there some other way it works when someone clicks submit. Here is the form that he did up:

<form id="contact-form" enctype="multipart/form-data" method="post" >
<fieldset>
<label>
<span class="name-input">Name:</span>
<input name="name" value="" onBlur="if(this.value=='') this.value=''" onFocus="if(this.value =='' ) this.value=''" />
</label>
<label>
<span class="name-input">Email:</span>
<input name="name1" value="" onBlur="if(this.value=='') this.value=''" onFocus="if(this.value =='' ) this.value=''" />
</label>
<label>
<span class="name-input">Message:</span>
<textarea name="message" onBlur="if(this.value=='') this.value=''" onFocus="if(this.value =='' ) this.value=''"></textarea>
</label>
</fieldset>
<div class="link-form">
<a class="link link-margin" href="#" onClick="document.getElementById('contact-form').reset()">Clear</a>
<a class="link" href="#" onClick="document.getElementById('contact-form').submit()">Send</a>
</div>
<div class="clear"></div>
</form>


One other thing, in the script he has things like...if(this.value==' ')... am I meant to fill in values for these or is that the way this script works. To be honest here guys like I said I am fairly limited when it comes to this, so if you guys reckon it would be to much for me to get my head around, I will just throw out his script and put in one of my ones...it won't look as pretty but at least I know it'll work :)

Any advice would be much appreciated, thanks for taking the time to read this.

All the best.

edbr
12-09-2011, 02:49 AM
is there a onSubmit action perhaps?

pauldf
12-09-2011, 03:04 AM
Hi edbr

Thanks for getting back. No that is whats getting me. I went looking through everything and I can't see anything that tells the form what to do once someone clicks submit. The only thing I have seen is the piece of code that has the onClick part in it. It looks like there is a space for a link "href"

<div class="link-form">
<a class="link link-margin" href="#" onClick="document.getElementById('contact-form').reset()">Clear</a>
<a class="link" href="#" onClick="document.getElementById('contact-form').submit()">Send</a>
</div>

But that wouldn't be where to put the link to the handling form would it. I'm beginning to think that something like "Action=" or "onSubmit" must have been left out of the script. Thanks again for getting back.

edbr
12-09-2011, 03:41 AM
add an action and see what happens , thtas waht i would do, just test it

pauldf
12-10-2011, 01:26 PM
Hi edbr

Okay I think I may be on to something. I spent ages going through line after line to see could I see what was going on, or where I could put in the action. And i just decided to try add in:

form action="contactform.php"

just before the form id and at least when I click submit now, its starting to look for the php script to send the form. I just did up a simple php script to test the submit button, so I'm gonna do up a more secure one later with validation checks etc. and run it and see will it work for me. If it does happy days...if not I can see my computer going flying out the window :-D

Thanks again for your posts I'll let you know how it goes.

pauldf
12-12-2011, 12:13 PM
Okay just a quick update I just added "form action" to the code and pointed it at my php script and it seems to be working fine now, happy days :)