Thursday, 5 March 2020

WT-19

Q1. Write a java script code to accept a number form user and display its factorial.       


<html>
  
<BODY>       
 <center><table border=1>           
<form  name=calculate>
                       
<tr>                
<td>Value :</td>                               
<td> <input type=text name=val1 value=" "></td>              
</tr>               

<tr>
<td> Action: </td>
<td> <input type="radio" value="square" name="gender"
 onClick="squre(form)"> square

<input type="radio" value="Cube" name="gender"
onClick="cube(form)"> Cube

<input type="radio" value="factorial" name="gender"
onClick="factorial(this.form,val1.value)"> Factorial

 </td>
</tr>
           
<tr>                
<td>   
Result : <input type=text  name=val2 value=" ">                             
</td>                          
<td>                           
<input type=reset name="Reset" value="Reset"></b>                                  
</td>                                                              
</tr>
</table>                                              
</center>
                       
<SCRIPT language="JavaScript">                
function squre(form)                          
{                                 
form.val2.value=form.val1.value*form.val1.value;                           
}

                                   
function cube(form)                  
{                                                                                             
form.val2.value=form.val1.value*form.val1.value*form.val1.value;
}

function factorial(f,n)
{
fact=1;
for(i=1;i<=n;i++)
fact=fact*i;
f.val2.value=fact;
}
</SCRIPT>
</BODY>
 </HTML>     

Q2. Design an HTML form to take the information of a customer for booking a travel plan consisting of fields such as name, address, contact no., gender, preferred season(Checkboxes), location type(to be selected from a list) etc. You should provide button to submit as well as reset the form contents. (All the fields should be properly aligned)