mardi 15 avril 2014

Why does this Javascript only run once per page?


Vote count:

0




I have this Try-it-Yourself section to my website but for some reason when I am wanting to have more than one Try-it-Yourself section it will only work for the one at the top of the page. So if I had three of them on a page the top one would work in the way I want but the next two would do nothing.


I have the following HTML:



<div class="tryit">
<table>
<tr>
<td>Try It Yourself</td>
</tr>

<tr>
<td><textarea id="input" rows="10" cols="47"></textarea></td>
</tr>

<tr>
<td><input onclick="update();" type="button" value="Update"></td>
</tr>

<tr>
<td><iframe id="output" name="output" width="600" height="300" ></iframe></td>
</tr>
</table>
</div>


And the following Javascript:



function update()
{
var tryitoutput = document.getElementById('input').value;
window.frames['output'].document.documentElement.innerHTML = tryitoutput;
}


Thank you.



asked 1 min ago






Aucun commentaire:

Enregistrer un commentaire