problem with retrieving value from asp-textbox

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • mathewgk80
    New Member
    • Sep 2007
    • 103

    problem with retrieving value from asp-textbox

    Hi all,

    I am having two textboxes

    First textbox is used to enter the price per unit of an item..

    Second TextBox is used to enter the number of items..

    I have a label which should display the total amount , ie, priceperunit*nu mberofitems..

    The total amount should be displayed whenever the user enter the numberof items...

    I have to write the javascript code to find the total..

    Please help me...

    Regards,
    Mathew
  • Markus
    Recognized Expert Expert
    • Jun 2007
    • 6092

    #2
    Originally posted by mathewgk80
    Hi all,

    I am having two textboxes

    First textbox is used to enter the price per unit of an item..

    Second TextBox is used to enter the number of items..

    I have a label which should display the total amount , ie, priceperunit*nu mberofitems..

    The total amount should be displayed whenever the user enter the numberof items...

    I have to write the javascript code to find the total..

    Please help me...

    Regards,
    Mathew
    Sounds like you want us to write it for you...

    Just read some tutorials

    =]

    Comment

    • gits
      Recognized Expert Moderator Expert
      • May 2007
      • 5388

      #3
      hi ...

      please show some code you have done so far ... so that we may have a look at your attempt and its particular problems if there are any ...

      kind regards

      Comment

      • mathewgk80
        New Member
        • Sep 2007
        • 103

        #4
        Hi,

        I have written the Javascript code as given below.

        JavaScript
        ...............
        [CODE=javascript]function calculatesum()
        {
        noofitems=docum ent.getElementB yId("ctl00_Cont entPlaceHolder1 _txtNoofItemsPu rchased").value ;
        priceperunit=do cument.getEleme ntById("ctl00_C ontentPlaceHold er1_lblPricePer Unit").value;
        var total=noofitems *priceperunit;
        return total;
        }[/CODE]


        and when i execute the program i met with some error saying that

        "The server tag is not well formed."

        I am having the textbox property as given below

        [CODE=asp]<asp:TextBox ID="txtNoofItem sPurchased" runat="server" Height="15px" Style="left: -14px; position: relative;
        top: -9px"; Width="42px"; OnTextChanged=" return calculatesum()" ></asp:TextBox>[/CODE]

        Please let me know where i went wrong...

        regards,

        Mathew
        Last edited by gits; Nov 6 '07, 10:16 PM. Reason: added code tags

        Comment

        • gits
          Recognized Expert Moderator Expert
          • May 2007
          • 5388

          #5
          changed thread title to better describe the problem ... please always use a good thread title ...

          Comment

          • acoder
            Recognized Expert MVP
            • Nov 2006
            • 16032

            #6
            Where's the code for the label?

            Can you post the client-side version of your ASP.NET code?

            Comment

            • mathewgk80
              New Member
              • Sep 2007
              • 103

              #7
              Originally posted by acoder
              Where's the code for the label?

              Can you post the client-side version of your ASP.NET code?
              The code of Label is given below...

              <asp:Label ID="lblPricePer Unit" runat="server" Height="20px" Style="left: 80px; position: relative;
              top: -41px" Width="91px"></asp:Label>

              Comment

              • acoder
                Recognized Expert MVP
                • Nov 2006
                • 16032

                #8
                If you view the source in the browser on the client-side, is the label ID still the same or has it changed to something else?

                Whatever the ID is, use that with document.getEle mentById(labelI D).innerHTML to set the label with the total.

                Comment

                Working...