|
|
|||||||||
|
|||||||||
|
|||||||||
| |
|||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
|
|
Generate data entry and reporting .NET Web apps in minutes, straight from your database. Read our FREE whitepaper “Build Web 2.0 Applications Without Hand-Coding” Download now! |
|
#1
|
|||
|
|||
|
Hello, I am trying to get the element image_url name to the new_text() function
I dont know how I would do this I am a beginner at javascript. <script language="JavaScript"> function new_text(field_value){ document.form.+field_value+.value="New Text"; } </script> <input name="image_url5" type="text" onclick="new_text(this.value)"> [/code] The problem is that I have 30 textfields like this with all different names, so that is why I am trying to use a function. Thanks |
|
#2
|
|||
|
|||
|
Why not trying something like :
<script language="JavaScript"> function getName(Field_value) {document.write('<script language="JavaScript">' + 'function newText() {document.form.' + field_value + '.value="NewText";}</script>');}</script> And calling this two functions : <input name="image_url5" type="text" onclick="getName(this.value); newText();"> It's a little bite barbarian but, let's try turning around this trick. |
|
#3
|
|||
|
|||
|
Of course, you have already tried :
<script language="JavaScript"> function newText() {document.form.this.value="NewText";}</script> And : <script language="JavaScript"> function newText() {Field = this.value; document.form.Field.value="NewText";}</script> Or just : <input name="image_url5" type="text" onclick="this.value='New Text'"> |
|
#4
|
|||
|
|||
|
Thank you, I got it working.
![]() |
![]() |
| Viewing: Dev Articles Community Forums > Programming > JavaScript Development > Trying to get a name in a function |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|