如何调用javascript函数 [英] how to call a javascript-function

查看:70
本文介绍了如何调用javascript函数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好......我需要帮助......

只是想知道如何放置一个功能?

这是表格:


[HTML]< form>

< p> ;房间类型:< br />

< input type =" radio" ID = QUOT; ROOM1"命名= QUOT;房间"的onclick = QUOT; roomCost = 150" value =" 150" />< label for =" garden"> Garden< / label>< br />

< input type =" radio" ID = QUOT;房间2"命名= QUOT;房间"的onclick = QUOT; roomCost = 200" value =" 200" />< label for =" hillside"> Hillside< / label>< br />

< input type =" radio" ID = QUOT; ROOM3"命名= QUOT;房间"的onclick = QUOT; roomCost = 250" value =" 250" />< label for =" beachfront"> Beachfront< / label>< / p>


< p>逗留时间:< br />

< input type =" radio" ID = QUOT;长度1"名称= QUOT;长度"的onclick = QUOT; lengthStay等于1英寸; value =" 1 night" />< label for =" 1 night"> 1 night< / label>< br />

< input type =" radio" ; ID = QUOT;长度2"名称= QUOT;长度"的onclick = QUOT; lengthStay = 3英寸value =" 3晚">< label for =" 3晚>> 3晚< / labe>< br>


< input type =" ;无线电" ID = QUOT;长度3"名称= QUOT;长度"的onclick = QUOT; lengthStay = 5英寸value =" 5晚" />< label for =" 5晚>> 5晚< / label>< / p>


< ; p>成人人数:< br />

< input type =" radio" ID = QUOT;数字1"名称= QUOT;数"的onclick = QUOT; numberAdult等于1英寸; value =" 1 adult">< label for =" 1 adult"> 1 adult< / label>< br />

< input type =" radio" ; ID = QUOT;数字2"名称= QUOT;数"的onclick = QUOT; numberAdult = 2英寸value =" 2 adult" />< label for =" 2成人"> 2名成人分享< / label>< / p>


< p>如果您想要包含所有餐点,请点击此处:< input type ="复选框"名称= QUOT;膳食及QUOT;的onclick = QUOT; plusMeals = 70" value =" 70" />< / p>


< input type =" button"值= QUOT;计算"的onclick = QUOT;警报(calculateCost());" />

< input type =" reset" /> [/ HTML]



这是我做的javascript但尚未完成:

展开 | 选择 | Wrap | 行号

解决方案

欢迎来到TSDN!

使用代码标签伙伴:-)

你知道事件....

看看这段代码.. .....................................模糊(this,this.parentNode.parentNode,getChildren(this),tru e);>展开 | 选择 | Wrap | 行号


hi ...


欢迎来到TSDN ...


改变了线程标题以更好地描述问题。请...总是使用一个好的主题标题...


亲切的问候


感谢回复人...


i还有点丢失..在我选择了选项后,我按下计算按钮,它应该出现答案,但问题是javascript编码是否正确..如果它错了,你能告诉我错误的部分在哪里吗?


希望我刚刚制作的所有编码都不是完全错误的.. *手指交叉*


谢谢


hi there...i need help...
just wondering how to put a function?

this is the form:

[HTML]<form>
<p>Room type:<br/>
<input type="radio" id="room1" name="room" onclick="roomCost=150" value="150"/><label for="garden">Garden</label><br/>
<input type="radio" id="room2" name="room" onclick="roomCost=200" value="200"/><label for="hillside">Hillside</label><br/>
<input type="radio" id="room3" name="room" onclick="roomCost=250" value="250"/><label for="beachfront">Beachfront</label></p>


<p>Length of stay:<br/>
<input type="radio" id="length1" name="length" onclick="lengthStay=1" value="1 night"/><label for="1 night">1 night</label><br/>
<input type="radio" id="length2" name="length" onclick="lengthStay=3" value="3 nights"/><label for="3 nights">3 nights</labe><br>

<input type="radio" id="length3" name="length" onclick="lengthStay=5" value="5 nights"/><label for="5 nights">5 nights</label></p>


<p>Number of adults:<br/>
<input type="radio" id="number1" name="number" onclick="numberAdult=1" value="1 adult"/><label for="1 adult">1 adult</label><br/>
<input type="radio" id="number2" name="number" onclick="numberAdult=2" value="2 adults"/><label for="2 adults">2 adults sharing</label></p>


<p>Click here if you want all meals included: <input type="checkbox" name="meals" onclick="plusMeals=70" value="70"/></p>

<input type="button" value="Calculate" onclick="alert(calculateCost());"/>
<input type="reset"/>[/HTML]




this is the javascript that i made but not finish yet:

Expand|Select|Wrap|Line Numbers

解决方案

Welcome to TSDN !
Use code Tags buddy :-)
You know events ....
have a look at this code .............

Expand|Select|Wrap|Line Numbers


hi ...

welcome to TSDN ...

changed thread-title to better describe the problem. please ... always use a good thread title ...

kind regards


thanks for the replies guys...

i still kinda lost here.. after i make choices of the options then i press "calculate" button, it should appears the answer but the thing is whether the javascript coding is right or not.. if it''s wrong, could you please tell me where is the wrong part?

hopefully all the coding i just made wasn''t completely wrong.. *finger crossed*

thank you


这篇关于如何调用javascript函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