Follow us on Twitter!
It is the path of least resistance that makes rivers and men crooked. - Bj Palmer
Thursday, April 17, 2014
Navigation
Home
HellBoundHackers Main:
HellBoundHackers Find:
HellBoundHackers Information:
Learn
Communicate
Submit
Shop
Challenges
HellBoundHackers Exploit:
HellBoundHackers Programming:
HellBoundHackers Think:
HellBoundHackers Track:
HellBoundHackers Patch:
HellBoundHackers Other:
HellBoundHackers Need Help?
Other
Members Online
Total Online: 14
Guests Online: 12
Members Online: 2

Registered Members: 82813
Newest Member: VesuviusSentinel
Latest Articles
View Thread

HellBound Hackers | Computer General | Programming

Author

JavaScript .send() not posting form

ShadowGate
Member

Your avatar

Posts: 24
Location:
Joined: 18.07.11
Rank:
Newbie
Posted on 05-02-13 20:00
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.

Code

<?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>




Edited by ShadowGate on 05-02-13 20:14
Author

RE: JavaScript .send() not posting form

lolly
Member



Posts: 24
Location:
Joined: 02.08.12
Rank:
Wiseman
Warn Level: 30
Posted on 05-02-13 20:38
HAI THERE

https://maps.google.com/maps?q=94+Muskingum+Depew,+New+York+14043&layer=c&z=17&iwloc=A&sll=42.908565,-78.686541&cbp=13,282.8,0,0,0&cbll=42.908562,-78.686521&hl=en&ved=0CAoQ2wU&sa=X&ei=gW0RUfCZD4PlwAGYqIHQBA

http://www.facebook.com/travusgonzalez

</creepy>//lulzzzz

Edit: but to answer your question, you can't use:
Code
<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()'

Edited by lolly on 05-02-13 20:43
Author

RE: JavaScript .send() not posting form

ShadowGate
Member

Your avatar

Posts: 24
Location:
Joined: 18.07.11
Rank:
Newbie
Posted on 05-02-13 20:46
Ok first off not sure what the point of posting my facebook was but ok.

secondly I have tried both the inline javascript link and the onclick function, neither work.
Author

RE: JavaScript .send() not posting form

lolly
Member



Posts: 24
Location:
Joined: 02.08.12
Rank:
Wiseman
Warn Level: 30
Posted on 05-02-13 20:51
if you put the onclick attribute on the anchor, not the <a> tag, it will work.
Author

RE: JavaScript .send() not posting form

ShadowGate
Member

Your avatar

Posts: 24
Location:
Joined: 18.07.11
Rank:
Newbie
Posted on 05-02-13 20:55
Please explain (code example maybe) as I was under the impression that the <a> tag is an anchor. In fact I believe the 'a' stands for anchor.
Author

RE: JavaScript .send() not posting form

lolly
Member



Posts: 24
Location:
Joined: 02.08.12
Rank:
Wiseman
Warn Level: 30
Posted on 05-02-13 21:09
I meant the button tag, not anchor.

Anyways, as long as you're linking to the correct form, this WILL work:

<a href="#" onclick="document.forms[0].submit();">Submit</a>
Author

RE: JavaScript .send() not posting form

ShadowGate
Member

Your avatar

Posts: 24
Location:
Joined: 18.07.11
Rank:
Newbie
Posted on 05-02-13 21:23
I am linking to the correct form and it does not work.
Author

RE: JavaScript .send() not posting form

lolly
Member



Posts: 24
Location:
Joined: 02.08.12
Rank:
Wiseman
Warn Level: 30
Posted on 05-02-13 23:35
what does

<a href="#" onclick="alert(1);">Submit</a>

do?

If it doesn't alert anything, then there is some weird CSS or something that's blocking the event.

If it does alert 1, then you're not linking the form correctly.

Just play around with it in firebug and you'll figure it out.
Author

RE: JavaScript .send() not posting form

Euforia33
philalethes



Posts: 867
Location:
Joined: 05.10.09
Rank:
God
Posted on 06-02-13 01:03
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.


Edited by Euforia33 on 27-02-13 04:50
Author

RE: JavaScript .send() not posting form

ShadowGate
Member

Your avatar

Posts: 24
Location:
Joined: 18.07.11
Rank:
Newbie
Posted on 06-02-13 18:03
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.

Code
if(isset($_POST['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?
Author

RE: JavaScript .send() not posting form

ynori7
Member



Posts: 1486
Location: #valhalla
Joined: 08.10.07
Rank:
God
Posted on 08-02-13 10:50
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.

Code
if(isset($_POST['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:
Code
var_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:".


halls-of-valhalla.org/images/affiliateLogo.png voodoorage.halls-of-valhalla.org/images/smallLogo.png
i537.photobucket.com/albums/ff338/ynori77/archenemysig1.jpg
ynori7 http://halls-of-valhalla.org