473,727 Members | 2,046 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

I generate a FORM by js,but i can't input anything?

21 function js_reply_msg(no de,g_id,u_id,pa r_id)
22 {
23 node.innerHTML= "<FORM><TEXTARE A
name=\"msg_con\ "><\/TEXTAREA><br><I NPUT type=\"submit\"
value=\"reply\" ><\/FORM>"
24 node.nextSiblin g.nextSibling.i nnerHTML=""
25 }

My thought is that when i clicked a link,the js function generate the
Form,then get the input and deal with it.
But now ,i generate the FORM,but can't input anything:
when i press the mouse left button,i can input;if i don't ,i can't

Can anyone help me?Thank you

Aug 10 '06 #1
1 1754
firenet wrote:
21 function js_reply_msg(no de,g_id,u_id,pa r_id)
22 {
Don't include line numbers in posted code, indent code properly using 2
or 4 spaces and manually wrap it at about 70 characters to help prevent

23 node.innerHTML= "<FORM><TEXTARE A
name=\"msg_con\ "><\/TEXTAREA><br><I NPUT type=\"submit\"
value=\"reply\" ><\/FORM>"
Allowing uncontrolled addition of line breaks will usually add more
errors to your code - manually wrap it.

You can nest double-quotes inside single-quotes and vice versa, ensure
that you insert valid HTML:

node.innerHTML = '<FORM action=""><div> '
+ '<TEXTAREA name="msg_con"> </TEXTAREA>'
+ '<br><INPUT type="submit" value="reply">'
+ '</div></FORM>';

That snippet, on its own, seems to 'work' just fine in IE and Firefox.

24 node.nextSiblin g.nextSibling.i nnerHTML=""
This line is meaningless in the context of the code snippet you have
posted and causes an error if I just try to run your code in a test
page. Ensure that posted code runs when copy/pasted into a test page
and doesn't display spurious messages.

Blindly navigating down the DOM tree using nextSibling is likely to
cause problems because some browsers will insert extra nodes for
whitespace, others won't. There may be more (or fewer) nodes between
siblings than you expect. You must test the nodes to see if you've
found what you expect, and deal with it if you don't.

25 }

My thought is that when i clicked a link,
What link? You haven't shown any link, or how the function is called.
If you are using an A element and javascript pseudo-protocol, that may
be your issue.
the js function generate the
Form,then get the input and deal with it.
But now ,i generate the FORM,but can't input anything:
Please use proper punctuation, this isn't a chat session.
Capitalisation is important, I shouldn't have to wonder when you've
made a typing error and when you're just being cute..

when i press the mouse left button,i can input;if i don't ,i can't
So the form generates OK, but you have to click in it to give it focus
before entering any text - that is exactly how form controls work. If
you want to create the form and put focus on it, you are better off to
use DOM, then use the textarea's focus method, e.g.

<title>Reply message textarea</title>
<script type="text/javascript">

function addReplyMsg(nod e)
if (!node || !document.creat eElement) return;

function addEl(parent, tagName, elType){
var t = document.create Element(tagName );
if (typeof elType == 'string' && elType.length){
t.type = elType;
parent.appendCh ild(t);
return t;

var oForm = addEl(node, 'form');
oForm.action="" ;
var oDiv = addEl(oForm, 'div');
var oTA = addEl(oDiv, 'textarea');
oTA.name = 'msg_con';
addEl(oDiv, 'br');
var oSub = addEl(oDiv, 'input', 'submit');
oSub.value = 'Reply';
if (oTA.focus) oTA.focus();


<input type="button" value="Add"
onclick="addRep lyMsg(document. getElementById( 'xx'));">
<div id="xx"></div>

Aug 10 '06 #2

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

Similar topics

by: Richard Gregory | last post by:
Hi, I have the wsdl below, for an Axis web service, and when I select Add Web Refernce in Visual Studio the proxy is missing a class representing the returnedElementsType (see reference.cs below the wsdl). This complex type is a collection of another complex type(elementType), and the Reference.cs has an array of these rather than the single returnedElementsType. If If I want to be able to obtain these elements from the SOAP response I...
by: ward | last post by:
Greetings. Ok, I admit it, I bit off a bit more than I can chew. I need to complete this "Generate Report" page for my employer and I'm a little over my head. I could use some additional assistance. I say additional because I've already had help which is greatly appreciated. I do try to take the time and understand the provided script in hopes on not having to trouble others on those. But here it goes...
by: wendallsan | last post by:
Hi all, I know that this should be an easy thing, but I haven't figured out how to get this to work on my server at home. I have a roommate who is using PHPBB on his site on the server and that is able to send out e-mails no problem. I have created a simple form that sends data to a php page that then gets the data and then should send it out using the send() function. What is going on in actuality is that upon submitting the html form,...
by: Slickuser | last post by:
From my PHP page: Grab all data from the database. Go through a loop to generate the HTML. Client side: From the Color drop menu list, if a user change the value. It will grab that value & update to the database based on the hidden ID. DELETE ALL will delete everything the databse.
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...
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,...
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...
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...
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...
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
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.