
September 24th, 2012, 12:29 PM
|
 |
Contributing User
|
|
|
|
You can just adapt it a little bit then:
Code:
<script>
function insertText(text2insert,formKey,inputKey)
{
document.getElementsByTagName("form")[formKey-1].getElementsByTagName("input")[inputKey-1].value = text2insert;
}
</script>
<form>
<input type="text"/>
</form>
<form name="form" method="post">
<table > <tr><td> CAR #<br><input type='text' class='field' name='car[]' size='1'></td></tr></table>
<table > <tr><td> CAR #<br><input type='text' class='field' name='car[]' size='1'></td></tr></table>
<table > <tr><td> CAR #<br><input type='text' class='field' name='car[]' size='1'></td></tr></table>
<table > <tr><td> CAR #<br><input type='text' class='field' name='car[]' size='1'></td></tr></table>
<input type="button" value="Insert Text" onclick="insertText('Hello','2','2')"/>
</form>
<form>
<input type="text"/>
</form>
Where the "formKey" parameter is a number representation of the form location; in relation to the element's page position (from top to bottom).
|