/    Sign up×
Community /Pin to ProfileBookmark

who can help me

well
i make a search function ith javascript that can find a character or a word
in a sentence but i want it to select that word or character
but it selectall the sentence
what can i do? ?

to post a comment
JavaScript

3 Comments(s)

Copy linkTweet thisAlerts:
@BigMoosieMay 10.2005 — Paste your code
Copy linkTweet thisAlerts:
@mohsenauthorMay 11.2005 — <html>

<head>

</head>

<body>

<table align=center>

<tr><td><textArea id=m1>text here</textArea>

<tr><td><input type=text id=m2>

<tr><td><input type=button value=Search id=m3 onclick="y();">

</table>

</body>

<SCRIPT LANGUAGE="JavaScript">

var a,b,c,d,e,f;

function y(){

a=m1.value;

b=m2.value;

c=a.length-1;

for(i="0";i<=c;i++){

d=a.charAt(i);

if(d==b){

alert(d+" "+"is"+" "+i);

}

}



}

</SCRIPT>

</html>
Copy linkTweet thisAlerts:
@TheBearMayMay 11.2005 — This should be close:

<i>
</i>function y(){
var pos=document.getElementById("m1").value.indexOf(document.getElementById("m2").value);
if (pos &gt;= 0) alert(document.getElementById("m2").value+" is located at position "+ pos);
}
×

Success!

Help @mohsen spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.18,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...