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





<html>
<head>
<title>EX-8: WTAD : www.bipinrupadiya.com</title>
<script language="javascript">
var temp=new Array();
function findMyStr()
{
myStr=(document.getElementById("txt1").value);
str2bSearch=(document.getElementById("txt2").value);
myStr_length=myStr.length;
str2bSearch_length=str2bSearch.length;
for(i=0;i<myStr_length;i++)
{
temp[i]=myStr.substring(i,str2bSearch_length+i);
}
for(i=0;i<temp.length;i++)
{
if(temp[i]==str2bSearch)
{
found=true;
break;
}
else
{
found=false;
}
}
if(found==true)
document.getElementById("msg").innerHTML='String found ...';
else
document.getElementById("msg").innerHTML='string not found';
}
</script>
</head>
<body>
<br>Enter String : <input type="Text" ID="txt1">
<br>Search String : <input type="Text" ID="txt2">
<br><input type="button" value=" SEARCH" onClick="findMyStr()">
<div id="msg" style="color:red"></div>
</body>
</html>

2 comments:

Unknown said...

Thanks for sharing this page.I learned how to find the string from this page.
Regards,
JAVA Training in Chennai | JAVA course in Chennai

Aparna said...

This is the awesome post and I have huge information from your creative blog. The admin presented the content is very interesting and also comprehensive. Thank you for your sharing, Keep updating...
Oracle Training in Chennai
Oracle Training institute in chennai
Tableau Training in Chennai
Spark Training in Chennai
Pega Training in Chennai
Unix Training in Chennai
Power BI Training in Chennai
Oracle DBA Training in Chennai
Oracle Training in Chennai
Oracle Training institute in chennai

Follow by Email

Blog Archive

Total Pageviews

© BipinRupadiya.com. Powered by Blogger.