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 8179469
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T00:00:27+00:00 2026-06-07T00:00:27+00:00

I have two forms here, the first is a select dropdown select, which when

  • 0

I have two forms here, the first is a select dropdown select, which when posted generates another form, creating an amount input boxes based on the number selected. This second form then puts the data from the input boxes into 2 array. All this works perfectly but I am trying to add extra functionality to the submit button on the second form. I created a function ‘showcontet()’ to show and hide the content in the div with id ‘table’. This works perfectly when used on a button outside of the form. When used on the submit button inside the form you can see the content for about 1 second before it then disappears again.

    <head>
      <script type="text/javascript">
           showcontent = function(){
              var content = document.getElementById('tabl');
              content.style.display = 'inline';
           }

      </script>
        <?php 
    $userkey = array();
    $userval = array();
    $usernum = $_POST['usernum'];
    $total = 0;
    ?>


        <form action='MYPIE.PHP' method='POST'>
                HOW MANY SECTIONS?
                    <select name="usernum" value="<?php echo $usernum;?>">
                          <option>1</option>
                          <option>2</option>
                          <option>3</option>
                          <option>4</option>
                          <option>5</option>
                          <option>6</option>
                          <option>7</option>
                          <option>8</option>
                          <option>9</option>
                    </select>
                <input type="submit" name="submitnum" value="submit selection" />
        </form>


    <form action='MYPIE.PHP' method='POST'>     
        <?php 
            for ($i=1; $i<$usernum+1; $i++){
                echo '<input type="hidden" value="' .$usernum.'" name="usernum" />';
                echo "<br>insert key:   <input name='key".$i."' value='".$userkey[$i]."'>   insert value:   <input name='val".$i."' >";

            $userkey[$i] = $_POST["key".$i];
            $userval[$i] = $_POST["val".$i];
            }

        ?>
        </br>
        <input type="submit" value="submit" name="submit keys" onclick="showcontent()" />
    </form>

    </table>


    <div id="tabl" style="display:none;">
    content
    </div>    

Apologies for the bad indentation, I am pretty new to this & thanks for any help

  • 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-07T00:00:28+00:00Added an answer on June 7, 2026 at 12:00 am

    make your second button not a ‘submit’ button but a regular ‘button’
    else it will fire the submit of the form…

    or

    set the ‘showcontent()’ function on the forms ‘onsubmit’ event and let that function return false:

    onsubmit="return showcontent()"
    
    function showcontent(){
        var content = document.getElementById('tabl');
        content.style.display = 'inline';
    
        $.ajax({
            type: "POST",
            url: "MYPIE.PHP",
            data: { usernum: $("select[name='usernum'] option:selected").val() }
            }).done(function() {
                alert('data posted');
        });
    
        return false;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i have two dropdown list. first drop down:1 enter code here <form:select path=custName id=custName>
I have a form on my page which contains two select dropdowns. The first
I have two select elements in my form, Category and Sub-category. At first, only
here is what my code looks like i have two forms: class Form_1 extends
My script is here : jsfiddle i have two attributes in my form that
i have the form, and i want to upload two files. here is the
I have a very strange behavior with Request.Form . Here are two IIS 7
I have two forms, one with a radio button that users must select to
I'm having some issues with dijit.form.Select items. In a page i have two of
I have two forms in my project, form1 and form2. I have added a

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.