.dsy:it.
Show 150 posts per page

.dsy:it. (http://www.dsy.it/forum/)
- Forum De Bell Tolls (http://www.dsy.it/forum/forumdisplay.php?forumid=7)
-- [JAVASCRIPT] Operazioni nei Form. (http://www.dsy.it/forum/showthread.php?threadid=8201)


Posted by dan on 21-01-2004 14:50:

[JAVASCRIPT] Operazioni nei Form.

<tr>
<td><input type="radio" name="hotel" value="marina" onSelect=""></td>
<td>Hotel 1 </td>
<td>460 € </td>

</tr>
<tr>
<td><input type="radio" name="hotel" value="western"></td>
<td>Hotel 2 </td>
<td>432 € </td>
</tr>
<tr>
<td><div align="right">
<input type="checkbox" name="aggiungici">
</div></td>
<td>120 € </td>
</tr>

<tr>
<td><div align="right"><strong>Importo Totale </strong></div></td>
<td><input type="text" name="tot"></td>
</tr>


Voglio che nella casella Importo Totale venga indicato il valore corrispondente alle caselle selezionate, ovvero:
460, 432, 580 o 552

E' possibile?!?!


Posted by korn on 21-01-2004 15:17:

Prova così...


code:
<script language="JavaScript"> <!-- function totale () { var palbergo = 0; if ( document.forms[0].hotel.value == "marina" ) palbergo = 460; if ( document.forms[0].hotel.value == "western" ) palbergo = 432; if ( document.forms[0].aggiungici.checked == true ) palbergo += 120; document.forms[0].tot.value = palbergo; } //--> </script>


e poi aggiungi negli <input> del check e dei radio
code:
onClick="totale();"


E' fatto in fretta e furia, spero funzioni :)

Se non funziona, prova a sostituire forms[0] con il nome della form, e ricorda che JS è case-sensitive!

__________________
» Collect some stars to shine for you, and start today ‘cause there are only a few. _ (In Flames)
» Don't stop for nothing, it's full speed or nothing! I'm taking down, you know, whatever is in my way! _ ('tallica)
» I am my own god, I do as I please. _ (Pain)
» Ninetynine, ninetynine knives! Ninetynine knives inside! Nobody gets out alive! _ (The Haunted)
Web: http://www.negativesignal.com - ICQ# 171585477 - Death to software patents! And TCPA too! "e uno!", diceva il boia.


Posted by dan on 21-01-2004 16:13:

Posso fare:

if ( document.forms[0].aggiungici.checked == true && document.forms[0].hotel.value == "western" )

??

Cosa devo mettere nel value di Importo Totale?


Posted by dan on 21-01-2004 17:48:

OK funzia alla perfection! :D

Il codice giusto era:
code:--------------------------------------------------------------------------------
<script language="JavaScript">
<!--
function totale () {
var palbergo = 0;
if ( document.forms[0].hotel[0].checked == true )
palbergo = 460;
if ( document.forms[0].hotel[1].checked == true )
palbergo = 432;
if ( document.forms[0].aggiungici.checked == true )
palbergo += 120;
document.forms[0].tot.value = palbergo;
}
//-->
</script>
--------------------------------------------------------------------------------


All times are GMT. The time now is 04:58.
Show all 4 posts from this thread on one page

Powered by: vBulletin Version 2.3.1
Copyright © Jelsoft Enterprises Limited 2000 - 2002.