Sasa Posted August 14, 2009 Report Share Posted August 14, 2009 mana funkcija ir šāda: function searchChPoz(searchIn, searchWhat) { var str = searchIn.toString(); var poz = str.search(/searchWhat.toString()/i); return poz; } mēģinu izmantot šādi: Response.write("<td id=\"WoodyCode\" class=\"woodycode\">" + searchChPoz(array[row][col], "n") + "</td>"); rezultātā izvada visu laiku -1, bet man vajag atrašanās pozīciju un cik saprotu -1 nozīmē to ka nekas netika atrasts, bet tāds čars man tur ir. Quote Link to comment Share on other sites More sharing options...
0 bubu Posted August 14, 2009 Report Share Posted August 14, 2009 Vai tu saproti, ka tajā str stringā tu meklē stringu "searchWhat.toString()", nevis čaru "n" ? T.i, tas tiks atrast tikai tad, ja str saturēs kautko šādu "asdfgsfg searchWhat.toString() zummdumm". Quote Link to comment Share on other sites More sharing options...
0 indoom Posted August 14, 2009 Report Share Posted August 14, 2009 return searchIn.toString().indexOf(searchWhat); Quote Link to comment Share on other sites More sharing options...
Question
Sasa
mana funkcija ir šāda:
mēģinu izmantot šādi:
rezultātā izvada visu laiku -1, bet man vajag atrašanās pozīciju un cik saprotu -1 nozīmē to ka nekas netika atrasts, bet tāds čars man tur ir.
Link to comment
Share on other sites
2 answers to this question
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.