JavaScript .send() not posting form
I have a form that has an anchor styled as a button and I am trying to submit the form via javascript. I am able to send the form using an input tag or a button tag. The button comes the closest to matching the anchors style but I have not been able to get them to look the same. I would really like to use the anchor if I can, please help.
<?php
require_once("../content/includes/validation.php");
?>
<!DOCTYPE html>
<html lang="en">
<head>
<title>Contact | Buffalo Bridal Association</title>
<meta charset="utf-8" />
<meta name="description" content="" />
<meta name="keywords" content="" />
<meta name="author" content="" />
<meta name="robots" content="" />
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1" />
<!--<base href="http://localhost/buffalobridalassociation/" />-->
<base href="http://hooksshoes.com/bbatest/" />
<link rel="icon" href="content/images/favicon2.png" />
<link rel="stylesheet" href="content/styles/reset.css" media="all">
<link rel="stylesheet" href="content/styles/layout.css" media="screen" />
<link rel="stylesheet" href="content/styles/site.css" media="screen" />
<script src="content/scripts/jquery.js"></script>
<script src="content/scripts/document_ready.js"></script>
<script src="content/scripts/cufon-yui.js"></script>
<script src="content/scripts/cufon-replace.js"></script>
<script src="content/scripts/Josefin_Sans_400.font.js"></script>
<script src="content/scripts/Tangerine_700.font.js"></script>
<script src="content/scripts/atooltip.jquery.js"></script>
<script src="content/scripts/jquery.nivo.slider.pack.js"></script>
<script src="content/scripts/script.js"></script>
<!--[if lt IE 9]>
<script type="text/javascript" src="js/html5.js"></script>
<style type="text/css">
.aToolTip, .box1, .box1 .inner { behavior: url(js/PIE.htc); }
</style>
<![endif]-->
<!--[if lt IE 7]>
<div style='clear:both;text-align:center;position:relative'>
<a href="http://www.microsoft.com/windows/internet-explorer/default.aspx?ocid=ie6_countdown_bannercode"><img src="http://www.theie6countdown.com/images/upgrade.jpg" border="0" alt="" /></a>
</div>
<![endif]-->
</head>
<body id="page6">
<div class="body1">
<div class="main">
<header>
<div class="wrapper">
<h1><a href="site/index.php" id="logo"></a></h1>
<nav>
<ul id="menu">
<li class="first"><a href="site/index.php">Home</a></li>
<li><a href="site/members.php">Members</a></li>
<li><a href="site/shows.php">Bridal Shows</a></li>
<li id="menu_active"><a href="site/contact.php">Contact</a></li>
</ul>
</nav>
</div>
</header>
</div>
</div>
<div class="body3">
<div class="main">
<article id="content">
<div class="wrapper">
<div class="pad">
<div class="wrapper">
<section class="col1">
<h2>Contact <span>Form</span></h2>
<?php include("../content/includes/contact-email.php"); ?>
<form id="ContactForm" action="site/contact.php" method="post">
<div>
<div class="wrapper">
<span><label for="name">Name:</label></span>
<input type="text" class="input" id="name" name="name" />
</div>
<div class="wrapper">
<span><label for="email">Email:</label></span>
<input type="text" class="input" id="email" name="email" />
</div>
<div class="textarea_box">
<span><label for="message">Message:</label></span>
<textarea name="message" id="message" cols="1" rows="1" placeholder="Tell us about your experience with our Member businesses."></textarea>
</div>
<button type="submit" value="submit" name="submit" class="button" id="submit"><strong>Send</strong></button>
<a href="javascript:document.getElementById('ContactForm').submit();" class="button" name="submit" id="submit"><strong>Send</strong></a>
<a href="javascript:document.getElementById('ContactForm').reset();" class="button"><strong>Clear</strong></a>
</div>
</form>
<p style="margin-top:75px;"><strong>Wedding professionals, not a member of the BBA, what are you waiting for?</strong><br /><a href="http://www.buffalobridalassociation.com/BBA_Application.pdf">Get your membership application today!</a></p>
</section>
<section class="col2 pad_left2">
<h2>Our <span>Info</span></h2>
<div class="wrapper pad_bot1">
<p class="address">
Telephone:<br>
Fax:<br>
E-mail:
</p>
</div>
<h2>Your <span>Feedback</span></h2>
<p class="pad_bot1">All Members of Buffalo Bridal Association subscribe to a <a href="site/ethics.html">Code of Ethics</a> by which they pledge themselves to honesty and integrity.<br /><br />BBA Members acknowledge that their customers rely on their knowledge, experience and recommendations, and pledge not to betray the trust of their customers.</p>
</section>
</div>
</div>
</div>
</article>
</div>
</div>
<?php
include("../content/includes/footer.php");
?>
</body>
</html>```
HAI THERE
http://www.facebook.com/travusgonzalez
</creepy>//lulzzzz
Edit: but to answer your question, you can't use:
markup<a href="javascript:document.getElementById('ContactForm').submit();" class="button" name="submit" id="submit">
you would have to do something like onClick='document.form[0].submit()'
I've come across this before, the problem is the name of the button. You can not call it submit while using submit() as you are basically overriding the method. Change it to something like: <button id="formsubmit" class="button" name="formsubmit" value="submit" type="submit"> and it should work.
Edit: Pen testing new fetures.
Ok so I believe the javascript is working fine, and as it should. I think the problem is how I expected the php to pick up the submit.
... Send email ...
}```
I don't think the POST varable is being set to submit. Why is this and how can I fix my php to work with the way javascript submits the form?
ShadowGate wrote: Ok so I believe the javascript is working fine, and as it should. I think the problem is how I expected the php to pick up the submit.
... Send email ...
}```
I don't think the POST varable is being set to submit. Why is this and how can I fix my php to work with the way javascript submits the form?
Try putting this before the if statement:
```markupvar_dump($_POST['submit']);die; ```
Then try again. If it shows you something like "NULL" then your post parameter wasn't set. If you have a value, then there was something wrong with your emailing function (such as trying to send emails without having an SMTP server). If you see nothing at all then you probably never even reached that point in the code and your problem is somewhere else.
By the way, your initial problem could have been related to the fact that Firefox no longer allows javascript to be executed through the URL by prefixing it with "javascript:".