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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T22:01:02+00:00 2026-06-11T22:01:02+00:00

I have code below which changes price is the ‘price’ div to what the

  • 0

I have code below which changes price is the ‘price’ div to what the user selects.

<script type="text/javascript">
        function showprice(e){
            document.getElementById("price").innerHTML = e.getAttribute('data-price');
        }
    </script>

        <img src="http://i.imgur.com/JnUKx.jpg" id="img1" onclick="showprice(this);" width="39" height="33" data-price="245.00">
        <img src="http://i.imgur.com/c8Rwp.gif" id="img2" onclick="showprice(this);" width="39" height="33" data-price="255.00">

        <div id="price" style="padding-bottom:10px"></div>​

I have created 2 separate paypal buttons for each price. Both buttons are exactly the same but each have a different ‘value’. how can i change the ‘value’ depending on which image the user selects?

value for img1 button @ £245 is SKF4F8AARZWKE (code below)
value for img1 button @ £265 is WEI8F8HHJOPRY

paypal code for button img1 value SKF4F8AARZWKE

<form action="https://www.paypal.com/cgi-bin/webscr" method="post">

                  <input type="hidden" name="cmd" value="_s-xclick">
<input type="hidden" name="hosted_button_id" value="SKF4F8AARZWKE">

  <input type="image" src="images/buyitnow.png"  style="width:100px; height:30px" border="0" name="submit" alt="PayPal — The safer, easier way to pay online.">

            </form>​
  • 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-11T22:01:03+00:00Added an answer on June 11, 2026 at 10:01 pm

    Give the input element an id and use document.getElementById(‘YOUR_ID’).value = ‘YOUR VALUE’;

    <script type="text/javascript">
       function changeprice(e){
            document.getElementById("price").innerHTML = e.getAttribute('data-price');
            document.getElementById("hosted_button_id").value = e.getAttribute('data-value');
       }
    </script>
    
    <img src="http://i.imgur.com/JnUKx.jpg" id="img1" onclick="changeprice(this);" width="39" height="33" data-price="245.00" data-value="SKF4F8AARZWKE">
    <img src="http://i.imgur.com/c8Rwp.gif" id="img2" onclick="changeprice(this);" width="39" height="33" data-price="255.00" data-value="WEI8F8HHJOPRY">
    
    <div id="price" style="padding-bottom:10px"></div>​
    
    
    <form action="https://www.paypal.com/cgi-bin/webscr" method="post">
        <input type="hidden" name="cmd" value="_s-xclick">
        <input type="hidden" id="hosted_button_id" name="hosted_button_id" value="SKF4F8AARZWKE">
    
        <input type="image" src="images/buyitnow.png"  style="width:100px; height:30px" border="0" name="submit" alt="PayPal — The safer, easier way to pay online.">
    </form>​
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have some code like below which changes the font of text under a
I have a working JavaScript code below which dynamically creates JSON object using JSON.parse
Hope someone can help. I have the code below which when the user hovers
I have the code below which I use clone() and live() . The code
I have the code below which I use clone() and delegate() . The code
I have the following code below which works, but I want to insert values
I have wrote the code below which was taken from Java How to program
I have below code which overrides equals() and hashcode() methods. public boolean equals(Object obj)
I have a function(please see code below) which reads some data from the web.
I have a piece of matlab code below which reads data from a table.

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.