locked
Inventory Tracking Newform.aspx RRS feed

  • Question

  • I've setup the Inventory Tracking template for my client and have the following question:

    In the "Create an Order" form is an Item dropdown that lists all the Inventory items currently available, is there a way to position the dropdown to a specific item by passing the ID of the Inventory item?

    i.e. https://servername/InventoryTracking/NewForm.aspx?ID=4 (btw, this does not work) or something similar?

    I'm open to any suggestions

    Thanks

    Tuesday, March 17, 2009 12:29 AM

Answers

  • Sorry, that was my bad. I tried adding the parameter in SPD at first, but then ran into the problem where SPD strips out any Javascript in the XSL when you save the web part, so I had to make all changes in the browser instead. You added the InventoryID parameter when you modified the web part and added the ParameterBinding node to the Parameters Editor.

    After going over the code again, I think I need to revise my answer. I had done half the solution in SPD to test it out, then changed my approach to using the browser and think I got some wires crossed in the process. Let's try this again.

    1.) I misspelled the parameter when I typed it in. You still need to add the parameter to the Parameters Editor box, but note the correct spelling. (Before, I spelled it with two e's.) Also, I added the name of the QuerySting parameter to the Location string.
    <ParameterBinding Name="InventoryID" Location="QueryString(InventoryID)" DefaultValue="1"/>

    2.) Add the following XSL parameter to the top of the XSL (such as under "<xsl:param name="dvt_apos">'</xsl:param>").
    <xsl:param name="InventoryID" />

    3.) This time, we won't call the hadleItemChangeCore function. Instead, we'll manually set the Item drop down menu value using javascript, then when the _spBodyOnLoadFunctionNames method is called, it will set the price and quantity values accordingly. Add this code before the _spBodyOnLoadFunctionNames line of code:
    var inventoryPicker = getTagFromIdentifierAndTitle("select", "Lookup", "Item");   
    if (inventoryPicker != null) {
    inventoryPicker.value = <xsl:value-of select="$InventoryID"/>
    }


    The whole XSL looks like this now:
     
    <P>&lt;xsl:stylesheet xmlns:x="<A   
    href="http://www.w3.org/2001/XMLSchema">http://www.w3.org/2001/XMLSchema</A>"   
    xmlns:d="<A   
    href="http://schemas.microsoft.com/sharepoint/dsp">http://schemas.microsoft.com/sharepoint/dsp</A>"   
    version="1.0" exclude-result-prefixes="xsl msxsl ddwrt" xmlns:ddwrt="<A   
    href="http://schemas.microsoft.com/WebParts/v2/DataView/runtime">http://schemas.microsoft.com/WebParts/v2/DataView/runtime</A>"   
    xmlns:asp="<A   
    href="http://schemas.microsoft.com/ASPNET/20">http://schemas.microsoft.com/ASPNET/20</A>"   
    xmlns:__designer="<A   
    href="http://schemas.microsoft.com/WebParts/v2/DataView/designer">http://schemas.microsoft.com/WebParts/v2/DataView/designer</A>"   
    xmlns:xsl="<A   
    href="http://www.w3.org/1999/XSL/Transform">http://www.w3.org/1999/XSL/Transform</A>"   
    xmlns:msxsl="urn:schemas-microsoft-com:xslt"   
    xmlns:SharePoint="Microsoft.SharePoint.WebControls"   
    xmlns:ddwrt2="urn:frontpage:internal"&gt;<BR>&nbsp;&lt;xsl:output method="html"   
    indent="no"/&gt;<BR>&nbsp;&lt;xsl:decimal-format   
    NaN=""/&gt;<BR>&nbsp;&lt;xsl:param   
    name="dvt_apos"&gt;'&lt;/xsl:param&gt;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;   
    &lt;xsl:param name="InventoryID" /&gt;<BR>&nbsp;&lt;xsl:variable   
    name="dvt_1_automode"&gt;0&lt;/xsl:variable&gt;<BR>&nbsp;&lt;xsl:template   
    match="/"&gt;<BR>&nbsp;&nbsp;&lt;xsl:call-template   
    name="dvt_1"/&gt;<BR>&nbsp;&lt;/xsl:template&gt;<BR>&nbsp;&lt;xsl:template   
    name="dvt_1"&gt;<BR>&nbsp;&nbsp;&lt;xsl:variable   
    name="dvt_StyleName"&gt;Table&lt;/xsl:variable&gt;<BR>&nbsp;&nbsp;&lt;xsl:variable   
    name="Rows" select="/dsQueryResponse/Rows/Row"/&gt;<BR>&nbsp;&nbsp;&lt;script   
    type="text/javascript"&gt;<BR>&nbsp;&nbsp;var inventoryID;<BR>&nbsp;&nbsp;var   
    quantity;<BR>&nbsp;&nbsp;var inventoryArray = new Array();<BR>&nbsp;&nbsp;var   
    quantityTextSpan;<BR>&nbsp;&nbsp;var itemTextSpan;<BR>&nbsp;&nbsp;var   
    priceTextSpan;<BR>&nbsp;&nbsp;var   
    priceBox;<BR>&nbsp;&nbsp;&nbsp;&lt;xsl:call-template   
    name="dvt_1.body"&gt;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&lt;xsl:with-param name="Rows"   
    select="$Rows"/&gt;<BR>&nbsp;&nbsp;&nbsp;&lt;/xsl:call-template&gt;<BR>&nbsp;&nbsp;function   
    getTagFromIdentifierAndTitle(tagName, identifier, title)   
    {<BR>&nbsp;&nbsp;&nbsp;var len = identifier.length;<BR>&nbsp;&nbsp;&nbsp;var   
    tags = document.getElementsByTagName(tagName);<BR>&nbsp;&nbsp;&nbsp;for (var   
    i=0; i &amp;lt; tags.length; i++) {<BR>&nbsp;&nbsp;&nbsp;&nbsp;var tempString =   
    tags[i].id;<BR>&nbsp;&nbsp;&nbsp;&nbsp;if (tags[i].title == title   
    &amp;amp;&amp;amp; (identifier == '' || tempString.indexOf(identifier) ==   
    tempString.length - len)) {<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return   
    tags[i];<BR>&nbsp;&nbsp;&nbsp;&nbsp;}<BR>&nbsp;&nbsp;&nbsp;}<BR>&nbsp;&nbsp;&nbsp;return   
    null;<BR>&nbsp;&nbsp;}&nbsp;<BR>&nbsp;&nbsp;function handleQuantityKey()   
    {<BR>&nbsp;&nbsp;&nbsp;quantity =   
    Number(this.value);<BR>&nbsp;&nbsp;&nbsp;setPriceAndQuantityLeft();<BR>&nbsp;&nbsp;}<BR>&nbsp;&nbsp;function   
    handleItemChangeCore(val) {<BR>&nbsp;&nbsp;&nbsp;inventoryID =   
    val;<BR>&nbsp;&nbsp;&nbsp;setPriceAndQuantityLeft();<BR>&nbsp;&nbsp;}<BR>&nbsp;&nbsp;function   
    handleItemChange()   
    {<BR>&nbsp;&nbsp;&nbsp;handleItemChangeCore(this.value);<BR>&nbsp;&nbsp;}<BR>&nbsp;&nbsp;function   
    setPriceAndQuantityLeft() {<BR>&nbsp;&nbsp;&nbsp;quantityTextSpan.innerHTML =   
    "Quantity in Inventory: " +   
    inventoryArray[inventoryID][1];<BR>&nbsp;&nbsp;&nbsp;itemTextSpan.innerHTML =   
    "Purchase Price: " +   
    inventoryArray[inventoryID][0];<BR>&nbsp;&nbsp;&nbsp;priceTextSpan.innerHTML =   
    ""</P> 
    <P>&nbsp;&nbsp;&nbsp;if (quantity == NaN || quantity == null)   
    return;<BR>&nbsp;&nbsp;&nbsp;priceBox.value = String(quantity *   
    Number(inventoryArray[inventoryID][0].replace(".", "."))).replace(".",   
    ".");<BR>&nbsp;&nbsp;&nbsp;priceTextSpan.innerHTML = "Transaction Value: " +   
    priceBox.value;<BR>&nbsp;&nbsp;}<BR>&nbsp;&nbsp;function setHandlers()   
    {<BR>&nbsp;&nbsp;&nbsp;priceBox = getTagFromIdentifierAndTitle("input",   
    "TextField", "Transaction   
    Value");<BR>&nbsp;&nbsp;&nbsp;priceBox.parentElement.parentElement.parentElement.style.display   
    =   
    "none";<BR>&nbsp;&nbsp;&nbsp;getTagFromIdentifierAndTitle("input","TextField","Quantity").parentElement.parentElement.innerHTML   
    += "&amp;lt;span   
    id=\"quantityTextSpan\"&amp;gt;&amp;lt;/span&amp;gt;";<BR>&nbsp;&nbsp;&nbsp;var   
    itemLookup = getTagFromIdentifierAndTitle("select", "Lookup",   
    "Item");<BR>&nbsp;&nbsp;&nbsp;if (itemLookup == null)   
    {<BR>&nbsp;&nbsp;&nbsp;&nbsp;itemLookup = getTagFromIdentifierAndTitle("input",   
    "",   
    "Item")<BR>&nbsp;&nbsp;&nbsp;}<BR>&nbsp;&nbsp;&nbsp;itemLookup.parentElement.parentElement.innerHTML   
    += "&amp;lt;span   
    id=\"itemTextSpan\"&amp;gt;&amp;lt;/span&amp;gt;";<BR>&nbsp;&nbsp;&nbsp;var   
    priceText = getTagFromIdentifierAndTitle("input", "TextField", "Sale   
    Price");<BR>&nbsp;&nbsp;&nbsp;if (priceText == null) priceText =   
    getTagFromIdentifierAndTitle("input", "TextField", "Order   
    Price");<BR>&nbsp;&nbsp;&nbsp;priceText.parentElement.parentElement.innerHTML +=   
    "&amp;lt;span   
    id=\"priceTextSpan\"&amp;gt;&amp;lt;/span&amp;gt;";<BR>&nbsp;&nbsp;&nbsp;var   
    quantityBox =   
    getTagFromIdentifierAndTitle("input","TextField","Quantity");<BR>&nbsp;&nbsp;&nbsp;var   
    inventoryPicker = getTagFromIdentifierAndTitle("select", "Lookup",   
    "Item");<BR>&nbsp;&nbsp;&nbsp;quantityTextSpan =   
    document.getElementById("quantityTextSpan");<BR>&nbsp;&nbsp;&nbsp;itemTextSpan =   
    document.getElementById("itemTextSpan");<BR>&nbsp;&nbsp;&nbsp;priceTextSpan =   
    document.getElementById("priceTextSpan");&nbsp;&nbsp;&nbsp;<BR>&nbsp;&nbsp;&nbsp;quantityBox.onkeyup   
    handleQuantityKey;<BR>&nbsp;&nbsp;&nbsp;if (inventoryPicker != null)   
    {<BR>&nbsp;&nbsp;&nbsp;&nbsp;inventoryPicker.onchange =   
    handleItemChange;<BR>&nbsp;&nbsp;&nbsp;&nbsp;inventoryPicker.onchange();<BR>&nbsp;&nbsp;&nbsp;}<BR>&nbsp;&nbsp;}<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;   
    var inventoryPicker = getTagFromIdentifierAndTitle("select", "Lookup",   
    "Item");&nbsp;&nbsp;&nbsp; <BR>if (inventoryPicker != null)   
    {<BR>inventoryPicker.value = &lt;xsl:value-of   
    select="$InventoryID"/&gt;<BR>}<BR>&nbsp;&nbsp;_spBodyOnLoadFunctionNames.push("setHandlers");<BR>&nbsp;&nbsp;&lt;/script&gt;   
    &lt;script type="text/javascript" src="Transactions.js" originalAttribute="src"   
    originalPath="Transactions.js"   
    defer=""&gt;&lt;/script&gt;&lt;/xsl:template&gt;<BR>&nbsp;&lt;xsl:template   
    name="dvt_1.body"&gt;<BR>&nbsp;&nbsp;&lt;xsl:param   
    name="Rows"/&gt;<BR>&nbsp;&nbsp;&lt;xsl:for-each   
    select="$Rows"&gt;<BR>&nbsp;&nbsp;&nbsp;&lt;xsl:call-template   
    name="dvt_1.rowview"/&gt;<BR>&nbsp;&nbsp;&lt;/xsl:for-each&gt;<BR>&nbsp;&lt;/xsl:template&gt;<BR>&nbsp;&lt;xsl:template   
    name="dvt_1.rowview"&gt;<BR>&nbsp;&nbsp;inventoryArray[&lt;xsl:value-of   
    select="@ID"/&gt;] = new Array(&amp;quot;&lt;xsl:value-of   
    select="@AssetPurchasePrice"/&gt;&amp;quot;,&amp;quot;&lt;xsl:value-of   
    select="@ITQuantity"/&gt;&amp;quot;);<BR>&nbsp;&lt;/xsl:template&gt;<BR>&lt;/xsl:stylesheet&gt;&nbsp;</P> 

    Sorry about the confusin. Let me know if this works.
    (I've also added a post about this to my blog, at this location: http://blog.beckybertram.com/Lists/Posts/Post.aspx?ID=34)
    Visit my blog at blog.beckybertram.com or follow me on Twitter: @beckybertram
    • Marked as answer by SteveHs Friday, March 27, 2009 12:38 AM
    Wednesday, March 25, 2009 12:24 AM

All replies

  • Create your own custom dropdown field and then you will be able to position the dropdown to a specific item.

    or you can use client side javascript to your form and change the position of dropdown listitem.


    Suhaib
    • Proposed as answer by Suhaib.Khan Tuesday, March 17, 2009 4:45 PM
    Tuesday, March 17, 2009 4:45 PM
  • Steve,
    It's possible to do, although you'll need a little javascript magic.

    Click on your Create Order page in the browser.  Go to your Site Actions menu and select "Edit Page".

    You'll see a somewhat hidden web part at the bottom of the page, below the form web part displaying the fields to be entered. Edit that web part. Click on the "Parameters Editor" button in the web part tool bar on the side of the page. Add this parameter to the XML:

    <ParameterBinding Name="InveentoryID" Location="QueryString" DefaultValue="1"/>

    Now click on the "XSL Editor" button.

    If you'll notice, the majority of the XSL in this web part is really javascript. What you'll basically have to do is edit the javascript in this XSL file to find the Inventory drop down menu element in the HTML, and reset the value to the @InventoryID property. Luckily, they already have a javascript function that resets the quantity and price values when the inventory item changes. We'll just call that right off the bat, passing in our new variable.

    Look for this line in the javascript:
    _spBodyOnLoadFunctionNames.push("setHandlers");

    Right after that, add this:
    handleItemChangeCore(<xsl:value-of select="@InventoryID"/>);

    With @InventoryID being the parameter name you added in SharePoint Designer.

    Save your changes and test it, by adding "&InventoryID=1" to your Query String. Voila, the inventory box should be set for you right off the bat.

    (Unfortunately, if you try to execute these same pages with SharePoint Designer, SPD won't let you save web parts with javascript in their XSL; it will strip the javascript out, and your form will no longer work properly. Make sure you make these changes in the browser!)

    blog.beckybertram.com
    Tuesday, March 17, 2009 5:38 PM
  • Thanks Becky! however, I am trying to understand the various steps being that I'm fairly new to SP

    >If you'll notice, the majority of the XSL in this web part is really javascript. What you'll basically have to do is edit the javascript in this >XSL file to find the Inventory drop down menu element in the HTML, and reset the value to the @InventoryID property. Luckily, they >already have a javascript function that resets the quantity and price values when the inventory item changes. We'll just call that >right off the bat, passing in our new variable.

    Did you mean the line we entered as (handleItemChangeCore(<xsl:value-of select="@InventoryID"/>); ? If not, where do we reset the value to the @InventoryID property?

    >With @InventoryID being the parameter name you added in SharePoint Designer.
    Where do we enter the parameter @InventoryID in SPD?

    >Save your changes and test it, by adding "&InventoryID=1" to your Query String. Voila, the inventory box should be set for you right off the bat.

    Did you mean when we run the 'Create Order' url such as http://server/lists/NewForm.aspx?ContentTypeId=0x010009338184931546ee9B887021C71AADBA01&InventoryID=3  ?

    Sorry to ask so many questions but thanks for all your help towards a newbie
    Steve
    Sunday, March 22, 2009 2:49 AM
  • Becky, after entering the following (correct me if I'm wrong) it doesn't work and I'm sure I'm missing something:

    1. Added <ParameterBinding Name="InventoryID" Location="QueryString" DefaultValue="1"/> via Parameters Editor at the bottom of the list - saved it.

    2. Then entered - handleItemChangeCore(<xsl:value-of select="@InventoryID"/>); under _spBodyOnLoadFunctionNames.push("setHandlers"); using the XSL option - saved it.

    3. On IE url line I entered
    http://servername/Inventory/Transactions/NewForm.aspx?ContentTypeId=blahblahblah&InventoryID=2

    Are there any document library changes etc. to be made? Please help :)

    Thanks
    Steve




    Sunday, March 22, 2009 7:48 PM
  • Steve, to answer your questions:
    - What you've done by adding the extra "InventoryID" node to the Parameters XML is tell the Data web part that it should expect a parameter from the query string.
    - In the XSL, the javascript function of handleItemChangeCore() gets called whenever a user changes the inventory drop-down box in the form. (The javascript is necessary, because changing the item also updates the price and quantity fields on the pag. Basically, we're just manually calling that javascript method right off the bat, when the page loads, rather than having it called when the user interacts with the page. @InventoryID refers to the query string value, and that's what you're passing into the javascript function.

    If you added the querystring parameter, and added the line to the javascript, it should all work when you pass in an inventory id in the query string. I tested it in my browser and it worked. Unfortunately, I'm not sure how to help you next. All I know to say is 1.) make sure the javascript stayed intact when you saved the web part, and 2.) make sure your "InventoryID" is capitalized the same everywhere, spelled the same everywhere, etc.


    Visit my blog at blog.beckybertram.com or follow me on Twitter: @beckybertram
    Sunday, March 22, 2009 11:13 PM
  • Thanks Becky, I checked it over and over and it looks the same everywhere - if you don't mind me asking - how does your query string look like when you pass it?

    mine looks like this: http://servername/Inventory/Transactions/NewForm.aspx?ContentTypeID=0x010009338184931546ee9B887021C71AADBA01&InventoryID=2   (this is for Create an Order)

    Do you see any problems with that?

    Thanks
    Steve

    Monday, March 23, 2009 1:25 AM
  • Becky,

    Maybe I'm missing one step :

    >With @InventoryID being the parameter name you added in SharePoint Designer.
    Could you expand on the above pls?

    Thanks
    Steve
    Monday, March 23, 2009 3:32 PM
  • Sorry, that was my bad. I tried adding the parameter in SPD at first, but then ran into the problem where SPD strips out any Javascript in the XSL when you save the web part, so I had to make all changes in the browser instead. You added the InventoryID parameter when you modified the web part and added the ParameterBinding node to the Parameters Editor.

    After going over the code again, I think I need to revise my answer. I had done half the solution in SPD to test it out, then changed my approach to using the browser and think I got some wires crossed in the process. Let's try this again.

    1.) I misspelled the parameter when I typed it in. You still need to add the parameter to the Parameters Editor box, but note the correct spelling. (Before, I spelled it with two e's.) Also, I added the name of the QuerySting parameter to the Location string.
    <ParameterBinding Name="InventoryID" Location="QueryString(InventoryID)" DefaultValue="1"/>

    2.) Add the following XSL parameter to the top of the XSL (such as under "<xsl:param name="dvt_apos">'</xsl:param>").
    <xsl:param name="InventoryID" />

    3.) This time, we won't call the hadleItemChangeCore function. Instead, we'll manually set the Item drop down menu value using javascript, then when the _spBodyOnLoadFunctionNames method is called, it will set the price and quantity values accordingly. Add this code before the _spBodyOnLoadFunctionNames line of code:
    var inventoryPicker = getTagFromIdentifierAndTitle("select", "Lookup", "Item");   
    if (inventoryPicker != null) {
    inventoryPicker.value = <xsl:value-of select="$InventoryID"/>
    }


    The whole XSL looks like this now:
     
    <P>&lt;xsl:stylesheet xmlns:x="<A   
    href="http://www.w3.org/2001/XMLSchema">http://www.w3.org/2001/XMLSchema</A>"   
    xmlns:d="<A   
    href="http://schemas.microsoft.com/sharepoint/dsp">http://schemas.microsoft.com/sharepoint/dsp</A>"   
    version="1.0" exclude-result-prefixes="xsl msxsl ddwrt" xmlns:ddwrt="<A   
    href="http://schemas.microsoft.com/WebParts/v2/DataView/runtime">http://schemas.microsoft.com/WebParts/v2/DataView/runtime</A>"   
    xmlns:asp="<A   
    href="http://schemas.microsoft.com/ASPNET/20">http://schemas.microsoft.com/ASPNET/20</A>"   
    xmlns:__designer="<A   
    href="http://schemas.microsoft.com/WebParts/v2/DataView/designer">http://schemas.microsoft.com/WebParts/v2/DataView/designer</A>"   
    xmlns:xsl="<A   
    href="http://www.w3.org/1999/XSL/Transform">http://www.w3.org/1999/XSL/Transform</A>"   
    xmlns:msxsl="urn:schemas-microsoft-com:xslt"   
    xmlns:SharePoint="Microsoft.SharePoint.WebControls"   
    xmlns:ddwrt2="urn:frontpage:internal"&gt;<BR>&nbsp;&lt;xsl:output method="html"   
    indent="no"/&gt;<BR>&nbsp;&lt;xsl:decimal-format   
    NaN=""/&gt;<BR>&nbsp;&lt;xsl:param   
    name="dvt_apos"&gt;'&lt;/xsl:param&gt;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;   
    &lt;xsl:param name="InventoryID" /&gt;<BR>&nbsp;&lt;xsl:variable   
    name="dvt_1_automode"&gt;0&lt;/xsl:variable&gt;<BR>&nbsp;&lt;xsl:template   
    match="/"&gt;<BR>&nbsp;&nbsp;&lt;xsl:call-template   
    name="dvt_1"/&gt;<BR>&nbsp;&lt;/xsl:template&gt;<BR>&nbsp;&lt;xsl:template   
    name="dvt_1"&gt;<BR>&nbsp;&nbsp;&lt;xsl:variable   
    name="dvt_StyleName"&gt;Table&lt;/xsl:variable&gt;<BR>&nbsp;&nbsp;&lt;xsl:variable   
    name="Rows" select="/dsQueryResponse/Rows/Row"/&gt;<BR>&nbsp;&nbsp;&lt;script   
    type="text/javascript"&gt;<BR>&nbsp;&nbsp;var inventoryID;<BR>&nbsp;&nbsp;var   
    quantity;<BR>&nbsp;&nbsp;var inventoryArray = new Array();<BR>&nbsp;&nbsp;var   
    quantityTextSpan;<BR>&nbsp;&nbsp;var itemTextSpan;<BR>&nbsp;&nbsp;var   
    priceTextSpan;<BR>&nbsp;&nbsp;var   
    priceBox;<BR>&nbsp;&nbsp;&nbsp;&lt;xsl:call-template   
    name="dvt_1.body"&gt;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&lt;xsl:with-param name="Rows"   
    select="$Rows"/&gt;<BR>&nbsp;&nbsp;&nbsp;&lt;/xsl:call-template&gt;<BR>&nbsp;&nbsp;function   
    getTagFromIdentifierAndTitle(tagName, identifier, title)   
    {<BR>&nbsp;&nbsp;&nbsp;var len = identifier.length;<BR>&nbsp;&nbsp;&nbsp;var   
    tags = document.getElementsByTagName(tagName);<BR>&nbsp;&nbsp;&nbsp;for (var   
    i=0; i &amp;lt; tags.length; i++) {<BR>&nbsp;&nbsp;&nbsp;&nbsp;var tempString =   
    tags[i].id;<BR>&nbsp;&nbsp;&nbsp;&nbsp;if (tags[i].title == title   
    &amp;amp;&amp;amp; (identifier == '' || tempString.indexOf(identifier) ==   
    tempString.length - len)) {<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return   
    tags[i];<BR>&nbsp;&nbsp;&nbsp;&nbsp;}<BR>&nbsp;&nbsp;&nbsp;}<BR>&nbsp;&nbsp;&nbsp;return   
    null;<BR>&nbsp;&nbsp;}&nbsp;<BR>&nbsp;&nbsp;function handleQuantityKey()   
    {<BR>&nbsp;&nbsp;&nbsp;quantity =   
    Number(this.value);<BR>&nbsp;&nbsp;&nbsp;setPriceAndQuantityLeft();<BR>&nbsp;&nbsp;}<BR>&nbsp;&nbsp;function   
    handleItemChangeCore(val) {<BR>&nbsp;&nbsp;&nbsp;inventoryID =   
    val;<BR>&nbsp;&nbsp;&nbsp;setPriceAndQuantityLeft();<BR>&nbsp;&nbsp;}<BR>&nbsp;&nbsp;function   
    handleItemChange()   
    {<BR>&nbsp;&nbsp;&nbsp;handleItemChangeCore(this.value);<BR>&nbsp;&nbsp;}<BR>&nbsp;&nbsp;function   
    setPriceAndQuantityLeft() {<BR>&nbsp;&nbsp;&nbsp;quantityTextSpan.innerHTML =   
    "Quantity in Inventory: " +   
    inventoryArray[inventoryID][1];<BR>&nbsp;&nbsp;&nbsp;itemTextSpan.innerHTML =   
    "Purchase Price: " +   
    inventoryArray[inventoryID][0];<BR>&nbsp;&nbsp;&nbsp;priceTextSpan.innerHTML =   
    ""</P> 
    <P>&nbsp;&nbsp;&nbsp;if (quantity == NaN || quantity == null)   
    return;<BR>&nbsp;&nbsp;&nbsp;priceBox.value = String(quantity *   
    Number(inventoryArray[inventoryID][0].replace(".", "."))).replace(".",   
    ".");<BR>&nbsp;&nbsp;&nbsp;priceTextSpan.innerHTML = "Transaction Value: " +   
    priceBox.value;<BR>&nbsp;&nbsp;}<BR>&nbsp;&nbsp;function setHandlers()   
    {<BR>&nbsp;&nbsp;&nbsp;priceBox = getTagFromIdentifierAndTitle("input",   
    "TextField", "Transaction   
    Value");<BR>&nbsp;&nbsp;&nbsp;priceBox.parentElement.parentElement.parentElement.style.display   
    =   
    "none";<BR>&nbsp;&nbsp;&nbsp;getTagFromIdentifierAndTitle("input","TextField","Quantity").parentElement.parentElement.innerHTML   
    += "&amp;lt;span   
    id=\"quantityTextSpan\"&amp;gt;&amp;lt;/span&amp;gt;";<BR>&nbsp;&nbsp;&nbsp;var   
    itemLookup = getTagFromIdentifierAndTitle("select", "Lookup",   
    "Item");<BR>&nbsp;&nbsp;&nbsp;if (itemLookup == null)   
    {<BR>&nbsp;&nbsp;&nbsp;&nbsp;itemLookup = getTagFromIdentifierAndTitle("input",   
    "",   
    "Item")<BR>&nbsp;&nbsp;&nbsp;}<BR>&nbsp;&nbsp;&nbsp;itemLookup.parentElement.parentElement.innerHTML   
    += "&amp;lt;span   
    id=\"itemTextSpan\"&amp;gt;&amp;lt;/span&amp;gt;";<BR>&nbsp;&nbsp;&nbsp;var   
    priceText = getTagFromIdentifierAndTitle("input", "TextField", "Sale   
    Price");<BR>&nbsp;&nbsp;&nbsp;if (priceText == null) priceText =   
    getTagFromIdentifierAndTitle("input", "TextField", "Order   
    Price");<BR>&nbsp;&nbsp;&nbsp;priceText.parentElement.parentElement.innerHTML +=   
    "&amp;lt;span   
    id=\"priceTextSpan\"&amp;gt;&amp;lt;/span&amp;gt;";<BR>&nbsp;&nbsp;&nbsp;var   
    quantityBox =   
    getTagFromIdentifierAndTitle("input","TextField","Quantity");<BR>&nbsp;&nbsp;&nbsp;var   
    inventoryPicker = getTagFromIdentifierAndTitle("select", "Lookup",   
    "Item");<BR>&nbsp;&nbsp;&nbsp;quantityTextSpan =   
    document.getElementById("quantityTextSpan");<BR>&nbsp;&nbsp;&nbsp;itemTextSpan =   
    document.getElementById("itemTextSpan");<BR>&nbsp;&nbsp;&nbsp;priceTextSpan =   
    document.getElementById("priceTextSpan");&nbsp;&nbsp;&nbsp;<BR>&nbsp;&nbsp;&nbsp;quantityBox.onkeyup   
    handleQuantityKey;<BR>&nbsp;&nbsp;&nbsp;if (inventoryPicker != null)   
    {<BR>&nbsp;&nbsp;&nbsp;&nbsp;inventoryPicker.onchange =   
    handleItemChange;<BR>&nbsp;&nbsp;&nbsp;&nbsp;inventoryPicker.onchange();<BR>&nbsp;&nbsp;&nbsp;}<BR>&nbsp;&nbsp;}<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;   
    var inventoryPicker = getTagFromIdentifierAndTitle("select", "Lookup",   
    "Item");&nbsp;&nbsp;&nbsp; <BR>if (inventoryPicker != null)   
    {<BR>inventoryPicker.value = &lt;xsl:value-of   
    select="$InventoryID"/&gt;<BR>}<BR>&nbsp;&nbsp;_spBodyOnLoadFunctionNames.push("setHandlers");<BR>&nbsp;&nbsp;&lt;/script&gt;   
    &lt;script type="text/javascript" src="Transactions.js" originalAttribute="src"   
    originalPath="Transactions.js"   
    defer=""&gt;&lt;/script&gt;&lt;/xsl:template&gt;<BR>&nbsp;&lt;xsl:template   
    name="dvt_1.body"&gt;<BR>&nbsp;&nbsp;&lt;xsl:param   
    name="Rows"/&gt;<BR>&nbsp;&nbsp;&lt;xsl:for-each   
    select="$Rows"&gt;<BR>&nbsp;&nbsp;&nbsp;&lt;xsl:call-template   
    name="dvt_1.rowview"/&gt;<BR>&nbsp;&nbsp;&lt;/xsl:for-each&gt;<BR>&nbsp;&lt;/xsl:template&gt;<BR>&nbsp;&lt;xsl:template   
    name="dvt_1.rowview"&gt;<BR>&nbsp;&nbsp;inventoryArray[&lt;xsl:value-of   
    select="@ID"/&gt;] = new Array(&amp;quot;&lt;xsl:value-of   
    select="@AssetPurchasePrice"/&gt;&amp;quot;,&amp;quot;&lt;xsl:value-of   
    select="@ITQuantity"/&gt;&amp;quot;);<BR>&nbsp;&lt;/xsl:template&gt;<BR>&lt;/xsl:stylesheet&gt;&nbsp;</P> 

    Sorry about the confusin. Let me know if this works.
    (I've also added a post about this to my blog, at this location: http://blog.beckybertram.com/Lists/Posts/Post.aspx?ID=34)
    Visit my blog at blog.beckybertram.com or follow me on Twitter: @beckybertram
    • Marked as answer by SteveHs Friday, March 27, 2009 12:38 AM
    Wednesday, March 25, 2009 12:24 AM
  • Thank you so much Becky! This works perfectly.

    Much appreciated
    Steve
    Friday, March 27, 2009 12:38 AM