Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7927807
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T19:30:14+00:00 2026-06-03T19:30:14+00:00

I was wondering how to call a php script from javascript, I know your

  • 0

I was wondering how to call a php script from javascript, I know your meant to use AJAX but I just cant get it to work.

I have a contact me form in html, and onClick, it activates a javascript script, that validates the values entered into the different fields.

If all are valid I want it to call a php script called mail.php, that sends an email.

The html, javascript and php scripts all work, its just this little bit I’m not sure of.

Form:

    <form name="mail" id="mail" method="post">
        <textarea class="message" name="message" id="message">Input message to send here.</textarea>
          <div class ="type">
          <h2>Contact</h2><br /><br />
          <h3>Name</h3><br />
          <h3>Email</h3><br />
          <h3>Subject</h3><br />
          <div class="text-boxes">
             <input type="text" class="input-text" name="name" id="name"/><br /><br />
             <input type="text" class="input-text" name="email" id="email"/><br /><br />
             <input type="text" class="input-text" name="subject" id="subject"/><br /><br />
          </div>
          <div class="submit">
             <input type="image" src="images/submit.gif" alt="Submit button" onClick="validate(this.form)"/>
          </div>
     </form>

On submit, the form calls a js script.

Thanks.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T19:30:22+00:00Added an answer on June 3, 2026 at 7:30 pm

    You should submit the form. (or use JavaScript to valid the form then submit it)

    <form id="email_form">
        <input name="name">
        <input type="submit" id="submit_btn">
    </form>
    

    Then mail.php will get the information, and you can do whatever you want there.

    ADDED

    To submit a form in JavaScript:

    document.querySelector("#submit_btn").addEventListener("click",function(e){
        var form = document.querySelector("#email_form");  //Select the form
        form.submit();                            //Submit it (very self-explanatory)
        e.preventDefault();
    },false);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm wondering if I can use the header(Location: someFile.php); from a script that is
I know PHP has call_user_func , I was just wondering if JavaScript had something
Possible Duplicate: How to call a JavaScript function from PHP? I have a php
I was wondering when to call from the view a Custom View Helper like
I was wondering how you would call a getter function from another class in
Hi I was wondering how can I call a method just for one time
I was wondering if it's possible to call the same kernel functions from different
I am wondering if there is some way to call C++ code from Common
(CrossSlide) (LightBox) This is my header: <script type=text/javascript src=<?php echo ROOT.'sources/js/jquery.js'; ?>></script> <script type=text/javascript
I was just wondering if it is valid to call mysql_pconnect multiple times in

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.