I have a problem creating a for-loop using Javascript. It seems everyting is fine for me but still I didn't get what I want.
Take a look please to this code to understand more:
The HTML form code:
<form name="myform"> <textarea name="inputtext" cols="100%" rows="10%"></textarea><br /> <input type="radio" name="options" value="javascript" checked> Option1 <br /> <input type="radio" name="options" value="windows"> Option2<br /> <input type="button" value="Do it" onClick="generate();"><br /> <textarea name="outputtext" cols="100%" rows="10%"></textarea><br /> </form>
The Javascript code:
function generate() { var code = ""+document.myform.inputtext.value; if (document.myform.options[0].checked) { document.myform.outputtext.value = escape(code); } else { var result= "2- "; for(int i=0; i<code.length; i++) { //There will be some logic to decide if to add the char or not. result+=code.charAt(i); } document.myform.outputtext.value = result; } }
The problem is not clear for me. However, when I try to comment out the for-loop, everything works fine !
Any ideas?
int
is not a datatype in javascript. Please use a javascript debugger (like firebug on firefox) to help you out. – Munim May 15 '11 at 19:26