<html><head><script type="text/javascript">var x=3</script><body><script type="text/javascript" src="created.js"></script></body></html>
Created.js:
document.write('<table border="1" style="position: absolute; right: 50%; top: 30%;">');for(i=1;i<7;i++) {if(i==x){break};document.write('<tr><td>something</td></tr>'); }document.write('<tr><td>special TD</td></tr>');for(i=x;i<7;i++) {document.write('<tr><td>something</td></tr>'); } document.write('</table>');
So, isn't there a way to combine the two loops with the IF statement being inside and get 1 loop to do this entire work? I tried and did almost everything I thought of to make this work, and at the end this was my solution, yet I still wonder if there isn't the way I looked for - 1 loop with an IF statement inside that works correctly....Could someone pls repair these things for me so that I can see where I have been mistaken? Thanks in advance. PS: The code should be working as it is as well, yet it looks better when it's more compact And I want to keep the codes tidy and not messy Thanks all...