473,699 Members | 2,834 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How do I change HTML element: show "input" instead of "a"?

2 New Member
Hello!

I would like to switch elements on the fly.
Dynamicly turn "A" elenent an "input" tag.

This is what I tried:

Expand|Select|Wrap|Line Numbers
  1. <html>
  2. <head>
  3. <script>
  4. function insertTableRow(ref, arg)
  5.     var whichID = ref.parentNode.id;
  6.  
  7.     if (arg=='header'){
  8.         document.getElementById(whichID).Element='input';
  9. //        document.getElementById(whichID).class='prodDesc';
  10.         document.getElementById(whichID).style.display='';
  11.         document.getElementById(whichID).TYPE='text';
  12.         document.getElementById(whichID).NAME='descriptionHeader';
  13.         document.getElementById(whichID).VALUE='new Header Content';
  14.     }
  15. }
  16. </script>
  17. </head>
  18. <body>
  19. <span id="menuoutline">incert in table: 
  20.             <a id="menuoutlineAHeader" href="#" onclick="insertTableRow(this, 'header')">header</a>
  21.             </span><BR>
  22. </body>
Could you please help make it work?
Jul 23 '07 #1
4 1651
pbmods
5,821 Recognized Expert Expert
Heya, Apple1. Welcome to TSDN!

Instead of giving yourself massive headaches, simply add an INPUT with style="display: none;" to your HTML manually, then make insertTableRow( ) make the A invisible and the INPUT visible.
Jul 24 '07 #2
gits
5,390 Recognized Expert Moderator Expert
Yes ... that would be my recommendation too ;) ... however: in case you want the replacement ... you may play with the replaceChild()-method to achieve your goal ...

kind regards
Jul 24 '07 #3
Apple1
2 New Member
Thanks guys!

I had to leave my city for a couple of days. Your first advice was really helpful. Actually, I tried the second too, but it seemed to be way too complex for me (you were right).

Thanks again!
Aug 1 '07 #4
pbmods
5,821 Recognized Expert Expert
Heya, Apple.

Glad to hear you got it working! Good luck with your project, and if you ever need anything, post back anytime :)
Aug 1 '07 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

8
1911
by: b83503104 | last post by:
Hi, I want to accept the user's answer yes or no. If I do this: answer = input('y or n?') and type y on the keyboard, python complains Traceback (most recent call last):
11
4168
by: Pete Wilson | last post by:
Hi folks -- The page at http://www.pwilson.net/submit-demo.html will not validate. The validator at http://validator.w3.org tells me I can't have an input inside a form. Would some kind soul please tell me what I'm doing wrong?
3
3758
by: Jonathan | last post by:
Hi all: I originally posted this in an HTML forum, but have realized that the solution may (a) require a server-side change or (b) be non-existent. In any case, since the page I'm dealing with is a PHP page and the problem has to do with an auto-inserted "input" element, I'll post it here, too. I'd appreciate any advice, commentary, or even pessimistic sympathy if I'm just SOL. - Thanks. I am pasting some code below that I am having a...
0
25854
by: phmyhn | last post by:
I have two web pages, one is viewlarger.aspx, another one is shoppingcart.aspx. On the viewlarger.aspx, when clicking "add to cart" image button, the sub appends the id (passed from another page from a hyperlink column) into a session. the code is as following: Private Sub ibtAddtoCart_Click(ByVal sender As System.Object, ByVal e As System.Web.UI.ImageClickEventArgs) Handles ibtAddtoCart.Click idStr = Session("ids") pid =...
1
4234
by: Arvind P Rangan | last post by:
Hi All, You must have used <input type="file"> in HTML very often. Is there any object or example done on this, other than using a text box and a button which will open with Directory Object. Give me example of links where i can find needed information. Thanks Regards Arvind P Rangan
1
2662
by: k386 | last post by:
I am having trouble creating a hidden form field, or least having it accessible from getElementById. Rough overview: I am reading an XML file through XMLhttpRequest and outputting each item into a unique div tag, which has a dynamically generated name, then appending each div tag to an existing div tag. This is working A-OK. Here's the problem: Basically so I can show a general section - ie. Bookmarks, Blog Posts, etc - then show or...
13
10387
by: Jen | last post by:
One user of my application is experiencing an exception "input string not in correct format". But it makes no sense where it is occurring. It is occurring when a string from a textbox ("172") is being convert to an Int16 (using Convert.ToInt16). How can that be? There are other text boxes that are used in the identical fashion and they don't generate the exception. All there are many other machines running my application that don't...
4
13301
by: Chris | last post by:
Hi, i 'm experimenting with postback and i tried that with a button server control and an Html input button but with runat="server". The button server control causes a postback, but not the Html input button with runat="server". Can someone explain me why (because it's running on the server)? Thanks
2
1552
by: =?ISO-2022-JP?B?GyRCJD8kKxsoQg==?= | last post by:
Hi everyone, I am developing the console which has the embedded Python interactive interpreter. So, I want to judge whether current command is complete or not. Below is good example to solve this problem. // // http://effbot.org/pyfaq/how-do-i-tell-incomplete-input-from-invalid-input.htm // int testcomplete(char *code)
0
8685
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
8612
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
9171
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...
1
8905
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
8880
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
5869
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4373
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4625
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
2008
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.