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

  • Home
  • SEARCH
  • 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 4015010
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T09:33:59+00:00 2026-05-20T09:33:59+00:00

I wish to have a submit button (for the default form action), and an

  • 0

I wish to have a submit button (for the default form action), and an additional button for a second action.

I have the following code:

<html>
<head><title></title>
<?PHP
$Input = "";
if(isset($_POST['Input'])) $Input = $_POST['Input'];
?>
</head>

<body>
    <FORM id ="form1" method="post">
        Input: <INPUT TYPE = "TEXT" VALUE ="<?php echo $Input;?>" NAME = "Input" SIZE="3">
        <INPUT TYPE = "submit" id = "action1" VALUE = "action 1"> 
        <INPUT TYPE = "button" id = "action2" VALUE = "action 2">
    </FORM>
    <br>

    <script type="text/javascript">
        var form = document.getElementById('form1'); 

        form.onsubmit = function() {
            document.getElementById("php_code_action1").innerHTML="<?php echo "action 1<br>"; ?>";
            document.getElementById("php_code_action2").innerHTML="";
        };

        document.getElementById('action2').onclick = function() 
        {     
            document.getElementById("php_code_action2").innerHTML="<?php echo "action 2<br>"; ?>";
            document.getElementById("php_code_action1").innerHTML="";
        } 
    </script>

    <span id="php_code_action1"> </span>
    <span id="php_code_action2"> </span>

</body>
</html>

A click on the Action2 button works as I expect, but a click on “Action1” button has the page refresh and the output of action1 disappear.

Why is there a refresh, and how can I show the output of action1?

  • 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-05-20T09:34:00+00:00Added an answer on May 20, 2026 at 9:34 am
    form.onsubmit = function() {
        document.getElementById("php_code_action1").innerHTML="<?php echo "action 1<br>"; ?>";
        document.getElementById("php_code_action2").innerHTML="";
        return false;
    };
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an html form which includes a textarea box and a submit button
Hoi! I have a form I wish to submit, but I need to add
I have a form which once the Submit button is pressed, it goes to
I have 2 buttons , one being a image submit button and the other
I have small page which has label, DropDownList and a submit button. <div> <asp:label
I have a content type and I wish to edit the submit function. I
I have a form, and inside it there's a while() with checkboxes. I wish
I wish to have a newsletter on my home page. I found the following
I have a controller that has the following index action : def index if
I have some code where I wish to call a page method for each

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.