Forum Moderators: open
<SCRIPT>
mystring = "this is the translated text";
for (i=0;i<mystring.length;i++) {
j = mystring.substring(i,i+1);
if (j == " ") j = "space";
document.write("<IMG SRC="+j+".gif>");
}
</SCRIPT>
what happens is the text in the mystring= "here" gets converted into images, t being converted to t.gif and so on. Now in order for user input I'm not entrily sure what to do what I've got is:
<SCRIPT>
mystring = "";
for (i=0;i<mystring.length;i++) {
j = mystring.substring(i,i+1);
if (j == " ") j = "space";
document.write("<IMG SRC="+j+".gif>");
}
</SCRIPT>
<script>
function go(){
var text = document.theform.letters.value;
}
</script>
<form name="theform">
<input type="text" size="20" name="letters">
<input type="button" value="Go" onclick="go()"/>
</form>
But I'm not sure what to put after 'value;' which will take the text from the input box and put it into the brackets in the mystring function. Any thoughts?
luke
<script>
function go(){
var text = document.theform.letters.value +"";
mystring = text;
for (i=0;i<mystring.length;i++) {
j = mystring.substring(i,i+1);
if (j == " ") j = "space";
document.write("<IMG SRC="+j+".gif>");
}
}
</script>
...when you document.write the browser clears the screen and starts a fresh document.