Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Web Programming > JavaScript > Javascript
Password Reminder
Register
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old September 5th, 2006, 01:32 PM
Val Val is offline
Registered User
 
Join Date: Sep 2006
Location: , , .
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>
</form>

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>
</form>

<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");
oInput.onclick="alert('ok-3')";
oInput.id=str;
oInput.name=str;
oForm.appendChild(oInput);
}// end of writeline(str)

</script>

Any ideas?


Reply With Quote
  #2 (permalink)  
Old September 6th, 2006, 02:55 AM
joefawcett's Avatar
Wrox Author
Points: 9,763, Level: 42
Points: 9,763, Level: 42 Points: 9,763, Level: 42 Points: 9,763, Level: 42
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Exeter, , United Kingdom.
Posts: 3,074
Thanks: 1
Thanked 38 Times in 37 Posts
Default

Try
Code:
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)
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


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



All times are GMT -4. The time now is 04:09 PM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.