🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: cth.dtek.general
2 messages
2 total messages Started by Daniel Johansson Sun, 01 Nov 1998 00:00
java script-fr�ga
#15
Author: Daniel Johansson
Date: Sun, 01 Nov 1998 00:00
22 lines
970 bytes
Tjena!

Jag har en grundl�ggande java script-fr�ga.
Jag har en funktion l�ngst upp i ett HTML-dokument som heter
AddPrice_aftele.
V�rdet p� cost-variabeln genereras med en parseInt l�ngre
ner i HTML-dokumentet. Nu till fr�gan:
Innan jag ber�knar real_cost vill jag kolla att cost verkligen
�r ett heltal s� man inte knappat in bokst�ver eller liknande.
Om cost �r NaN (not a number) ska det s�ttas till 0.
Jag vet knappt n�t om java script. Hj�lp!

Koden hittills:

function addPrice_aftele(cost,button)
{
    .....vad h�r?....
    real_cost=cost+100.
}


HJ�LP!
Re: java script-fr�ga
#16
Author: Vilhelm Bergman
Date: Sun, 01 Nov 1998 00:00
32 lines
1210 bytes
In article <71i49f$8p7$1@nyheter.chalmers.se>,
Daniel Johansson <d96j@dtek.chalmers.se> wrote:
>Innan jag ber�knar real_cost vill jag kolla att cost verkligen
>�r ett heltal s� man inte knappat in bokst�ver eller liknande.
>Om cost �r NaN (not a number) ska det s�ttas till 0.
>
>Koden hittills:
>
>function addPrice_aftele(cost,button)
>{
>    .....vad h�r?....
>    real_cost=cost+100.
>}

	apa="7"
	
	if(parseInt(apa)!=parseFloat(apa)) {
		window.alert("float " + apa)
	} else {
		if(isNaN(apa)) {
			window.alert("NaN")
		} else {
			window.alert("int "+apa)
		}
	}

Borde v{l t{cka vad du ville ha...

/v
-- 
"Should array indices start at 0 or 1? My compromise of 0.5 was rejected
 without, I thought, proper consideration." - Stan Kelly-Bootle
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads