473,729 Members | 2,197 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Problem changing button type in IE using Javascript

I have a button

<input type="submit" name="Delete" value="Delete">

This code can not be changed

I want to use Javascript to change the type

I tried:

document.Detail View.Delete.typ e='button'

This works perfectly in Firefox

But in IE I get the error

Error: Could not get the type property. This command is not supported

How can I do this in a way that works in IE
Sep 5 '08 #1
8 5145
mike_solomon wrote:
I have a button

<input type="submit" name="Delete" value="Delete">

This code can not be changed

I want to use Javascript to change the type

I tried:

document.Detail View.Delete.typ e='button'

This works perfectly in Firefox

But in IE I get the error

Error: Could not get the type property. This command is not supported

How can I do this in a way that works in IE
Create a new input element with the necessary properties, then replace
the 'submit' button with the 'button' button.
--

Martin Honnen
http://JavaScript.FAQTs.com/
Sep 5 '08 #2
On 5 Sep, 13:12, Martin Honnen <mahotr...@yaho o.dewrote:
mike_solomon wrote:
I have a button
<input type="submit" name="Delete" value="Delete">
This code can not be changed
I want to use Javascript to change the type
I tried:
document.Detail View.Delete.typ e='button'
This works perfectly in Firefox
But in IE I get the error
Error: Could not get the type property. This command is not supported
How can I do this in a way that works in IE

Create a new input element with the necessary properties, then replace
the 'submit' button with the 'button' button.
--

* * * * Martin Honnen
* * * *http://JavaScript.FAQTs.com/
Sorry I not sure how to to that

Can you give me an example pls
Sep 5 '08 #3
mike_solomon wrote:
>Create a new input element with the necessary properties, then replace
the 'submit' button with the 'button' button.
Sorry I not sure how to to that

Can you give me an example pls
Assume you have a reference named input to the submit button:

var newInput = document.create Element('input' );
newInput.type = 'button'; // that should work even with IE
newInput.name = input.name;
newInput.value = newInput.defaul tValue = input.value;
input.parentNod e.replaceChild( newInput, input);

--

Martin Honnen
http://JavaScript.FAQTs.com/
Sep 5 '08 #4
On 5 Sep, 13:33, Martin Honnen <mahotr...@yaho o.dewrote:
mike_solomon wrote:
Create a new input element with the necessary properties, then replace
the 'submit' button with the 'button' button.
Sorry I not sure how to to that
Can you give me an example pls

Assume you have a reference named input to the submit button:

* *var newInput = document.create Element('input' );
* *newInput.type = 'button'; // that should work even with IE
* *newInput.name = input.name;
* *newInput.value = newInput.defaul tValue = input.value;
* *input.parentNo de.replaceChild (newInput, input);

--

* * * * Martin Honnen
* * * *http://JavaScript.FAQTs.com/

Martin thats great

I have done the following

var input = document.Detail View.Delete
var newInput = document.create Element('input' );
newInput.type = 'button';
newInput.name = input.name
newInput.value = newInput.defaul tValue = input.value;
newInput.onclic k =function fdelmsg(){alert (delmsg)};
newInput.setAtt ribute("class", "button")
input.parentNod e.replaceChild( newInput, input);

This works in Firefox & almost works in IE

The bit that doesn't work in IE is
newInput.setAtt ribute("class", "button")

