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
Solved

elements.type problem

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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Avoid defining the variables in the global scope; trying to define them in a local function scope. Because:   • Look-up is performed every time a variable is accessed.   • Variables are resolved backwards from most specific to least specific scope…
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…

856 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