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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T22:58:03+00:00 2026-05-23T22:58:03+00:00

I am new in jQuery and I have to do a dynamic form with

  • 0

I am new in jQuery and I have to do a dynamic form with two selects, in one select I need to make that if the user choose the option let’s say B another select appear but if he choose A then it doesn’t show, the problem is that I can get to every element in the form, I do the form with a PHP for and then pass the variable to the id’s so it gets something like this:

<select id="edocivil<?php echo $x ?>" class="textbox" name="edocivil<?php print $x; ?>" >

$x been the number of the field, I need to get the value of that field so if it B it shows these other select that is in a div, this is how:

<div id="regimen<?php echo "$x"; ?>" style="display:none;">

and what I do is have a hidden field with the value of $x so I can get it with jQuery but I can’t do it I need help please, I leave the jQuery script and the hidden field thank you.

$(document).ready(function(){ //asÌ es como se crean las funciones jQuery. solo cree

var id_edo= $(this).next(".numero_id_edo").val();
alert(id_edo);
$("#edocivil"+id_edo).change(function(){ //se ejecuta con el evento onChange  


 var val = $("#edocivil"+id_edo).val()

if(val =="B")
{
    $("#regimen"+id_edo).show();  
}
else
{
    $("#regimen"+id_edo).hide();  
}

});//change
});//ready

the hidden field:

<input type="hidden" name="numero_id_edo"  id="numero_id_edo" value="<?php echo $x; ?>" class="numero_id_edo">

I tried to make it the most understandable way, I am really new to this of Stack Overflow

  • 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-23T22:58:04+00:00Added an answer on May 23, 2026 at 10:58 pm

    ok if i have understood well you can do it like this, first get the value of hidden field so that we have the $x

    var $x = $("#numero_id_edo").val(); //here we get the value of hidden field or inother words $x
    

    now on the basis of this we can get the selected value of dropdown

    $("#edocivil"+$x).change(function(){
    
    alert($(this).val());
    
    });
    

    edit

    by assuming you have multiple hidden fields on the page you can get there values like

    var idArr=[];
    
    $("input:hidden").each(function(){
    
    idArr.push($(this).val());
    });
    
    alert(idArr.length);
    
    for (v in idArr )
    {
    alert(idArr[v]);
    }
    

    look at this fiddle hopefully you will get the idea http://jsfiddle.net/3nigma/hAcuF/1/

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

Sidebar

Related Questions

I have a dynamic navigation and need to open one link in a new
I have application that brings response via Ajax and creates 5-20 new jQuery click
I am new to jQuery. Any help would be appreciated I have two radio
Ok, I am new to JQuery, I have a modal that has a asp:Literal
I'm new to JQuery, I have a dynamic side menu (links have the class
I am currently building a dynamic form that allows the user to add as
I am new to JQuery and need som direction. I have created a page
i have a dynamic table that creates a div (new panel) for every TD
I am somewhat new to jQuery and I have a problem with something I
I'm new to jQuery and I want to have a input box from 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.