html - how to use javascript function in a form button? -


i don't know html , javascript.. have activity on how you'll call javascript function located @ <head></head> of html tag?

and if there several functions? can call @ same time in 1 button? or should create function , put functions in there?

this our activity about... in javascript button, when clicked, must calculate transactions? have 5 functions, , 1 of them called button tag, while other 4 inside of function. don't know do... when clicked button, nothing happen. btw, it's reservation form, when button clicked, must calculate inputs , shows confirmation page/alert prices , such. guys!

this code of form:

<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> 

and javascript code:

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> 

i hope can me guys!

hi have change code little check it

<input type="button" name="submit" onclick="return formsubmit()" class="submit" value="reserve"> 

Comments

Popular posts from this blog

java.util.scanner - How to read and add only numbers to array from a text file -

rewrite - Trouble with Wordpress multiple custom querystrings -