Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Web Programming > JavaScript > Javascript How-To
|
Javascript How-To Ask your "How do I do this with Javascript?" questions here.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Javascript How-To section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old June 2nd, 2004, 03:28 PM
Registered User
 
Join Date: Jun 2004
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default using variables within <td> tags

I am fairly new to web page designing although I have been a programmer for over 20 years. I am attempting to create a page with an "excel" looking table format. The user can input numeric data into two of the six cells. What I am trying to do is do background calculations based on those entries and output the results to the other four cells. I am in way over my head with this one.

handyman
 
Old June 2nd, 2004, 03:46 PM
Friend of Wrox
 
Join Date: Nov 2003
Posts: 1,285
Thanks: 0
Thanked 2 Times in 2 Posts
Default

Uhh... have you accomplished any of this task, or are you starting from scratch?

Snib

<><
 
Old June 3rd, 2004, 08:06 AM
Registered User
 
Join Date: Jun 2004
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I apologize for the delay. We had a thunderstorm "crop up" on us and ligthning strikes play havoc with my modem.

Here is what I have coded:

<html>

<head>
<title></title>
</head>

<body bgcolor="#CC9966">

<script>
  var K = 0, D = 0.0, K25 = 0, K30 = 0, D25 = 0.0, D30 = 0.0;
</script>
<table border="1" width="98%" bordercolor="#808080" bordercolorlight="#808080"
bordercolordark="#808080">
  <tr>
    <th width="15%" valign="middle" align="center" bgcolor="#FFFF00"></th>
    <th width="15%" valign="middle" align="center" bgcolor="#FFFF00"></th>
    <th width="25%" valign="middle" align="center" bgcolor="#FFFF00" colspan="2">25%
     Savings</th>
    <th width="25%" valign="middle" align="center" bgcolor="#FFFF00" colspan="2">30%
      Savings</th>
  </tr>
  <tr>
    <th width="15%" valign="middle" align="center" bgcolor="#FFFF00">H</th>
    <th width="15%" valign="middle" align="center" bgcolor="#FFFF00">A</th>
    <th width="13%" valign="middle" align="center" bgcolor="#FFFF00">K</th>
    <th width="12%" valign="middle" align="center" bgcolor="#FFFF00">D</th>
    <th width="13%" valign="middle" align="center" bgcolor="#FFFF00">K</th>
    <th width="12%" valign="middle" align="center" bgcolor="#FFFF00">D</th>
  </tr>
  <tr>
    <td width="15%" bgcolor="#FFFFFF" valign="middle" align="justify">&nbsp; <input
      size="14" name="K" value tabindex="1" onrowexit="calcK(K)"></td>
    <td width="15%" valign="middle" align="justify" bgcolor="#FFFFFF">&nbsp; <!--webbot
      bot="Validation" s-data-type="Number" s-number-separators=",." --><input
      size="14" name="D" value tabindex="2" onrowexit="calcD(D)"></td>
    <td width="13%" valign="middle" align="center" bgcolor="#C0C0C0">&nbsp; <input
      type="hidden" value name="K25"></td>
    <td width="12%" valign="middle" align="center" bgcolor="#C0C0C0">&nbsp; <input
      type="hidden" value name="D25"></td>
    <td width="13%" valign="middle" align="center" bgcolor="#C0C0C0">&nbsp; <input
      type="hidden" value name="K30"></td>
    <td width="12%" valign="middle" align="center" bgcolor="#C0C0C0">&nbsp; <input
      type="hidden" value name="D30"></td>
  </tr>
</table>
<script>
   function calcK(K)
   {
   K25 = K - (K * .25);
   K30 = K - (K * .30);
    }
   function calcD(D)
   {
   D25 = D - (D * .25);
   D30 = D - (D * .30);
    }
</script>

</body>

</html>

It is at this point that I get completely lost.

handyman
 
Old June 15th, 2004, 11:18 PM
Registered User
 
Join Date: Jun 2004
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hey,

I figured it out. I guess you can't use type="hidden" and expect it to show you a value. I, also, used readonly=true to prevent modifications within the cells.

Thanks anyway,

handyman





Similar Threads
Thread Thread Starter Forum Replies Last Post
Change data of <TD> austinf Javascript 3 July 28th, 2006 05:32 AM
Fixing <TD> size. rupen HTML Code Clinic 4 April 28th, 2006 07:41 AM
change <td> value onClick crmpicco Javascript How-To 2 August 23rd, 2005 07:31 AM
<style> tags in a <body> vs. <div> bcat BOOK: Beginning CSS: Cascading Style Sheets for Web Design ISBN: 978-0-7645-7642-3 1 March 27th, 2005 08:50 AM
XML into <td> crmpicco Classic ASP Basics 4 February 11th, 2005 09:57 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.