Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Simple Multiply 1

Status
Not open for further replies.

gms27

Technical User
Aug 19, 2005
27
PT
Hi there!
I'm trying to make a simple process in my webpage.
I have a filed that does a wordcount and delivers a number, i would like that that number would be multiplied by 0.09.

heres the code:

function countit(){



var formcontent=document.wordcount.wordcount2.value
formcontent=formcontent.split(" ")
document.wordcount.wordcount3.value=formcontent.length
}
</script>
<table border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="100%"><textarea rows="12" name="wordcount2" cols="70" wrap="virtual">
Paste your text here.</textarea></td>
</tr>
<tr>
<td width="100%"><div align="right">
<p align="left">
<input type="button" value="Calculate Words"
onClick="countit()"> <input type="text" name="wordcount3" size="20">
&nbsp;&nbsp;</p>
<p align="left">&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<input name="price" type="text" id="price" size="20">
<span class="style9">&euro;/$</span> </p>
<div align="center"><center><p>&nbsp;



I would like the result (x*o.o9) to appear automatically in the last text box.
Hope someone can help me.

Cheers
 
Code:
<html>
<head>
<script>
/*Word count script
By JavaScript Kit ([URL unfurl="true"]http://javascriptkit.com)[/URL]
Over 400+ free scripts here!
[URL unfurl="true"]http://www.javascriptkit.com/script/script2/countwords.shtml[/URL]
*/

function countit(){
var formcontent=document.getElementById("wordcount2").value;
formcontent = formcontent.split(" ");
var count = formcontent.length
document.getElementById("count").value = count ; 
document.getElementById("countx").value = (count * 0.09); 
}
</script>
</head>
<body>
<table border="1">
    <tr>
      <td width="100%"><textarea rows="12" name="wordcount2" cols="70" wrap="virtual"> Paste your text here.</textarea></td>
    </tr>
    <tr>
      <td>
      <input type="button" value="Calculate Words" onClick="countit()"> 
      <input name="count" id="count" type="text" id="price" size="20">  
      <input name="countx" id="countx" type="text" id="price" size="20">  
</body>
</html>

btw when borrowing code it is polite to not remove thier comments. I re-added them for you.

I don't know the answer but my good friend Google does.
 
Sure but wont that text get in the way of the code?
When the web site is complete it will have a Credits page with links to the tek-tips, phpjunkiard and of course javascriptkit!.
Anyway thanks j4606 ;)
 
hehe the code is comments, so it is not evaluated by the script. Have a nice week end.

I don't know the answer but my good friend Google does.
 
lol ok... i don't know anything about javascript, i only understand Excel code...

P.S. i appollogise to anyone offended by my error.
 
<input name="count" id="count" type="text" id="price" size="20">
<input name="countx" id="countx" type="text" id="price" size="20">

one thing, fireworks says there's a duplicate atribute here.
I have no idea how to solve this
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top