Monday, 17 June 2013

8. Write a JavaScript to find a string from the given text. If the match is found then replace it with another string.

0 comments
WTAD Practical - 8
Write a JavaScript to find a string from the given text. If the match is found then
replace it with another string.




<HTML>
<html>
<HEAD>
<TITLE>WTAD.practical-8 @iAmLearningHere </TITLE>
</HEAD>
<body bgcolor="YellowGreen">
        <font size="4">
        <script language="javascript" type="text/javascript">
        var c = prompt("Enter Text :");
        var searchtxt = prompt("Enter Search Text :");
        document.write("<br>Text is :: " + c );
        document.write("<br>Search text is :: " + searchtxt);
        var r = new RegExp(searchtxt);
        if ( c.search() == -1)
        {
            alert("Match Not Found");
            var searchtxt = prompt("Enter Search Text Again:");
        }
        else
        {
            alert("Match Found !");
            var rtext = prompt("Enter  Text To replace With:");
            document.write("<br>Replace text is :: " + rtext);
            document.write("<br>Replaced Text :: " + c.replace(r,rtext));
        }
    </script>
    </body>
</HTML>

7. Write a JavaScript to convert Celsius to Fahrenheit.

0 comments
WTAD Practical - 7
Write a JavaScript to generate two random numbers and find out maximum and
minimum out of it.




<HTML>
<html>
<HEAD>
<TITLE>WTAD.practical-7 @iAmLearningHere </TITLE>
</HEAD>
<body bgcolor="YellowGreen">
        <center><font size=5>
        <script language="JavaScript">
            var a,b;
            a=parseFloat(prompt("enter the Celsius:",""));
            document.write("Celsius value is: "+a+"<br><br>");
            b=32+(a*1.8);
            alert("Celsius to Fehrenheit "+b);
            document.write("Fehrenheit value is: "+b);
        </script>
    </body>
</HTML>

6. Write a JavaScript to remove the highest element from the array and arrange the array in ascending order.

0 comments
WTAD Practical - 6
 Write a JavaScript to remove the highest element from the array and arrange the array in ascending order.

<HTML>
<html>
<HEAD>
<TITLE>WTAD.practical-6 @iAmLearningHere </TITLE>
</HEAD>
<BODY bgcolor="YellowGreen">
    <script language="JavaScript">
            var i,size,j,temp;
            var arr=new Array();
            size=parseInt(prompt("enter the size of array",""));
            for(i=0;i<size;i++)
            {
                arr[i]=parseInt(prompt("enter the element of array",""));
            }
            document.write("array is:-<br>");
            for(i=0;i<size;i++)
            {
                document.write(arr[i]+", ");
            }
            for(i=0;i<size;i++)
            {
                for(j=i+1;j<size;j++)
                {
                    if(arr[i]>arr[j])
                    {
                        temp=arr[i];
                        arr[i]=arr[j];
                        arr[j]=temp;
                    }
                }
            }
            document.write("<br><br>sorted array is:-<br>");
            for(i=0;i<size;i++)
            {
                document.write( arr[i] + ", ");
            }
            document.write("<br><br>after delete large element array is:-<br>");
            arr.pop();
            for(i=0;i<arr.length;i++)
            {
                document.write(arr[i]+", ");
            }
        </script>
</BODY>
</HTML>
 

Recent Post

Recent Comments

© 2010 IamLearningHere Template by MBT