Cool, so it can be done...
Thanks....

-----Original Message-----
From: Spike [mailto:[EMAIL PROTECTED]
Sent: Friday, 21 November 2003 10:40 AM
To: CFAussie Mailing List
Subject: [cfaussie] RE: [OT] JS Object


That should be easy enough...

<script>
function getFormName(obj) {
   var parent = obj.parentElement;
   if (parent.tagName == 'FORM') {
     alert(parent.getAttribute('name'));
   }
   else {
     getFormName(parent);
   }
}

</script>


<form action="index.cfm" method="post" name="foo">
    <div>
     <span>
       <a href="#" onclick="getFormName(this)">testit</a>
     </span>
    </div>
</form>

Spike

Taco Fleur wrote:

> ????
> 
> Maybe I wasn't clear, first of all, I am not having problems ;-))
> It's just that a light bulb went on, and I was wondering if............
> 
> <form name="billy">
> <a href="" onclick="fnTest( this );">test</a>
> </form>
> 
> script..........
> function fnTest( obj )
> {
>       Tell me what form you belong to sonny??
> }
> 
> Instead of 
> 
> <form name="billy">
> <a href="" onclick="fnTest( this.formName );">test</a>
> </form>
> 
> -----Original Message-----
> From: Spike [mailto:[EMAIL PROTECTED]
> Sent: Friday, 21 November 2003 10:27 AM
> To: CFAussie Mailing List
> Subject: [cfaussie] RE: [OT] JS Object
> 
> 
> Why won't that work for you?
> 
> The easiest way to find out is to do something like this:
> 
> <script>
> function dumpit(obj) {
>    var output = '<table>';
>    for (var prop in obj) {
>      output += '<tr><td>' + prop + '</td><td>';
>      if (typeof(obj[prop]) == 'object') {
>        output += '[object]';
>      }
>      else {
>       output += obj[prop];
>      }
>      output += '</td></tr>';
>    }
>    output += '</table>';
>    document.getElementById('dumper').innerHTML = output;
> }
> 
> 
> </script>
> 
> <div id="dumper"></div>
> 
> <form action="index.cfm" method="post" name="foo" onclick="dumpit(this)">
>     Click to view DOM info.
> </form>
> 
> Taco Fleur wrote:
> 
> 
>>PS. I know it can be done like this.form or this.formName but that's not 
>>what I am after.. ;-))
>>
>>    -----Original Message-----
>>    *From:* Taco Fleur
>>    *Sent:* Friday, 21 November 2003 10:15 AM
>>    *To:* CFAussie Mailing List
>>    *Subject:* [cfaussie] [OT] JS Object
>>
>>    Can you derive the form name from an object?
>>
>>    For example, let's say I am calling a JS function within a form, I
>>    pass this function the object it is called from ie. (this), within
>>    the function can I now derive the form name from this object?
>>
>>    *Taco Fleur
>>    07 3535 5072*
>>    Tell me and I will forget
>>    Show me and I will remember
>>    Teach me and I will learn
>>
>>    ---
>>    You are currently subscribed to cfaussie as: [EMAIL PROTECTED]
>>    To unsubscribe send a blank email to
>>    [EMAIL PROTECTED]
>>    MXDU2004 + Macromedia DevCon AsiaPac + Sydney, Australia
>>    http://www.mxdu.com/ + 24-25 February, 2004 
>>
>>---
>>You are currently subscribed to cfaussie as: [EMAIL PROTECTED]
>>To unsubscribe send a blank email to 
>>[EMAIL PROTECTED]
>>MXDU2004 + Macromedia DevCon AsiaPac + Sydney, Australia
>>http://www.mxdu.com/ + 24-25 February, 2004
> 
> 

-- 
Stephen Milligan
Software Architect for http://www.bestrates.com.au
MSN: [EMAIL PROTECTED]



---
You are currently subscribed to cfaussie as: [EMAIL PROTECTED]
To unsubscribe send a blank email to [EMAIL PROTECTED]

MXDU2004 + Macromedia DevCon AsiaPac + Sydney, Australia
http://www.mxdu.com/ + 24-25 February, 2004

---
You are currently subscribed to cfaussie as: [EMAIL PROTECTED]
To unsubscribe send a blank email to [EMAIL PROTECTED]

MXDU2004 + Macromedia DevCon AsiaPac + Sydney, Australia
http://www.mxdu.com/ + 24-25 February, 2004

Reply via email to