Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

elements.type problem

Posted on 1997-06-17
4
Medium Priority
?
303 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 400 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

Tech or Treat! - Giveaway

Submit an article about your scariest tech experience—and the solution—and you’ll be automatically entered to win one of 4 fantastic tech gadgets.

Question has a verified solution.

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

This article will give core knowledge of JavaScript and will head in to your first JavaScript program. I am Durvesh Naik and I am here to deal with this series of JavaScript. I will teach you JavaScript in part wise , as its quite boring to read big…
This article discusses how to implement server side field validation and display customized error messages to the client.
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…

597 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