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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T18:11:36+00:00 2026-06-06T18:11:36+00:00

i would like to know how to create a hidden type input box and

  • 0

i would like to know how to create a hidden type input box and labels using javascript by onclick function.

$().ready(function() {  
    $("#product").autocomplete("get_completeproducts", {            
        width: 406,
        matchContains: true,
        selectFirst: false
    });
});


<input type="text" value="" name="product" id="product" size="50">
<input type="button" value="Add to List" onclick="addprotolist()" name="select_pro">

i am getting the above input box value through ajax auto complete , the user will click on the select box , then what i have to do is , i have to add list them the number of selected phones bellow the input box like

<label>Samsung Galaxy Y<label><input type="hidden" value="778" name="pro_id[]">
<label>Samsung Galaxy Y Duos<label><input type="hidden" value="788" name="pro_id[]">
<label>Samsung Galaxy Y Plus<label><input type="hidden" value="728" name="pro_id[]">
.
.
.
<input type="submit" name="save" value="Save your list">

anybody can provide me how to code this using javascript or jquery.

  • 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-06-06T18:11:37+00:00Added an answer on June 6, 2026 at 6:11 pm
    function addprotolist() {
      var str = '<label>'+ var_for_text +'</label><input type="hidden" value="'+ var_for_value +'" name="pro_id[]">';
      $('#yourform').append( str );
    }
    

    Note

    If you want to append multiple input, label etc using loop, don’t call append within loop, it will slow down performance. Make a string like above and call .append() at last out of loop.

    For example

    var str = '';
    function addprotolist(inputObj) {
    
      // a typical example of inputObj may be
      // inputObj = [ {labelText: 'some 1', value: 'val1' }, {labelText: 'some 2', value: 'val2'} ]
    
      // loop
      for(var i = 0; i < inputObj.length; i++ ) {
        str += '<label>'+ inputObj[i].labelText +'</label><input type="hidden" value="'+ inputObj[i].value +'" name="pro_id[]">';
      }
    
      // call append outside of loop
      $('#yourform').append( str );
    }
    

    But this way it does not really make sense to use a label. You have to connect it to your input either by wrapping it or by specifying a for attribute pointing to the input’s id:

    <!-- Simple label example with for attribute -->  
    <input type="radio" name="clickmebutton" id="clickmebutton">
    <label for="clickmebutton">Click me</label>  
    
    <!-- or more simply -->  
    <label><input type="radio" name="clickmebutton"> Click me</label>  
    

    from label on MDN

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

Sidebar

Related Questions

I would like to know how to create a php function that can be
I would like to know a way to create an XML file using MySQL
I would like to know how to create a rounded corners on a table
I would like to know if there is a way to take create a
I would like to know if there is a way to create web pages
I would like to create a multi-dimensional array with two variables but don't know
Would like to know the c# code to actually retrieve the IP type: Static
I would like to create a gallery slideshow using Jquery Tools Scrollable plugin. But
I would like to be able to add a hidden form field using array
I have a org.eclipse.swt.browser.Browser instance created in a composite. I would like to know

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.