Solved

How to get pointer to a DHTML created element in MSHTML???

Posted on 2004-10-03
7
263 Views
Last Modified: 2013-11-19
Hi,
I have a web page that creates an input box when clicked on the cell of a table. THe html is like this:

<table><tr><td><span id='mytag' onclick='myfunc(this')/>
</td></tr></table>

<script language='javasript'>
function myfunc(element)
{
    element.parentElement.innerHTML="<input id='mytag'></input>";
}


This creates the input element when I click on the span tag. Now what I want is to access this input element from MSHTML.
I have a window in which I have embedded a browser control. When I load the page in the browser, obviously  there is no input element, so I cant access it. But after I have clicked on the span tag, the input element is created. calling get_document->get_all->item("mytag"), doesnt return pointer to the DHTML created input element. I go on getting the pointer to the span tag.

What should I do to get pointer to the Input tag that got created as a result of onclick event??

Thanks in advance,
Sarah.
0
Comment
Question by:sarah81
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
7 Comments
 
LVL 10

Expert Comment

by:Havin_it
ID: 12215717
Not sure if this alone will solve your problem, but in your code above, the span and the dynamically-created input have the same ID. That's gonna cause problems...
0
 

Accepted Solution

by:
texascatch earned 50 total points
ID: 12294757
Sarah,

In effect, having duplicate id's will cause you problems. The id should be unique throughout the scope of the current document. If a document contains more than one object with the same identifier, the objects are exposed as a collection that can be referenced only in ordinal position.

Im enclosing your example with a few changes. When the page loads you will receive the span object. Once the input text is created click on it to get an alert message with the input object.

Hope this helps,
Texascatch

<html>
<body>
<table border=1 width=100%>
<tr>
<td><span style='border:1px solid red; width:100px; heigth:100px' id='mySpan' onclick='myfunc(this)'></span>
</td>
</tr>
</table>

<script>
function myfunc(element)
{
    element.parentElement.innerHTML="<input id='myInput' onclick='msg()'></input>";
}
alert(document.getElementById("mySpan").tagName);
function msg(){
alert(document.getElementById("myInput").tagName);
}
</script>
</html>
0
 
LVL 1

Author Comment

by:sarah81
ID: 12294855
no the problem here is that the HTML must have both span and input tags with the same name, else there is no way to recognize the new input box.

may be this wasnt the right place to post this question but i didnt find any topic area where i could post questions related to MSHTML.

and yeah u r right, 2 elements with same name can be accessed thru a collecton and thats what i have done.

so well my prob is solved. thanks for ur help anyways.

i cant give u all points for this, but i will give a few to texascatch if there is some way to give some points. is there?
0
 

Expert Comment

by:texascatch
ID: 12294889
http://www.experts-exchange.com/help.jsp#hi19
this talks about the points..im new here..thank you
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
TypeError jquery issues with site - CSS conflicts 3 47
Presenting my portfolio on the web? 11 53
Pass a js value to an html form 5 43
CSS styling problem 3 28
This article explains how to prepare an HTML email signature template file containing dynamic placeholders for users' Azure AD data. Furthermore, it explains how to use this file to remotely set up a department-wide email signature policy in Office …
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
The viewer will the learn the benefit of plain text editors and code an HTML5 based template for use in further tutorials.
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

710 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question