Solved

elements.type problem

Posted on 1997-06-17
4
295 Views
Last Modified: 2012-05-04
I have a javascript which works ok under Netscape but fails
with Explorer... the problem seems to be that when I check elements.type for type checkbox it fails to find anything.
Is there some other way to reference the object?

alert(parent.frames[2].document.forms[0].elements[1].type);
   - netscape says checkbox
   - explorer says nothing ie. blank alert box

the screen has 3 frames.

-barbara
0
Comment
Question by:barbara032497
  • 2
4 Comments
 
LVL 3

Expert Comment

by:RM032397
ID: 1267302
elements.type is not supported in jscript/MSIE 3

Can you tell us more about what you need to do please?

0
 
LVL 5

Expert Comment

by:icd
ID: 1267303
JScript form elements don't have type field: you cannot reference, for instance myButton.type. I believe that this is absent from Navigator 2.0 as well.
0
 
LVL 1

Accepted Solution

by:
viro earned 100 total points
ID: 1267304
RM is right, but ...
You can put the name of the elements like this:
[Type+"_"+Name] - Ex: radio_Name1
then with a function you can read the name of the object and take off the type. Something like:

Aux=""
for (i=0; object.name.charAt(i)!="_"; i++)
  Aux+=object.name.charAt(i)

the type is on the Aux.

hope it help!
0
 
LVL 1

Expert Comment

by:viro
ID: 1267305
It´s ViRo again!
Try this peace of code:

<HTML>
<HEAD>
<SCRIPT LANGUAGE="JavaScript">

function test()
{
  alert(GetType(document.forms[0].elements[0]));
}

function GetType(obj)
{
  Aux=""
  for (var i=0; obj.name.charAt(i) != "_"; i++)      Aux+=obj.name.charAt(i)
  return Aux
}

</SCRIPT>
</HEAD>
<BODY OnLoad='test()'>

<FORM>
  <INPUT TYPE="Text" NAME="Text_ee">
</FORM>

</BODY>
</HTML>
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

This article discusses how to create an extensible mechanism for linked drop downs.
This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

759 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now