• Post Reply Bookmark Topic Watch Topic
  • New Topic

How to extract string value  RSS feed

 
Gerard Largosa
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
-------------code sample---------------------
<img src="./Images/1.jpg" name = "Name1" onclik="function_1(this)">


<Script Language=JavaScript>


function function_1(field_name){
var x = field_name;
//extract path value from field_name, see question below.

}
</Script>

------------------------------------------

How can I extract the path name(document.form1.Name1) out of the variable field_name. I have tried to do var x = field_name.toString() but it does not work instead I get the string [object].
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 66263
151
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Images aren't form elements so there is not a form attribute for you to obtain the name of the containing form.

What are you really trying to do?
 
Eric Pascarello
author
Rancher
Posts: 15385
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You are passing in a reference to the object so you can access the attributes directly.

var src = field_name.src;
var name = field_name.name;

Eric
[ August 04, 2006: Message edited by: Eric Pascarello ]
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!