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)">
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
Trying to get a name in a function - Javascript
Moderator: General Moderators
Code: Select all
<script language="JavaScript">
function new_text(srcObj){
srcObj.value="New Text";
}
</script>
<input name="image_url5" type="text" onclick="new_text(this)">- feyd
- Neighborhood Spidermoddy
- Posts: 31559
- Joined: Mon Mar 29, 2004 3:24 pm
- Location: Bothell, Washington, USA
try...
Code: Select all
eval('document.' + field_name + '.value = ''' + new_value + '''');
or
eval('document.formsї''form_name''].elementsї''' + field_name + '''].value = ''' + new_value + '''');
-------------
onclick="new_text(this.name)"