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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T05:15:36+00:00 2026-06-13T05:15:36+00:00

I have this Javascript datastore which is part of a TiddlyWiki (fyi) for storing

  • 0

I have this Javascript datastore which is part of a TiddlyWiki (fyi) for storing product by SKU. However I’m not sure how to make a form to update it. I want the form to retrieve the amount of the product in ID that is available using GetAmount. The user is given the option to add to, subtract from, or update the value, and then it saves it using the Update function. The new amount should also be displayed in the amount field. This seems like it should be simple, but I don’t know enough about HTML forms to know how to do it.

Here is a fiddle with what I have so far. http://jsfiddle.net/Arlen22/pCDx3/

  • 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-13T05:15:37+00:00Added an answer on June 13, 2026 at 5:15 am

    Forget about using html forms to submit your data. Your datasource is connected directy to your javascript so you can skip the postback and codebehind stuff. I would use jQuery for simplicity but you could do it with native javascript as well. jQuery is well documented if you decide to learn and use it, and worth the time to learn if you ask me.

    This example should help to get you started, feel free to edit and comment on it as needed:

    Html

    <fieldset class="stock-control">
    
        <legend>Edit Stock Amount</legend>
    
        <label>ID:</label>
        <input type="text" id="txt-id">
    
        <label>Amount:</label>
        <input type="text" id="txt-change"><br />
    
        <input type="button" id="btn-add" value="Add">
        <input type="button" id="btn-sub" value="Subtract">
        <input type="button" id="btn-set" value="Set">
    
        <br />
        <label>In stock: </label><span id="lbl-total"></span>
    
    </fieldset>
    
    <fieldset class="stock-control">
    
        <legend>Edit Stock Amount</legend>
    
        <label>ID:</label>
        <input type="text" class="txt-id">
    
        <label>Amount:</label>
        <input type="text" class="txt-change"><br />
    
        <input type="button" class="btn-add" value="Add">
        <input type="button" class="btn-sub" value="Subtract">
        <input type="button" class="btn-set" value="Set">
    
        <br />
        <label>In stock: </label><span class="lbl-total"></span>
    
    </fieldset>
    

    Javascript

    // Your code
    
    $(function () {
    
        $('.stock-control').each(function () {
    
            var $control = $(this);
            var $id = $control.find('.txt-id');
            var $amount = $control.find('.txt-amount');
            var $total = $control.find('.lbl-total');
    
            function RenderAmount() {
                $total.text(StockRecorder.GetAmount($id.val()));
            };
    
            $('.btn-add').click(function () {
                var stock = parseInt($total.text()) + parseInt($amount.val());
                StockRecorder.Update($id.val(), stock);
                RenderAmount();
            });
    
            $('.btn-sub').click(function () {
                var stock = parseInt($total.text()) - parseInt($amount.val());
                StockRecorder.Update($id.val(), stock);
                RenderAmount();
            });
    
            $('.btn-set').click(function () {
                StockRecorder.Update($id.val(), parseInt($amount.val()));
                RenderAmount();
            });
    
            // Initialize
            RenderAmount();
    
        });
    
    });
    

    NOTE: You would want a button or an event that calls the RenderAmount() functions when an id has been entered/changed in the id textbox. In my example i pretended it was already filled in.

    By the way, seems like a fun project you have gotten your hands on. Enjoy it! 🙂
    ​

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

Sidebar

Related Questions

i have this javascript code to which i want to add the jquery fade-in
I have this javascript modal which I want to use for error reporting. Everything
I have this code which depends on this javascript from dynamic drive: http://dynamicdrive.com/dynamicindex16/formdependency.htm Its
I have this JavaScript function which counts down until you can click the download
I have this JavaScript code: var test123 = $('product-price-' + productId).innerHTML; // thats 26,00&nbsp;€
I have this javascript here is make to work like a search suggestion for
I have this JavaScript function which is working in all the machines I tried
I have this <ul> <ul id=select_opts class=bullet-list style=margin-left:15px;></ul> This javascript code which is meant
I have this Javascript/JQuery code: <script type=text/javascript src=http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js></script> <script type=text/javascript> name = $(#name).val(); alert(Name:
I have this Javascript function that sends username and password to php file through

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.