Adverse Credit Remortgage - MPAA - Cheap Car Insurance - Loans - Bad Credit Mortgages

PDA

View Full Version : JS Challenge!


T0PS3O
Mar 7th 2005, 4:48 am
For the JS Geeks :)

If you can change this code:

http://javascript.internet.com/equivalents/length.html

...so it just shows "convert [input type=text] cm to inches [button GO] [input type=text output appears here]" and works as well...

...I'll reward you with links!

Thanks!

nullbit
Mar 7th 2005, 5:11 am
Inside head:

<script type="text/javascript">
<!--
function cm_to_inch(cm)
{
return Math.round(10 * (cm * .39)) / 10;
}
//-->
</script>


Inside body:
<form>
Convert
<input type="text" name="cm" id="cm" />
cm to inches
<input onclick="document.getElementById('inch').value = cm_to_inch(document.getElementById('cm').value)" type="button" value="Go" />
<input type="text" name="inch" id="inch" />
</form>

T0PS3O
Mar 7th 2005, 5:15 am
Legendary!

I spent 10 minutes and couldn't work it out. PM me if you want a link.

Thanks!

T0PS3O
Mar 7th 2005, 5:26 am
How do I put a word inside the button?

nullbit
Mar 7th 2005, 5:28 am
I missed that out. I've edited the post to include the "Go"

T0PS3O
Mar 7th 2005, 6:45 am
Nullbit is a JS whizz indeed. Sussed it but I ran into problems with my host converting double quotes into singles but nullbit had some clever tricks up his sleeve and fixed it again.

Check out his SEO tool as well: http://www.webmasterbrain.com/ looks very impressive indeed.