Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

assign name

Status
Not open for further replies.

geethanandh

Programmer
Jun 5, 2002
21
0
0
US
hello
Is it possible to assign the value of one textbox as a name to another text box in the same form.

bye
 
if you know the index position of the input box in the form collection:


document.forms[0].elements[1].name=document.forms[0].elements[0].value
 
hi sjravee
I know the name of the textbox which contains the value.
I have tried this
<input type=&quot;text&quot; name='&quot;hello&quot; value=&quot;&quot; size=&quot;14&quot;>
<input type=&quot;text&quot; name=&quot;hello.value&quot; value=&quot;&quot; size=&quot;14&quot;>

but when i submit the form the name of the textbox is not substituted with the value.


bye
geethanandh
 
try the following, it seems to work ok:

<form name=form1 onSubmit=&quot;return ChangeName(document.form1.hello.value)&quot;>
<input type=&quot;text&quot; name=&quot;hello&quot; value=&quot;&quot; size=&quot;14&quot;>
<input type=&quot;text&quot; name=&quot;hello2&quot; value=&quot;&quot; size=&quot;14&quot;>
<input type=submit>
</form>
<script>
function ChangeName()
{
document.form1.hello2.name = document.form1.hello.value
return true
}
</script>

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top