my dog learned polymorphism*
The moose likes HTML, CSS and JavaScript and the fly likes Getting a form name from the select Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "Getting a form name from the select" Watch "Getting a form name from the select" New topic
Author

Getting a form name from the select

Christophe Verré
Sheriff

Joined: Nov 24, 2005
Posts: 14687
    
  16

There are two selects in a form called Form1, respectively called firstSelect and secondSelect.
The firstSelect has an onchange event defined like this:
<select name="firstSelect" onchange="changVal(this, document.myform.secondSelect)">

When the value changes, changVal(oElem,oTarget) is called.
In changVal(), calling alert(oTarget.form.name) will display the form name Form1.

Can you please explain this ? I can't see anything about Select components having a property called form in the HTML Specification. Maybe I'm looking at the wrong spec.

(For those who own Ajax In Action, please refer to Listing 9.2, page 333)


[My Blog]
All roads lead to JavaRanch
Jaikiran Pai
Marshal

Joined: Jul 20, 2005
Posts: 9947
    
161

Had a look at the MSDN reference, select does have a attribute named form:

select in HTML

Specifically,
form attribute on HTML Object


[My Blog] [JavaRanch Journal]
Christophe Verré
Sheriff

Joined: Nov 24, 2005
Posts: 14687
    
  16

Thank you.
Referring to the link you've posted, I've figured out that it was part of Document Object Model HTML.
http://www.w3.org/TR/2000/WD-DOM-Level-1-20000929/level-one-html.html#ID-94282980
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Getting a form name from the select
 
Similar Threads
Drop Downs
Posting one selected option value in two forms
Can not Populate the form on combo box change
JavaScript not loading
Drop Down validation