Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Java > Java and JDK > Java Basics
|
Java Basics General beginning Java language questions that don't fit in one of the more specific forums. Please specify what version.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Java Basics 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 August 5th, 2008, 04:46 AM
Authorized User
 
Join Date: Jul 2008
Posts: 13
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to vsempoux
Default Calculate values of different selectionlists

Hello all,

I have the following html page
Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
    <title>My test page</title>
</head>
<body>
<form id="GetPresations">
    <table>
        <tr>
            <td>Monday</td>
            <td>date</td>
            <td style="width:60px">
                <select name="Mon" style="width:45px">
                    <option value="0" selected="0">0</option>
                    <option value="0,5">0,5</option>
                    <option value="1">1</option>
                </select>
            </td>
            <td>Day prestated</td>
        </tr>
        <tr>
            <td>Tuesday</td>
            <td>date</td>
            <td style="width:60px">
                <select name="Tue" style="width:45px">
                    <option value="0" selected="0">0</option>
                    <option value="0,5">0,5</option>
                    <option value="1">1</option>
                </select>
            </td>
            <td>Day prestated</td>
        </tr>        <tr>
            <td>Wednesday</td>
            <td>date</td>
            <td style="width:60px">
                <select name="Wed" style="width:45px">
                    <option value="0" selected="0">0</option>
                    <option value="0,5">0,5</option>
                    <option value="1">1</option>
                </select>
            </td>
            <td>Day prestated</td>
        </tr>        <tr>
            <td>Thursday</td>
            <td>date</td>
            <td style="width:60px">
                <select name="Thu" style="width:45px">
                    <option value="0" selected="0">0</option>
                    <option value="0,5">0,5</option>
                    <option value="1">1</option>
                </select>
            </td>
            <td>Day prestated</td>
        </tr>        <tr>
            <td>Friday</td>
            <td>date</td>
            <td style="width:60px">
                <select name="Fri" style="width:45px">
                    <option value="0" selected="0">0</option>
                    <option value="0,5">0,5</option>
                    <option value="1">1</option>
                </select>
            </td>
            <td>Day prestated</td>
        </tr>        <tr>
            <td>Saturday</td>
            <td>date</td>
            <td style="width:60px">
                <select name="Sat" style="width:45px">
                    <option value="0" selected="0">0</option>
                    <option value="0,5">0,5</option>
                    <option value="1">1</option>
                </select>
            </td>
            <td>Day prestated</td>
        </tr>        <tr>
            <td>Sunday</td>
            <td>date</td>
            <td style="width:60px">
                <select name="Sun" style="width:45px">
                    <option value="0" selected="0">0</option>
                    <option value="0,5">0,5</option>
                    <option value="1">1</option>
                </select>
            </td>
            <td>Day prestated</td>
        </tr>        <tr>
            <td>Week</td>
            <td></td>
            <td>total</td>
            <td>Day(s) prestated</td>
        </tr>
    </table>
<input name="Send" value="Save prestations" type="button" onclick="alert(total)" style="width: 100px" />
<input NAME="RESET" value="RESET" type="reset" style="width: 87px"/>
</form>
</body>
</html>
I would like to create an onchange function that is used with each selection list.
The function should calculate the total (numeric) value of all selections and put it in the total cell. (so each time i select a value, the total should change).
Also when i click on the send button, it should give me an alert with the total value.

I'm just starting to learn javascript and would appriciate any help from you experienced guys.

Thanks alot already.
Vic

 
Old August 5th, 2008, 08:35 AM
Friend of Wrox
 
Join Date: Mar 2007
Posts: 373
Thanks: 0
Thanked 1 Time in 1 Post
Default

Have a look at the following urls

http://www.w3.org/TR/WCAG20-TECHS/SCR19.html
example at http://www.w3.org/TR/WCAG20-TECHS/wo...dynselect.html

Instead of changing the other selection box values [in the example available at the above URL]
you can write your code to sum the selected values.

- Rakesh
 
Old August 5th, 2008, 08:37 AM
Friend of Wrox
 
Join Date: Mar 2007
Posts: 373
Thanks: 0
Thanked 1 Time in 1 Post
Default

http://www.irt.org/articles/js216/index15.htm

Try the above url also for more info. [Its little old, but you might find it useful to start]

- Rakesh
 
Old August 7th, 2008, 10:25 AM
Authorized User
 
Join Date: Jul 2008
Posts: 13
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to vsempoux
Default

Yes, that did it.
Thanks for the info.







Similar Threads
Thread Thread Starter Forum Replies Last Post
Calculate ivangr Visual Basic 2005 Basics 0 April 9th, 2006 04:39 AM
How to calculate cumulative values of query fields method Access 0 July 12th, 2005 08:53 AM
Access - calculate a cntrl/values from 2nd cntrl CongoGrey Access 3 April 8th, 2005 06:48 AM
calculate the values up crmpicco Classic ASP Basics 3 February 1st, 2005 10:18 AM
Help me How to calculate minhtri VB How-To 4 June 8th, 2004 04:06 PM





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