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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T15:47:33+00:00 2026-05-17T15:47:33+00:00

I am facing the problem to post the value of form when using while

  • 0

I am facing the problem to post the value of form when using while or for loop.

Here is my code.

<form name="frm1" id="frm1" method="post" enctype="multipart/form-data">
<?php
for($i=0;$i<5;$i++)
{
?>
    <a href="#" onclick="return test1();">Test<?php echo $i;?></a>
    <input type="hidden" value="<?php echo $i;?>" name="var" />
<?php 
}
?>
</form>

And i have used this javascript

<script type="text/javascript">
function test1()
{
    document.frmviewer.method="post";
    document.frmviewer.action="page2.php";
    document.frmviewer.submit();
}   

</script>

Now i want to get the value of tag means “Test1” in page2.php page with hidden variable.

I am able to do it with passing value in javascript but i do not want to pass any variable in javascript and also do not want to pass any variable in url.

Thanks in advance.

Kanji

  • 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-17T15:47:34+00:00Added an answer on May 17, 2026 at 3:47 pm

    You can do it simply using this:

    <form name="frm1" id="frm1" method="post" acti0n="page2.php">
    <input type="hidden" name="topostvalue"/>
    <?php
    for($i=0;$i<5;$i++)
    {
    ?>
        <a href="#" onclick="return test1($i);">Test<?php echo $i;?></a>
    <?php 
    }
    ?>
    </form>
    

    and in js

    <script type="text/javascript">
    function test1(val)
    {
        document.frm1.topostvalue.value = val;
        document.frm1.submit();
    }   
    </script>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this code : <form id=form2 name=form2 method=post action=> <table dir=ltr width=554 border=0
I'm facing a problem using IE here. I need to insert a form on
The following code creates a form based on a model, Post . Problem I
I am facing one problem in the following code , Form is going to
I am facing a problem. So I thought I should post my question here.
Iam facing problem in understanding and converting a matlab code into opencv. I want
iam facing problem in passing array to view. this is my controller code.. function
I am facing problem while setting focus in EdiText. Below is my EditText property.
I am facing problem with UIPanGestureRecognizer. suppose i am adding 10 button dynamicaly using
I'm facing some problem when I fetch page content of particular Id. I'm using

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.