You are here: Re: Can html perform interactively or make decisions? « HTML « IT news, forums, messages
Re: Can html perform interactively or make decisions?

Posted by David Graham on 02/27/06 19:10

"Toby Inkster" <usenet200602@tobyinkster.co.uk> wrote in message
news:01fbd3-4fn.ln1@ophelia.g5n.co.uk...
> David Graham wrote:
>
> > I just ran the javascript you posted to see it work. When I put in 4 + 3
I
> > get an answer of 43 - is that what you intended?
>
> Not really -- posted without testing.
>
> You can use the parseInt() function to convert from a string to an
integer.
>
> e.g.
> var A = parseInt(document.getElementById('a'));
>
> --
> Toby A Inkster BSc (Hons) ARCS
> Contact Me ~ http://tobyinkster.co.uk/contact
>
Hi Toby
I altered your code to take into account what you just posted, so it looks
like this now:
<script type="text/javascript">
function sum ()
{
//var A = document.getElementById('a');
var A = parseInt(document.getElementById('a'));
//var B = document.getElementById('b');
var B = parseInt(document.getElementById('b'));
//var C = document.getElementById('c');
var C = parseInt(document.getElementById('c'));
C.value = A.value + B.value;
}
</script>
</HEAD>

<BODY>
<div>
<input id="a"> +
<input id="b">
<input type="button" onclick="sum();" value="=">
<input id="c">
</div>

When you click the button now nothing happens - no value for C appears on
the screen!
Any obvious mistake in my interpretation of your last post please?
bye
David

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация