나는 HTML과 가장 특히 자바 스크립트에 대해 아무것도 몰라.하지만 우리는 당신이 HTML 태그의 <head></head>
에있는 자바 스크립트 함수를 호출하는 방법에 대한이 활동을 가지고 있나?양식 버튼에서 javascript 기능을 사용하는 방법은 무엇입니까?
몇 가지 기능이 있다면 어떻게 될까요? 단추 하나로 동시에 호출 할 수 있습니까? 또는 다른 함수를 만들어서 거기에 모든 함수를 넣어야합니까?
이것은 우리의 활동에 대한 모든 것입니다 ... 자바 스크립트 버튼에서, 클릭하면 모든 거래를 계산해야합니까? 나는 5 개의 함수를 가지고 있으며, 그 중 하나는 버튼 태그에 의해 호출되고 나머지 4는 그 함수 안에있다. 나는 무엇을해야 할지를 정말로 모른다. 그러나 내가 버튼을 클릭했을 때, 아무 것도 일어나지 않을 것이다. Btw, 예약 양식이므로 버튼을 클릭하면 모든 입력을 계산하고 가격 등으로 확인 페이지/알림을 표시해야합니다. 고마워요!
이 형태의 내 코드입니다 :
<form name="reserve" action="" id="reserve" method="post">
<fieldset>
<legend>Contact Information</legend>
<label for="name">Name: </label>
<input type="text" name="firstname" value="firstname"
onfocus="if (this.value==this.defaultValue)this.value='';"
onblur="if(this.value=='')this.value=this.defaultValue;"/>
<input type="text" name="lastname" value="lastname"
onfocus="if(this.value==this.defaultValue)this.value='';"
onblur="if(this.value=='')this.value=this.defaultValue;"/>
<br>
<label for="address">Address: </label>
<textarea name="address" cols="30" rows="3"></textarea>
<br>
<label for="city">City: </label>
<input type="text" name="city">
<label for="country">Country: </label>
<select name="country">
<option value=""></option>
<option value="PH">Philippines</option>
<option value="TH">Thailand</option>
<option value="VN">Vietnam</option>
<option value="MY">Malaysia</option>
<option value="ID">Indonesia</option>
<option value="SG">Singapore</option>
</select>
<br>
<label for="email">Email: </label>
<input type="email" name="email">
<label for="phone">Phone: </label>
<input type="tel" name="phone">
</fieldset>
<hr>
<fieldset>
<legend>Accomodation Request</legend>
<label for="checkin">Check-in: </label>
<input type="date" name="checkin">
<label for="checkout">Check-out: </label>
<input type="date" name="checkout">
<br>
<label for="roomtype">Room type: </label> <br>
<input type="checkbox" id="s" name="roomtype" value="superior">Superior |||||
<label for="sguest">No.of guests: </label>
<input type="text" id="supg" name="sguest" size="3"> <br>
<input type="checkbox" id="d" name="roomtype" value=deluxe">Deluxe |||||||
<label for="dguest">No.of guests: </label>
<input type="text" id="delg" name="dguest" size="3"> <br>
<input type="checkbox" id="p" name="roomtype" value="Premier">Premier |||||
<label for="pguest">No.of guests: </label>
<input type="text" id="premg" name="pguest" size="3"> <br>
</fieldset>
<br>
<hr>
<label for="adinfo">Additional Information:</label>
<textarea name="adinfo" cols="40" rows="10"></textarea>
<br><br>
<hr>
<input type="button" name="submit" onclick="formSubmit()"
class="submit" value="Reserve">
</form>
는 그리고 이것은 자바 스크립트 코드 :
function superiorroom(){
var roomprice=0;
var theForm = document.forms["reserve"]
var s = theForm.elements["s"]
var supg = theForm.elements["supg"]
var t=0;
If (s.checked==true)
{
roomprice=5400;
squantity=parseInt(squantity.value);
t=parseInt(t);
t= (roomprice*squantity)*supg;
}
return t;
}
function deluxeroom(){
var roomprice=0;
var theForm = document.forms["reserve"]
var d = theForm.elements["d"]
var delg = theForm.elements["delg"]
var u=0;
If (d.checked==true)
{
roomprice=7200;
dquantity=parseInt(dquantity.value);
u=parseInt(u);
u= (roomprice*dquantity)*delg;
}
return u;
}
function premiumroom(){
var roomprice=0;
var theForm = document.forms["reserve"]
var p = theForm.elements["p"]
var premg = theForm.elements["premg"]
var v=0;
If (p.checked==true)
{
roomprice=9800;
pquantity=parseInt(pquantity.value);
v=parseInt(v);
v= (roomprice*pquantity)*premg;
}
return u;
}
</script>
난 당신이 나에게 사람들을 도울 수 있기를 바랍니다!
의 시도' formSubmit()'함수 ?? – aIKid
오 죄송합니다 ... forumsubmit() 함수 안에는 4 가지 다른 함수 (totalp(), superiorroom() 및 기타가 있습니다.) – chenpai
저에게 그 함수를 보여줄 수 있습니까? 나는 여기서 무엇이 잘못되었는지 분석 할 필요가 있다고 생각합니다. – aIKid