472,359 Members | 1,631 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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

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

21 function js_reply_msg(node,g_id,u_id,par_id)
22 {
23 node.innerHTML="<FORM><TEXTAREA
name=\"msg_con\"><\/TEXTAREA><br><INPUT type=\"submit\"
24 node.nextSibling.nextSibling.innerHTML=""
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 1621
firenet wrote:
21 function js_reply_msg(node,g_id,u_id,par_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><TEXTAREA
name=\"msg_con\"><\/TEXTAREA><br><INPUT type=\"submit\"
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.nextSibling.nextSibling.innerHTML=""
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(node)
if (!node || !document.createElement) return;

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

var oForm = addEl(node, 'form');
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="addReplyMsg(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...
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...
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...
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 &...
by: Naresh1 | last post by:
What is WebLogic Admin Training? WebLogic Admin Training is a specialized program designed to equip individuals with the skills and knowledge required to effectively administer and manage Oracle...
by: antdb | last post by:
Ⅰ. Advantage of AntDB: hyper-convergence + streaming processing engine In the overall architecture, a new "hyper-convergence" concept was proposed, which integrated multiple engines and...
by: WisdomUfot | last post by:
It's an interesting question you've got about how Gmail hides the HTTP referrer when a link in an email is clicked. While I don't have the specific technical details, Gmail likely implements measures...
by: Matthew3360 | last post by:
Hi, I have been trying to connect to a local host using php curl. But I am finding it hard to do this. I am doing the curl get request from my web server and have made sure to enable curl. I get a...
by: Oralloy | last post by:
Hello Folks, I am trying to hook up a CPU which I designed using SystemC to I/O pins on an FPGA. My problem (spelled failure) is with the synthesis of my design into a bitstream, not the C++...
by: Carina712 | last post by:
Setting background colors for Excel documents can help to improve the visual appeal of the document and make it easier to read and understand. Background colors can be used to highlight important...
by: BLUEPANDA | last post by:
At BluePanda Dev, we're passionate about building high-quality software and sharing our knowledge with the community. That's why we've created a SaaS starter kit that's not only easy to use but also...
by: Rahul1995seven | last post by:
Introduction: In the realm of programming languages, Python has emerged as a powerhouse. With its simplicity, versatility, and robustness, Python has gained popularity among beginners and experts...
by: Ricardo de Mila | last post by:
Dear people, good afternoon... I have a form in msAccess with lots of controls and a specific routine must be triggered if the mouse_down event happens in any control. Than I need to discover what...

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.