473,385 Members | 1,780 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

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

2
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 1629
pbmods
5,821 Expert 4TB
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 Expert Mod 4TB
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
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 Expert 4TB
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
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
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...
3
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...
0
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...
1
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. ...
1
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...
13
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...
4
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...
2
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...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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...
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
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...

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.