473,473 Members | 1,793 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Doesnt work in MSIE

In firefox works fine,,,
Someone can explain to me?

function hiddenono(objeto)
{
if (objeto.type == 'hidden')
{objeto.type='text';}
else
{objeto.type='hidden';}
}

Jan 10 '07 #1
2 934
cr************@gmail.com wrote:
In firefox works fine,,,
Someone can explain to me?

function hiddenono(objeto)
{
if (objeto.type == 'hidden')
{objeto.type='text';}
else
{objeto.type='hidden';}
}

IE doesn't let you change the type of an input dynamically. If your
intention is to simply hide or show the input, then modify its CSS
visibility or display attribute.

In DOM 1, an input's type attribute was readonly - that was changed in
DOM 2.

DOM 1 HTMLInputElement:
<URL:
http://www.w3.org/TR/REC-DOM-Level-1...tml#ID-6043025 >

DOM 2 HTMLInputElement:
<URL: http://www.w3.org/TR/DOM-Level-2-HTM...tml#ID-6043025 >
If you really need to change the input's type, a rather ugly hack is to
modify the element's outerHTML if you can (lightly tested in IE and
Firefox, wrapped for posting):

function hiddenono(objeto)
{
if (objeto.type == 'hidden') {
formElChangeType(objeto, 'text');
} else {
formElChangeType(objeto, 'hidden');
}
}

function formElChangeType(el, newType){
var reA = new RegExp(
'type\\s*=\\s*[\\"\\\']*\\w+[\\s\\"\\\']+','i' );
var reB = new RegExp(
'type\\s*=\\s*[\\"\\\']?\\w+[\\s\\"\\\']?','i' );
var s = el.outerHTML;
if (s) {
if (reA.test(s)){
el.outerHTML = s.replace(reB, 'type='+newType+' ');
} else {
el.outerHTML = s.replace(/<input/i, '<input '
+ 'type='+newType+' ');
}
} else {
el.type = newType;
}
}
--
Rob

Jan 11 '07 #2
cr************@gmail.com wrote:
In firefox works fine,,,
Someone can explain to me?

function hiddenono(objeto)
{
if (objeto.type == 'hidden')
{objeto.type='text';}
else
{objeto.type='hidden';}
}
Changing the type-attribute of a form element is rather tricky IMO. You
might consider modifying the element's display style as a more
efficient strategy, at least for your particular requirement when you
only switch between 'hidden' and 'text' types.

<form>
<input type="text" name="T">
<input type="button" value="show"
onClick="document.forms[0].T.style.display=''">
<input type="button" value="hide"
onClick="document.forms[0].T.style.display='none'">
</form>

Hope this helps,

--
Bart

Jan 11 '07 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

13
by: Sheperd | last post by:
Hey everyone, I have this browser detect script and the validator is having problems with it, im trying to validate a page for XHTML 1.0 Transitional If you have any ideas or suggestions they...
3
by: Stan Brown | last post by:
Standard advice -- even given here recently -- for hiding CSS from MSIE 4.x is to enclose the styles in @media { ... }. The same advice is given at . Unfortunately, it doesn't work with MSIE...
2
by: Marek Mänd | last post by:
I have simple structure like: <div> <h3 style="text-align:center;"> <span style="float:right;">input type="image"/></span> <span style="float:left;">input type="image"/></span> boxes titlebar...
7
by: x muzuo | last post by:
Hi guys, I have got a prob of javascript form validation which just doesnt work with my ASP code. Can any one help me out please. Here is the code: {////<<head> <title>IIBO Submit Page</title>...
1
by: celtique | last post by:
Is it possible to make MSIE actually read :hover attribute for other tags, than <a> ? I made sth like that: #vfiles li { background-color: #DCE9DC; } #vfiles li:hover {
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.