Results 1 to 3 of 3

Thread: Javascript problem

  1. #1
    mufasil25 is offline Senior Member+
    Last Online
    9th December 2013 @ 12:39 AM
    Join Date
    25 Nov 2010
    Gender
    Male
    Posts
    58
    Threads
    17
    Credits
    691
    Thanked: 1

    Default Javascript problem

    Assalamualikum:
    Umeed hai ap saab kahiriat say hongay.
    bahi jaan mujhay ap se javascripts kay hawalay say help chahiya.
    kah main ek project bnana cahta hoo "Stock Management" means is main stock is information hogi to bahio maine bna to lia hai but us ma ek problem hai. bahi main coding nichay de rha hoo and is ma problem yeh hai kah maine 3 columns bnanai hai 1.Purchase, 2.Sold, 3.Stock. main yeh chahta hoo kah ma puchase ki quantity daloo or sold ki to purchase ma se sold subtract ho kar result stock ma ajai then next row ke purchase ma last stock wali value ajai yaha tak to maine kar lia hai but ek problem hai kah jab meri purchase ki value zero 0 ho jai gi to ma dubara purchase ki value kasay enter karoo ga takay new balance se counting start hoo.yeh cheez mujhay samajh nahi arahi Experts please help

    Code Snippet:
    <html>
    <head>
    <title>Stock Information</title>
    <link rel="stylesheet" type="text/css" href="css/style.css"/>
    <script type="text/javascript">
    //------------------------------------Date---------------------------------------------
    var today = new Date(); //
    var dd = today.getDate(); //
    var mm = today.getMonth()+1; //January is 0! //
    var yyyy = today.getFullYear(); //
    today = dd+'/'+mm+'/'+yyyy; //
    document.write(today); //
    //-------------------------------------------------------------------------------------
    //----------------------------------------------------
    function program(a,b,c,d,e,f)
    {
    var total1=a-b;
    document.stock.t3.value=total1;

    var jump1=document.stock.t3.value;
    document.stock.t4.value=jump1;
    var total2= c-d;
    document.stock.t6.value=total2;

    var jump2=document.stock.t6.value;
    document.stock.t7.value=jump2;
    var total3= e-f;
    document.stock.t9.value=total3;
    }
    </script>
    </head>
    <body>
    <center>
    <h1 class="table">Stock Information</h1>
    </center>
    <table width="800" align="center" class="table1">
    <tr>
    <th width="260"class="table">Purchase</th>
    <th width="260"class="table">Sold</th>
    <th width="428"class="table">Stock</th>
    </tr>
    <form name="stock">
    <tr align="center">
    <td><input id="t1" type="text" style="width:260px;" class="input1"/></td>
    <td><input id="t2" type="text" style="width:260px;" class="input1"/></td>
    <td><input id="t3" type="text" style="width:260px;" class="input1" onClick="program(t1.value,t2.value)" readonly/></td>
    </tr>
    <tr align="center">
    <td><input id="t4" type="text" style="width:260px;" class="input1" onClick="program(t1.value,t2.value,t4.value,t5.val ue)"/></td>
    <td><input id="t5" type="text" style="width:260px;" class="input1"/></td>
    <td><input id="t6" type="text" style="width:260px;" class="input1" onClick="program(t1.value,t2.value,t4.value,t5.val ue)" readonly/></td>
    </tr>
    <tr align="center">
    <td><input id="t7" type="text" style="width:260px;" class="input1" onClick="program(value1.value,value2.value,t4.valu e,t5.value)"/></td>
    <td><input id="t8" type="text" style="width:260px;" class="input1"/></td>
    <td><input id="t9" type="text" style="width:260px;" class="input1" onClick="program(value1.value,value2.value,t4.valu e,t5.value,t7.value,t8.value)"readonly/></td>
    </tr>
    </form>
    </table>
    </body>
    </html>

  2. #2
    asnain_infotech's Avatar
    asnain_infotech is offline Senior Member+
    Last Online
    4th March 2022 @ 07:26 PM
    Join Date
    05 Jun 2009
    Location
    Hyderabad
    Gender
    Male
    Posts
    223
    Threads
    19
    Credits
    1,229
    Thanked
    23

    Default

    Walaikum Assalam,
    Mufasil , ye modified function
    Hope this help you.


    function program(a,b,c,d,e,f)
    {
    var total1=a-b;
    document.stock.t3.value=total1;
    if(total1=="0")
    {
    document.getElementById('t1').value="";
    document.getElementById('t2').value="";
    }


    var jump1=document.stock.t3.value;
    document.stock.t4.value=jump1;
    var total2= c-d;
    document.stock.t6.value=total2;

    var jump2=document.stock.t6.value;
    document.stock.t7.value=jump2;
    var total3= e-f;
    document.stock.t9.value=total3;

    }


    Dua me yad rakhiye..

  3. #3
    sayhellotoit's Avatar
    sayhellotoit is offline Senior Member
    Last Online
    23rd September 2017 @ 07:51 PM
    Join Date
    01 May 2009
    Posts
    1,003
    Threads
    5
    Credits
    53
    Thanked
    127

    Default

    Wa-alaikum-assalam,
    Function banany ka sahi faida nahi uthaya aap nay, iss tarha tu ager aap ki fields barhti jaien gee tu function bhi bara hota jayay ga.
    Yeh code daikhain:
    <html>
    <head>
    <title>Stock Information</title>
    <link rel="stylesheet" type="text/css" href="css/style.css"/>
    <script type="text/javascript">
    //------------------------------------Date---------------------------------------------
    var today = new Date(); //
    var dd = today.getDate(); //
    var mm = today.getMonth()+1; //January is 0! //
    var yyyy = today.getFullYear(); //
    today = dd+'/'+mm+'/'+yyyy; //
    document.write(today); //
    //-------------------------------------------------------------------------------------
    //----------------------------------------------------
    function program(result, a, b)
    {
    var total = a-b;
    if (total != 0)
    result.value = total;
    }

    </script>
    </head>
    <body>
    <center>
    <h1 class="table">Stock Information</h1>
    </center>
    <table width="800" align="center" class="table1">
    <tr>
    <th width="260"class="table">Purchase</th>
    <th width="260"class="table">Sold</th>
    <th width="428"class="table">Stock</th>
    </tr>
    <form name="stock">
    <tr align="center">
    <td><input id="t1" type="text" style="width:260px;" class="input1"/></td>
    <td><input id="t2" type="text" style="width:260px;" class="input1"/></td>
    <td><input id="t3" type="text" style="width:260px;" class="input1" onFocus="program(this, t1.value, t2.value)" readonly/></td>
    </tr>
    <tr align="center">
    <td><input id="t4" type="text" style="width:260px;" class="input1" onFocus="program(this, t1.value, t2.value)"/></td>
    <td><input id="t5" type="text" style="width:260px;" class="input1"/></td>
    <td><input id="t6" type="text" style="width:260px;" class="input1" onFocus="program(this, t4.value, t5.value)" readonly/></td>
    </tr>
    <tr align="center">
    <td><input id="t7" type="text" style="width:260px;" class="input1" onFocus="program(this, t4.value, t5.value)"/></td>
    <td><input id="t8" type="text" style="width:260px;" class="input1"/></td>
    <td><input id="t9" type="text" style="width:260px;" class="input1" onFocus="program(this, t7.value, t8.value)" readonly/></td>
    </tr>
    </form>
    </table>
    </body>
    </html>
    Ab yahan aik sawal hay.
    Ager previous row mein stock ki value zero nahi hay tu next row mein Purchase mein new value enter nahi ki jayay gaee, previous row ki stock ki value hi istamal ki jayay gee, aisa hi hay na ?

Similar Threads

  1. Ms office word 2003 file problem
    By azizgold9 in forum Ask an Expert
    Replies: 1
    Last Post: 10th March 2016, 09:12 AM
  2. CD Read Problem
    By ALI NOOR in forum Ask an Expert
    Replies: 5
    Last Post: 25th January 2013, 08:53 PM
  3. Answered Window 7 problim hi problem a to z all it bayon sy guzarish and help
    By ariyanp480782 in forum Solved Problems (IT)
    Replies: 11
    Last Post: 14th October 2012, 12:56 PM
  4. javascript problem
    By Mian Autos in forum Ask an Expert
    Replies: 3
    Last Post: 9th August 2012, 06:03 AM
  5. NOw Come to jaa sCript :) Easy Hai Lear kArLaIN
    By Rau7* in forum English IT Zone
    Replies: 7
    Last Post: 29th July 2010, 10:49 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •