Wrox Programmer Forums
Javascript General Javascript discussions.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Javascript section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
Old September 5th, 2006, 01:32 PM
Val Val is offline
Registered User
Join Date: Sep 2006
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default dynamic <input> tag

I have a simple form:

<form id="form" action="#">
<input type="text" id="2" name="2" size="40" onclick="alert('ok-2')"></input>

and I want to create dynamically once more <input> tag inside this form.
My problem is - after creating tag, onclick method doesn't work.

So, what I did

<form id=form action="#">
<input type="text" id="2" name="2" size="40" onclick="alert('ok-2')"></input>

<input type=button onclick=javascipt:writeline("3") value="create tag input"> </input>

<script language="JavaScript" type="text/javascript">

function writeline(str) {
var oForm = document.getElementById("form");//
var oInput = document.createElement("input");
oInput.setAttribute("type", "text");
}// end of writeline(str)


Any ideas?

Old September 6th, 2006, 02:55 AM
joefawcett's Avatar
Wrox Author
Join Date: Jun 2003
Posts: 3,074
Thanks: 1
Thanked 38 Times in 37 Posts

oInput.onclick = function() {alert("ok-3");};
Be warned that version of IE before 6 won't submit the name of the button when posting. You probably don't need it anyway but if you do see: http://windowssdk.msdn.microsoft.com.../ms534184.aspx


Joe (Microsoft MVP - XML)

Similar Threads
Thread Thread Starter Forum Replies Last Post
<a> tag in XML sani723 XSLT 5 March 27th, 2007 04:16 AM
Problem with <span> tag tclotworthy XSLT 2 February 18th, 2007 03:48 PM
get displayed name of the <select> tag nikeshkm HTML Code Clinic 1 October 20th, 2006 11:21 PM
<Form> tag within <form> tag rit01 ASP.NET 2.0 Basics 3 April 23rd, 2006 08:12 AM
Dynamic HTML <<Events>> babloo81 Javascript 2 December 29th, 2003 12:40 PM

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.