Login | Register | FAQ
Anonymous

IndexOf

+ Post a reply

2 posts Page 1 of 1


IndexOf

by tqmd1 » Thu Dec 15, 2011 10:14 am

Dear Experts

Please help me to locate the error in my codes

Code: Select all
<html>
<title>hello</title>
</script>

<body>
<center>

<form name="thisform">
<input name=text1 type=text value="Pakistan"><br>
Result<br><input name=text3 type=text value="" disabled=true><br>
<input name=button8 type=button value="IndexOf"

OnClick="thisform.text3.value=thisform.text1.value.IndexOf('e')">
<input name=reset type=reset value="Clear" onclick="thisform.text1.focus()">
</form>

</center>
</body>
</html>
User avatar

tqmd1

  • Posts: 51
  • Joined: Fri Oct 28, 2011 11:05 am

Re: IndexOf

by mariaantonietta » Thu Dec 15, 2011 11:18 am

Hi, I think the mistake was in the spelling of onclick (you wrote OnClick) and of indexOf (you wrote thisform.text1.value.IndexOf('e')). This is my version of your code: it works on this end, try it out:

Code: Select all
<form name="thisform">
    <input name="text1" type="text" value="Pakistan"><br />
    Result<br /><input name="text3" type="text" value=""  disabled="true" /><br />
    <input name="button8" type="button" value="IndexOf" onclick="thisform.text3.value = thisform.text1.value.indexOf('e')" />
    <input name="reset" type="reset" value="Clear" onclick="thisform.text1.focus()" />
    </form>


Remember that JavaScript is case sensitive.
User avatar

mariaantonietta

  • Posts: 64
  • Joined: Mon Oct 31, 2011 7:23 pm


+ Post a reply

Page 1 of 1