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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T09:57:01+00:00 2026-05-27T09:57:01+00:00

I have the following two fields in a form: <input type=button value=Rep id=rep name=rep

  • 0

I have the following two fields in a form:

<input type="button" value="Rep" id="rep" name="rep" style="width:50px" onclick="addRep()" />
<input type="hidden" value="<?php echo $comment_id; ?>" />

I need to get the value of the hidden field in the form. So I thought to use some function to call the hidden field field next to the button whenever it is triggered.

I need to get that hidden field specifically, that comes after the button pressed.

I cant use methods like getElementByID,,cause I generate many of those hidden fields and buttons with the same id.. (I generate them dynamically with php).

In theory, I think that I could get the context of the button pressed (after trapping its event) and then use some function to find the next element in the form..

But I am not sure how to do that!

  • 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-27T09:57:02+00:00Added an answer on May 27, 2026 at 9:57 am

    Consider that you might have another element between your button and your hidden element. For example:

    <input type="button" value="Rep" id="rep" name="rep" style="width:50px" onclick="addRep()"/>
    <input type="text" id="someText" value="whatever"/>
    <input type="hidden" id="someButton" value="anything"/>
    

    In this case, you can target the hidden input element that is “closest” to the identified button by performing some checks:

    var rootNode    = document.getElementById('rep'),
        currentNode = rootNode.nextSibling,
        closestHidden;
    
    function check(node) {
      return node.nodeType === 1 && node.localName === 'input' && node.type === 'hidden'
    };
    
    do {
      if (check(currentNode)) {
        closestHidden = currentNode; break;
      }
    } while (currentNode = currentNode.nextSibling);
    
    alert(closestHidden.id);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a form with (at least) the following two fields: country club The
I am using jQuery datepicker, I have two datepicker input fields, like following: <html>
I have an HTML document with the following form: <form> <input type=text id=price> <input
I have the following query where I combine two fields from two tables: <cfquery
Hi I have the following cod throughout my app but with just two fields
I have the following problem: I got a view with two text fields and
I have the following two tables: Customer { int Id int Name } Bills
We have a content type with two imagefield / filefield fields, and after migrating
In SQL server 2008: Suppose I have two tables. Table1 has 3 fields: Name,
I have some XML in the following schema: <Form ID=1 Formtitle=Title> <Fields> <Fieldset Legend=LegendText

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.