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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T23:16:28+00:00 2026-05-23T23:16:28+00:00

I am incrementing a value of a hidden element using javascript , and posting

  • 0

I am incrementing a value of a hidden element using javascript ,
and posting it in the $_POST array.
But it increases only once , and then remains the same. Please help.

My file is incrementing.php with the below code:

<script language="Javascript">

function NextClicked()
{  
 document.getElementById("LabelClicked").value = 
  document.getElementById("LabelClicked").value + 1 ; 

 document.forms["incrementing"].submit();

}
</script>


<?php

if(isset($_POST['LabelClicked']) && $_POST['LabelClicked']>=1)
{
  $_POST['LabelClicked'] = $_POST['LabelClicked'] +9; 

}

?>
<?php
    if(isset($_POST['clickednext']))
    {
        echo 'Value ='.$_POST['LabelClicked'];
    }
    else
    {
        echo "Not Clicked Yet";
    }   
?>
<form name = "incrementing" method="post" action="incrementing.php">
 <div class=d2 align=left><a href="#" onclick=" NextClicked(); submit();">Next</a>
<input type = "hidden"  id="LabelClicked" name="LabelClicked" />
</form>
  • 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-23T23:16:30+00:00Added an answer on May 23, 2026 at 11:16 pm

    Don’t you need to set the value of LabelClicked id to be what the new, incremented value is?

    <input type="hidden"  id="LabelClicked" name="LabelClicked" value="<?php echo $_POST['LabelClicked']; ?>" />
    

    Otherwise it is incrementing from “” everytime. You should also make sure that you are treating

    document.getElementById("LabelClicked").value
    

    as an integer and not a string, or else you will get “111111”

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This is a question about incrementing one value of a MATLAB array multiple times
I've a for loop which keeps incrementing an integer value till the loop completes.
In my Android app I: generate an incrementing build number (integer) using a script
Via Google Mock's Return() you can return what value will be returned once a
I would like to insert some value into a table, which has an auto-incrementing
I've read this thread: Issues incrementing a field in MySQL/PHP with prepared statements but
I want to initialize an array with 10 values starting at X and incrementing
How does Java, Kotlin, and Android handle returning an Array value at a given
I have been storing and incrementing download counters like this: INCRBY downloads:<filename> 1 But
On this website the textual time is dynamically updated, I'm guessing using JavaScript. This

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.