GavinPearce
07-08-2003, 11:00 AM
Just a simple script, need to convert MB to KB to Bytes.
I'd like to have three text boxes one below the other, fill in a value in any of them, click go and it converts it to the other two, so the text boxes now display the values.
For example say I put in 100 in the kb box, it would then put the right one in the box above which would be MB and the right conversion in teh box below (which is bytes)
I nice touch would be when I next click on the textbox to enter the next value they automatically clear to allow the enxt input straight away.
Below is a script I found that may help.
<HEAD>
<SCRIPT LANGUAGE="JavaScript">
<!-- Begin
function convert() {
if(document.KBtoMB.KB.value) {
document.KBtoMB.MB.value = eval(document.KBtoMB.KB.value / 1024);
}
else {
if(document.KBtoMB.MB.value) {
document.KBtoMB.KB.value = eval(document.KBtoMB.MB.value * 1024);
}
}
}
// End -->
</script>
</HEAD>
<BODY>
<center>
<form name="KBtoMB">
<input type=text name="KB" size="16">KB
<input type=button name="KBtoMBgo" value=" < = > " onClick="convert()">
<input type=text name="MB" size="16">MB
<input type=reset value=" Clear ">
</form>
</center>
Thank you loads!!!!!!!!!!
I'd like to have three text boxes one below the other, fill in a value in any of them, click go and it converts it to the other two, so the text boxes now display the values.
For example say I put in 100 in the kb box, it would then put the right one in the box above which would be MB and the right conversion in teh box below (which is bytes)
I nice touch would be when I next click on the textbox to enter the next value they automatically clear to allow the enxt input straight away.
Below is a script I found that may help.
<HEAD>
<SCRIPT LANGUAGE="JavaScript">
<!-- Begin
function convert() {
if(document.KBtoMB.KB.value) {
document.KBtoMB.MB.value = eval(document.KBtoMB.KB.value / 1024);
}
else {
if(document.KBtoMB.MB.value) {
document.KBtoMB.KB.value = eval(document.KBtoMB.MB.value * 1024);
}
}
}
// End -->
</script>
</HEAD>
<BODY>
<center>
<form name="KBtoMB">
<input type=text name="KB" size="16">KB
<input type=button name="KBtoMBgo" value=" < = > " onClick="convert()">
<input type=text name="MB" size="16">MB
<input type=reset value=" Clear ">
</form>
</center>
Thank you loads!!!!!!!!!!