Insert HTML at certain point in string.
Hi,
Further to my post about counting tables I also want to allow smilies to be entered into the posts. the way I thought to do it would be to us IndexOf() again and search for a string such as ":)". Then when that string is encountered to insert a html string like this: "<img src =\"grin.gif\">". I have tried this approach though and can't get it to work. Here is my script:
<html>
<head>
<title>
Smilie Test</title>
</head>
<body>
<div id ="div1"></div>
<form name ="form1">
<input type ="text" name = "smilebox">
<input type ="button" name ="but1" onclick ="addsmile()" value ="click">
</form>
<script language ="javascript">
function addsmile(){
var SmileStr = document.form1.smilebox.value
var thestr = ":\)"
var found = 0;
var smilecount = 0;
while (found != -1){
found = SmileStr.indexOf(thestr, SmileStr)
if (found !=-1){
addHTML ="<img src =\"grin.gif\">"
smilecount++
found++
}
}
div1.innerHTML = div1.innerHTML + addHTML
}
</script>
</body>
</html>
This just adds the string no matter what is in the input field. Help!
Thanks
interrupt
__________________
\'sync\' <cr>
The name specified is not recognized as an internal or external command, operable program or batch file.
|