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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T00:29:35+00:00 2026-05-23T00:29:35+00:00

maybe very easy! I’m php coder and I don’t have experience in js but

  • 0

maybe very easy!
I’m php coder and I don’t have experience in js but I must do this for one of my codes
suppose I have sub1 in page after clicking it must be that sub1 but value now is sub2

       <html>
        <head>
        <title>pharmacy</title>
        </head>
        <body>
        <form method="post" action="pharmacy.php">
        <?php
       //some code
            if(array_key_exists('update',$_POST)){
                //somecode
                }
        ?>
<input type="submit" name="update" value="<?php echo if(isset($_GET['update'])) ? 'Show' : 'Update' ?> ">
    </form>
    </body>
    </html>
  • 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-23T00:29:36+00:00Added an answer on May 23, 2026 at 12:29 am

    show as function name does not really make sense here (imo), but you could do:

    <input type="submit" name="sub" value="sub1" onclick="show(this)">
    

    and

    function show(element) {
        element.value = 'sub2';
    }
    

    Important:

    But that will actually not solve your problem. As soon as you click the button, the form is submitted, meaning the browser initiates a new request and will load a new page. So every change you made the current page is lost anyway.

    The question is: What are you trying to do?

    It seems to me that you should change the value of the button on the server side. You have to keep track which form was submitted (or how often, I don’t know what you are trying to do) and set the value of the button accordingly.

    Update:

    I see several possibilities to solve this:

    1. You could keep using JavaScript and send and get the data via Ajax. As you have no experience with JavaScript, I would say you have to learn more about JavaScript and Ajax first before you can use it.

    2. You could add a GET parameter in your URL with which you can know which label to show for the button. Example:

      <form method="post" action="?update=1">
      

      and

      <input type="submit" name="sub" value="<?php echo isset($_GET['update']) ? 'Show' : 'Update' ?> ">
      
    3. Similar to 2, but use a session variable (and not a GET parameter) to keep track of the state.

    Update2:

    As you are already having $_POST['update'] you don’t need the URL parameter. It could just be:

    <html>
        <head>
            <title>pharmacy</title>
        </head>
        <body>
            <form method="post" action="pharmacy.php">
            <input type="submit" name="update" value="<?php echo isset($_POST['update']) ? 'Update' : 'Show'; ?> ">
            </form>
        </body>
    </html>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Maybe this is something very easy to do it but so far it's taking
I have a similar question to this one : It's very easy in py-amqp/flopsy
I know this maybe a very basic question but I'm having a bit of
Maybe I just don't know .NET well enough yet, but I have yet to
Maybe a very easy question, but I am already looking for hours on the
it's a very easy question maybe, but i can't find any working plug in
I have known PHP basics, functional programming for a long time before. But this
I am very new to css so this maybe a simple answer. I have
This may be a very noobie question, but in today's world of web app
This may be a very simple problem, but I couldn't find an answer googleing

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.