It doesn't give me an error but it doesn't change the button class
either :(
Sep 5 '08 #5
On 5 Sep, 13:58, mike_solomon <g...@solomontr ibe.co.ukwrote:
On 5 Sep, 13:33, Martin Honnen <mahotr...@yaho o.dewrote:
mike_solomon wrote:
>Create a new input element with the necessary properties, then replace
>the 'submit' button with the 'button' button.
Sorry I not sure how to to that
Can you give me an example pls
Assume you have a reference named input to the submit button:
* *var newInput = document.create Element('input' );
* *newInput.type = 'button'; // that should work even with IE
* *newInput.name = input.name;
* *newInput.value = newInput.defaul tValue = input.value;
* *input.parentNo de.replaceChild (newInput, input);
--
* * * * Martin Honnen
* * * *http://JavaScript.FAQTs.com/

Martin thats great

I have done the following

var input = document.Detail View.Delete
var newInput = document.create Element('input' );
newInput.type = 'button';
newInput.name = input.name
newInput.value = newInput.defaul tValue = input.value;
newInput.onclic k =function fdelmsg(){alert (delmsg)};
newInput.setAtt ribute("class", "button")
input.parentNod e.replaceChild( newInput, input);

This works in Firefox & almost works in IE

The bit that doesn't work in IE is
newInput.setAtt ribute("class", "button")

It doesn't give me an error but it doesn't change the button class
either :(
Final working solution

var input = document.Detail View.Delete
var newInput = document.create Element('input' );
newInput.type = 'button';
newInput.name = input.name
newInput.value = input.value;
newInput.onclic k =function fdelmsg(){alert (delmsg)};
input.parentNod e.replaceChild( newInput, input);
newInput.classN ame = 'button';
Sep 5 '08 #6
On 5 Sep, 13:58, mike_solomon <g...@solomontr ibe.co.ukwrote:
On 5 Sep, 13:33, Martin Honnen <mahotr...@yaho o.dewrote:
mike_solomon wrote:
>Create a new input element with the necessary properties, then replace
>the 'submit' button with the 'button' button.
Sorry I not sure how to to that
Can you give me an example pls
Assume you have a reference named input to the submit button:
* *var newInput = document.create Element('input' );
* *newInput.type = 'button'; // that should work even with IE
* *newInput.name = input.name;
* *newInput.value = newInput.defaul tValue = input.value;
* *input.parentNo de.replaceChild (newInput, input);
--
* * * * Martin Honnen
* * * *http://JavaScript.FAQTs.com/

Martin thats great

I have done the following

var input = document.Detail View.Delete
var newInput = document.create Element('input' );
newInput.type = 'button';
newInput.name = input.name
newInput.value = newInput.defaul tValue = input.value;
newInput.onclic k =function fdelmsg(){alert (delmsg)};
newInput.setAtt ribute("class", "button")
input.parentNod e.replaceChild( newInput, input);

This works in Firefox & almost works in IE

The bit that doesn't work in IE is
newInput.setAtt ribute("class", "button")

It doesn't give me an error but it doesn't change the button class
either :(
Final solution

var input = document.Detail View.Delete
var newInput = document.create Element('input' );
newInput.type = 'button';
newInput.name = input.name
newInput.value = input.value;
newInput.onclic k =function fdelmsg(){alert (delmsg)};
input.parentNod e.replaceChild( newInput, input);
newInput.classN ame = 'button';
Sep 5 '08 #7
mike_solomon meinte:
The bit that doesn't work in IE is
newInput.setAtt ribute("class", "button")
That's because IE has its problems with setAttribute(). It's superfluous
anyway.

newInput.classN ame = "button"; will do the job more efficiently and more
compatible.

Gregor
--
http://photo.gregorkofler.at ::: Landschafts- und Reisefotografie
http://web.gregorkofler.com ::: meine JS-Spielwiese
http://www.image2d.com ::: Bildagentur für den alpinen Raum
Sep 5 '08 #8
hj
On Sep 5, 5:02*am, mike_solomon <g...@solomontr ibe.co.ukwrote:
I have a button

<input type="submit" name="Delete" value="Delete">

This code can not be changed

I want to use Javascript to change the type

I tried:

document.Detail View.Delete.typ e='button'

This works perfectly in Firefox

But in IE I get the error

Error: Could not get the type property. This command is not supported

How can I do this in a way that works in IE
Just an FYI (the solutions in following posts were spot-on):

My guess is that IE doesn't *itself* implement any of the form
elements,
such as button, input, select, etc. Rather, it uses the underlying
Windows
controls. Those Windows control elements are immutable, so once you've
defined it in IE (by giving it a type and a name), you can't just
change
it to a different type of control simply by changing a property value.

At the time I was studying this, the rumor was that MS was considering
using browser-specific controls, rather than native Windows controls,
for
at least some such elements. But I don't know what happened with that.

This is a total pita -- if you need to change an element from one type
to
another, you need to create a new element, duplicate all the important
properties of the original, like name, id, classes and events, and
then
replace the original with the duplicate. Depending on the complexity
of
your application, this can be a *lot* more difficult than simply
changing
a single property on the original.

--

hj
Sep 6 '08 #9

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

Similar topics

2
3411
by: Bill S. | last post by:
Hi, I am just starting to work with ASP, so bear that in mind... I have an ASP page that displays records from a table, and allows you to add, update and delete. There is a form with one button that does adds and updates, and a second button for deletes. What I want to do is, instead of having the 'action' of the
1
6434
by: Veverita | last post by:
Hi there I'm hoping that someone can help me with a question I have about javascript syntax. I got an html page that uploads an image and some text field to a database. What I'd like to do is modify the content of one of the textfields prior to it being submitted to the database. Specifically, I need to
4
4763
by: Federico Bari | last post by:
Good morning all from italy, i have probably a compatibility problem with a html/javascript page. The aim of the code of the file test.htm you find here following (copy the 3 files in the same directory) is to change the content of a layer, created with the <div...> tag, with an external text (clicking over an hiperlink) or with the result of a <form...> submition. The solution (I haven't been able to find anyone else) is to use a...
6
2726
by: Shaun Fleming | last post by:
I've been trying to make this simple script compatible across various browsers. It works for IE 6.0 and NS 7 but doesnt work with Opera (I have version 7.11). This is what is supposed to happen: when the user clicks a button in the main window, a dialog window pops up. In the dialog the user enters a university to search for. When the string is submitted, the dialog then shows all the matches found in the database. The user picks one and...
6
6097
by: mike | last post by:
I have a page that uses a some javascript and it works fine in IE but fails to work in Firefox. Basically what I'm trying to do is have 3 iframes on a page but only displaying one of them at a time. A button is displayed for the two iframes that are not displayed and when the button is clicked, the corresponding iframe is shown and the other two are closed and buttons for the closed iframes are then displayed. Firefox says basically...
7
1640
by: iulian.ilea | last post by:
Hello, I have this: <input name="fileUpload" type="file" class="subtitle" title="GOGOGO" /> In entire application I have buttons customized. The button that appears with <input type="file"... /is a standard button. How can I customize it? To be, let's say, coloured in green, orange, or any other color...
3
1643
by: Mr. Roper | last post by:
I'm pretty weak when it comes to Java script, hopefully someone will take mercy on my sole and explain this to me. How come on the following HTML page, when I have my first script tag commented out, my button calls my OnClick function. However if I uncomment the first script tag, I get the following error: Button1_onclick is not defined <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">...
2
3156
by: sorobor | last post by:
dear sir .. i am using cakephp freamwork ..By the way i m begener in php and javascript .. My probs r bellow I made a javascript calender ..there is a close button ..when i press close button then the calender gone actually i want if i click outside off the calender then it should me removed ..How kan i do this ... Pls inform me as early as possible .. I am waiting for ur quick replay ...Here i attached the source code .... <!DOCTYPE...
2
3770
by: GuruPrasadBytes | last post by:
I am opened window.open(child.aspx page) from the parent.aspx file the below code is from parent.aspx, <HTML> <HEAD> ...... </HEAD> <body onload="loadXML();"> ..... <input id="AddSecurityBtn" type="button" runat="server" onclick='javascript: Args = objDoc.selectSingleNode('//Books'); Args = buildBookTable ; Args =null; window.open('child.aspx','800','900');' value="Add Books" />
0
8923
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8763
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9428
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9285
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9203
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8155
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
4796
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3238
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 we have to send another system
2
2686
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.