473,405 Members | 2,421 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,405 software developers and data experts.

Help wanted: Simple selection, multiply and display

Sorry if this is real beginner's stuff, but I'm an old-school HTML guy
and this is all another world to me.

Is there an easy way to get the user to specify a number from 1 to 5
(in a pick list or radio button or similar) and get a javascript
routine to multiply it by another hard-coded number (e.g. 7) and
display the result further down the page?

Thanks,
Steve Litchfield

Dec 10 '05 #1
2 1513
"sl*********@ukonline.co.uk" <sl*********@ukonline.co.uk> wrote in
news:11**********************@o13g2000cwo.googlegr oups.com:
Sorry if this is real beginner's stuff, but I'm an old-school HTML guy
and this is all another world to me.

Is there an easy way to get the user to specify a number from 1 to 5
(in a pick list or radio button or similar) and get a javascript
routine to multiply it by another hard-coded number (e.g. 7) and
display the result further down the page?


There is a way. 'Easy' is a term that means different things to different
people.

Working in parts to your post:

1. Specifying number from 1 to 5

You have fairly well described what it is you need to do with respect to
HTML. Either set up a drop-down (select) list or set of radio buttons to
provide the user with the options that you want to limit him/her to. You
will then want a handler to do something once selection is made: either
an "onchange" event for the select/radio control or a button provided to
the user to indicate that the selection is made or final (the use of the
button is better, unless you want the user to have the option of seeing a
result updated with each selection).

2. Multiplying by hard-coded number

You then have the handler call the function that will do items 2 and 3 in
this descriptive outline. The function will recover the value from the
(form) control set by the user, do the math that you want, and produce the
result. The result will be displayed as described below.

3. Displaying Result

You will want to have a DIV element with an 'id' attribute as part of your
document. It can be empty and/or set not to display through Javascript.
Within the function that gets the value and does the math, you will
reference that DIV and add text as a child node of that DIV. That text
content will be your result. You will want to learn particularly about
the methods 'document.createTextNode()' and 'document.createElement()' in
manipulating HTML documents dynamically. I recommend browsing through the
DOM Core and HTML specifications found at http://www.w3.org. Once your
familiar with these interfaces, you will get pretty much what you want.

I would think that given my descriptive outline above, you have sufficient
information for proceeding with coding. Let's see what you come up with,
and come back here if your code fails to work and you are stuck.

Dec 11 '05 #2
Thanks, you've been brilliant! That's all printed out and I'll get this
sorted (hopefully!) over Christmas. I've also found a friend with some
experience, so between us....

Thanks again
Steve

Dec 12 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Donna | last post by:
I am attempting a distance learning course in Java but am having problems with a task. I have completed the simple little program as listed below. public class Results { private static String...
31
by: da Vinci | last post by:
OK, this has got to be a simple one and yet I cannot find the answer in my textbook. How can I get a simple pause after an output line, that simply waits for any key to be pressed to move on? ...
5
by: ritchie | last post by:
Hi, I am writing to ask if anyone can see why my array is not being sorted correctly? It's an array of 4 elements(ints 1,2,3,4) but after calling the selection sort it comes back sorted as...
2
by: Daniel | last post by:
I'm new to .Net and all of its abilities so I hope this makes sense. Basically I'm confused on when is the appropriate time to use web forms controls vs. regular HTML. For example in ASP...
6
by: Teep | last post by:
Below is my code for dropdownlist that is populated from a SQL table. After a selection from the ddl, a datagrid is suppose to come up pertaining to the information selected, but I keep getting a...
3
by: knightsmastergeneral | last post by:
Hi, I'm currently working on getting junit and junireport to take some java files, convert it to xml and then display error messages / success rates etc in html which is one of the features of...
1
by: JWest46088 | last post by:
The program asks for the user to enter a real number and an imaginary number followed by another set of a real number and an imaginary number. It then takes those and adds them, subtracts them, and...
1
by: KiMcHeE | last post by:
Hi! I'm having a real difficult time trying to figure out what is wrong with my program code. I'm trying to make a "calculator" in the C language and I only know basic stuff. Here's my code: ...
0
by: gunimpi | last post by:
http://www.vbforums.com/showthread.php?p=2745431#post2745431 ******************************************************** VB6 OR VBA & Webbrowser DOM Tiny $50 Mini Project Programmer help wanted...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.