Solved

elements.type problem

Posted on 1997-06-17
4
300 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The task A number given should be formatted for easy reading by separating digits into triads. Format must be made inline via JavaScript, i.e., frameworks / functions are not welcome. So let’s take a number like this “12345678.91¿ and format i…
Boost your ability to deliver ambitious and competitive web apps by choosing the right JavaScript framework to best suit your project’s needs.
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…

696 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