java script assignment

download java script assignment

of 7

Transcript of java script assignment

  • 8/7/2019 java script assignment

    1/7

    Student Name: Mohamed Hassan Batch No: 2k8/DSE/23 Student Id: MIDSE 552

    1) Design a simple application in JavaScript to find the biggest of three numbers?

    < html>< /head>< script type="text/javascript">

    function f1(){var a;var b;var c;a=parseInt(n1.value);b=parseInt(n2.value);c=parseInt(n3.value);

    if((a>b)&&(a>c)){alert(a+" is the biggest");

    }else if ((b>a)&&(b>c)){

    alert(b + " is the biggest");}else{alert(c + " is the biggest");}

    }< /script>< /head>< body>

    < table border="1" bgcolor="green">< tr>

    < td> Input first number < /td>< td> < input type="text"

    name="n1"> < /td>< /tr>< tr>

    < td> Input Second number < /td>< td> < input type="text" name="n2">

    < /td>< /tr>

    < td> Input 3rd Number < /td>< td> < input type="text" name="n3">

    < /td>< /tr>

    < /table>< input type="button" value="biggest"

    onclick="f1()">< /body>< /html>

  • 8/7/2019 java script assignment

    2/7

    2

    Student Name: Mohamed Hassan Batch No: DSE/23 Student Id: MIDSE 552

    Q2 ) Design a simple application in JavaScript to greet the user in accordance with the systemtime when the page is displayed. If the time is between 0-1 2 Good morning, 1 2-15 Good Afternoon, 15- 20 Good Evening, 20-25 Good Night?

    var d = new Date();var hrs=d.getHours();

    if((hrs>=0)&&(hrs=12

    )&&(hrs=15)&&(hrs< 20)){ alert("Good Evening");

    }else

    { alert("Good Night");}

  • 8/7/2019 java script assignment

    3/7

    3

    Student Name: Mohamed Hassan Batch No: DSE/23 Student Id: MIDSE 552

    Q3 ) Design a simple application in JavaScript to perform the sales transaction for ABC company. The page should contain a combo box which displays minimum of 4 items, a text boxto display the item name, another textbox to display the price, another text box to display theQuantity, and a text box to display the total amount. When the user selects a item code from thecombo box the corresponding item name should be displayed in the item name text box, as well as the price of the item in the price text box. On users input for the quantity purchased the total should be calculated and displayed in the total amount text box?

  • 8/7/2019 java script assignment

    4/7

    4

    Student Name: Mohamed Hassan Batch No: DSE/23 Student Id: MIDSE 552

    Q4) Design a simple JavaScript to check whether a given value is a string or a number?

    function f(){ var n;

    n=(a.value);if(n!=""){

    if((n>=0)&&(n

  • 8/7/2019 java script assignment

    5/7

    5

    Student Name: Mohamed Hassan Batch No: DSE/23 Student Id: MIDSE 552

    Q5) Design a simple application in JavaScript to demonstrate the submission of a personsresume.

    Firs name

    Second name

    Gender

    Qualification

    Address

    Mobile Number

    On pressing the submit button, the program should check whether all the fields are entered withvalues, else display appropriate message box to the user. If all fields are supplied with values,the details entered should be displayed in a new document in the given format

    Applicant Name

    Gender

    Qualification

    Address

    Mobile Number

    Gender should be displayed as Male/Female not as M/f. First the name and last Name should becombined together.

    Combo box values are

    O/L

    O/L + Diploma

    A Level

    A Level + Diploma

    Submit

  • 8/7/2019 java script assignment

    6/7

    6

    Student Name: Mohamed Hassan Batch No: DSE/23 Student Id: MIDSE 552

  • 8/7/2019 java script assignment

    7/7

    7

    Student Name: Mohamed Hassan Batch No: DSE/23 Student Id: MIDSE 552

    Q6 ) Design a simple application in JavaScript to demonstrate a login page. If the user hasprovided a valid user name and password as in the program load a new page called main.html,else display appropriate error messages?

    function log(){ var uname;var upassword;var duname="hassan";var dpassword="1 23";

    uname=txt1.value;upassword=txt 2.value;

    if(uname==duname){

    if(upassword==dpassword){ alert("welcome "+uname);

    document.open("main.html");

    }else

    { alert("invalid password");}

    }else

    { alert("Invalid user name");}

    }

    User Name Password