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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T06:41:40+00:00 2026-05-23T06:41:40+00:00

I have product name(in paragraph), text form and button. The products have id’s as

  • 0

I have product name(in paragraph), text form and button. The products have id’s as follows p1,p2… The input types have id’s as follows i1,i2…After typing something in the form and clicking submit I want this to change the default product text. I have the following function which works only for one set(paragraph,form and button). The problem is that this product function works only for p1,i1 I want it to fork for p1,i1,p2,i2 and etc.

 function product(id){
            var userInput = document.getElementById("i1").value;
            document.getElementById("p1").innerHTML = userInput;
        }

The function call is as follows:

<button type='button' onclick='product()'>Name product</button>
  • 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-23T06:41:41+00:00Added an answer on May 23, 2026 at 6:41 am

    what you need is to pass the index to the function:

    function product(id) {
        var userInput = document.getElementById("i"+id).value;
        document.getElementById("p"+id).innerHTML = userInput;
    }
    

    your html would look like:

    <button type='button' onclick='product(1)'>Name product</button>
    

    hope this helps.

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

Sidebar

Related Questions

I have the following: Product name and right after form and submit button. I
I have a table structure something like this table Collection Id Name table Product
I have a table with column for storing product code. | product_id | Product-name
I have the following JSON String { name:Product, properties: { id: { type:number, description:Product
I have 2 tables product and history product table: id name type price location
I have the following Grails domain class: class Product { String name Float basePrice
I have tables Product ( ID, CategoryID, ... ) Category ( ID, Name, ..
I have the following JSON string (from wikipedia http://en.wikipedia.org/wiki/JSON ) { name:Product, properties: {
I have a product table like this: Product name , Affiliate ID , ProductCode
I have this: SELECT Product.ProductID, Product.Name, Product.GroupID, Product.GradeID, AVG(tblReview.Grade) AS Grade FROM Product left

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.