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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T17:11:38+00:00 2026-05-27T17:11:38+00:00

I have a homework assignment that asks to create an order form. The order

  • 0

I have a homework assignment that asks to create an order form. The order form is supposed to include a list of items available for the user to purchase, which comes from an XML document and is styled with an XSL file.

I got through this part fine, and loaded the XSL into the HTML DOM using JavaScript. Now I’m stuck trying to figure out how I will process the data. I need to multiply the quantity (which is inputted by the user), and the price (which is inputted from the XML).

I am completely stuck and would greatly appreciate any hints on where to go from here.

My XSLT:

<table width="0" border="1" cellspacing="3" cellpadding="5">
  <tr>
    <td>Qty</td>
    <td>Item Description</td>
    <td>Price</td>
  </tr>
 <xsl:for-each select="//item">
  <tr>
    <td><input name="top" type="text" onchange="calculate()" value="0" size="4" /></td>
    <td>Item <xsl:value-of select="id"/></td>
    <td><xsl:value-of select="price"/></td>
  </tr>
  </xsl:for-each>
</table>

Some XML:

<productcatalog>

        <item>
            <id>001</id>
            <name>Item #1</name>
            <price>10</price>
        </item>
        <item>
            <id>002</id>            
            <name>Item #2</name>
            <price>20</price>
        </item>
        <item>
            <id>003</id>
            <name>Item #3</name>
            <price>30</price>
        </item>
        <item>
            <id>004</id>
            <name>Item #4</name>
            <price>40</price>
        </item>



</productcatalog>
  • 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-27T17:11:39+00:00Added an answer on May 27, 2026 at 5:11 pm

    Since the quantity is from the user you can’t implement this with XSL. Your XSL stylesheet should output a script which does the calculation.

    If you can use a javascript library (e.g. jQuery) this task is considerably simpler, but you can certainly do this without it.

    Your calculate function should:

    1. store the quantity and convert to a number. The input element with the quantity will have triggered the event.
    2. find the row that triggered the event by walking up the parent nodes.
    3. find the price on that row by walking back down. Convert to a number.
    4. multiply price by quantity and insert as a string into the proper TD. (you use textContent or innerText attribute)

    Storing the price may be an issue. The new way (inaugurated with HTML5) is to use an attribute with a data- prefix. You can add data-price to the html output as a handy place to get the price. You can even put this on the input node itself, so you don’t have to navigate nodes to find the price.

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

Sidebar

Related Questions

I have a homework assignment which asks to have the user input a date
I have a homework assignment that I am supposed to write a http server
Have a homework assignment in which I'm supposed to create a vector of pointers
I'm working on a homework assignment that asks me to create a calculator that
I'm very new to XML and XSLT. I have a homework assignment that asks
For my homework assignment, I have a network of Nodes that are passing messages
I have been given a homework assignment where I need to create a captcha
I need little help on a homework assignment. I have to create a 10
I am currently working on a homework assignment where I have to create a
A recent homework assignment I have received asks us to take expressions which could

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.