Solved

elements.type problem

Posted on 1997-06-17
4
299 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

Creating Instructional Tutorials  

For Any Use & On Any Platform

Contextual Guidance at the moment of need helps your employees/users adopt software o& achieve even the most complex tasks instantly. Boost knowledge retention, software adoption & employee engagement with easy solution.

Question has a verified solution.

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

Article by: DanRollins
This article describes a JavaScript program that creates a maze made of hexagonal cells.  In Part 2 (http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/A_7850-Hex-Maze-Part-2.html), we'll extend the program by adding a depth-…
This article discusses the difference between strict equality operator and equality operator in JavaScript. The Need: Because JavaScript performs an implicit type conversion when performing comparisons, we have to take this into account when wri…
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…

733 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