I'm looping thru all the document form elements with the below loop. While looping I would like to know if this element is from the second table in the form. My issue is the table has no name. How can I know if I'm dealing with an element that is in the second table of the form?
Code:
var field = document.forms['ovrFrm'].elements;
for (i = 0; i < field.length; i++) {
//DO SOMETHING HERE
}
Using DOM in IE 5.5 I'm dynamically building table rows containing HTML input elements (checkboxes, text boxes, etc.), one element per TD. Note that these rows are clones - all the element id's for a given element are the same across rows.
Now, For certain things I need to reference two or more elements in the same row. For example, if I check this checkbox I want to enable that text box.
When I click a checkbox I know what it's parent is (the specific TD) and the grandparent (the specific row).
My current effort has me grabbing the table row where the click event happend then, using a pair of nested loops searching for the specific field I want. It works, but it looks like overkill to me. There's gotta be a more elegant way. I don't want to search through all the childNodes when I know which field I want, and it has an id unique to that row.
Can I reference things by their id? In other words I want to say something like this: thisRow = variable reference to the TR object containing the clicked-on element.
thisRow.theTDid.theCheckBox'sId.checked = false;
or at worst: thisRow.getElementById("theTDid").getElementById("theCheckBoxId").checked = false;
These don't work but what would? I want to avoid blindly iterating through all the TR's childNodes inside a loop going through all the TD's childNotes, looking for a specific data entry element.
I'm trying to do the following: i have a page that is displayed inside an IFRAME. I'll refer to this as the "inner page". there are some hyperlinks in the inner page that refer to the main page where the IFRAME is hosted. I would like to be able to populate a text box in the main page (called txtSC) by clicking on the hyperlink in the inner page. my code on the inner page looks like:
And in the main page, I have the ElementContent function defined as follows:
function ElementContent(idA,contentA,idB, contentB, expression)[code]....
I'm getting an error when i click on the hyperlink that an "object is required".Is this because the function ElementContent needs to be created on the inner page? And how do i reference the controls on the main page?
My application uses Web pages whose grid is defined by several tables. I noticed a funny behavior on IE and Firefox which is giving me pains.
Apparently, when the browser renders a <table> tag and before it reaches the </table> end tag, any document.write actions in Javascript get deferred execution till closure of table instead of occuring at runtime as they are parsed. Code:
I have this script that will read all the headers (h1-h6) in your HTML document and also HTML comment tags which are specially recognized, and it will create an HTML document "table of contents" (or outline) and insert it as a DIV within the document. This is for people with ESPECIALLY LONG HTML documents...it makes sense for this purpose.
The script is attached to this post in a zip. The zip archive has four JS files. 'htmlTOCgenerator.js' has all the meat of getting the nodes and generating the DOM nodes for the ToC. The other three have 'support' functions and are included. The 'colorContrasting.js' file is actually supposed to compute 'complementary' colors from random color generation. Why? Refresh the document each time, and the ToC has a different foreground (text) and background color, that's why. Breaks up the monotony. A large comment block inside 'htmlTOCgenerator.js' tells the document maker how to set up the HTML document for making this work.
In a first version, this script inserted the ToC ('table of contents') at the top of the document where the HTML comment tag "<!-- putTOChere -->" was placed/found.
Then I decided it was better to place the ToC DIV element to the left of the text, in a fixed block (does not scroll with text). The ToC DIV contents themselves are scrollable in case the contents would go beneath the bottom of the client window height--can't have that.
Click here to see an example of how it works:
I am having problems with it though.
1. The scrollbar on the ToC block always shows, even if the contents don't fill up the block. The CSS is set for 'overflow-y:scroll' but that does not mean the scrollbar does not show if there is no overflow. It would be nice to control that. Still have not figured it out.
For an example of not enough headers to fill out the height-specified (by necessity) fixed DIV block, see this page.
2. In my documents, the main body of text is all wrapped in a DIV with its right- and left-margins set to 'auto', so that when user widens or narrows the client window, the text is always centered. I need to stop the main body text from running behind the TOC during a narrowing of the client window. I thought setting the right margin of the ToC DIV should stop that. Anyway, that is a CSS styling problem, I suppose, although the CSS must be set through script (I do through script since the instructions don't require the document maker to set up CSS: too many instructions become annoying for anyone wanting utility in the script). And if you think frames are answer, that complicates matters and I believe it gets away from the eventuality when frames are deprecated.
3. I also want criticism on how to make this presentation/structuring/interaction of the ToC block better or workable.
Suppose a HTML document has a iframe. Using javascript,I want to detect ,on load of the html document, whether the body of the iframe document is ready to be displayed.I want to be able to overwrite the the body contents (before it actullay loads) of the iframe.can I do it with jquery? say if ,HTML doc is
Normally an SVG document is loaded/parsed/interpreted inside an HTML document using an 'object' (or 'embed') element, although there are supposedly other ways too. The problem is, the SVG document must be static this way.
I want to use the DOM interface to build SVG dynamically inside an HTML document. I am guessing I can build it inside HTML within an 'object' (or maybe 'iframe'?) element.
My intentions/goals:
In Javascript, I construct an object 'embedSVG' which has properties and methods for creating valid SVG elements and setting their attributes and attribute values.
During construction, the SVG document is created with its root element. During debugging in FF 2.0 (I'll work on an MSIE-compatible format later), I am using the Mozilla DOM Inspector and comparing nodes when the 'object' element is loading a valid external SVG document, and when I am appending the child representing the SVG document created by the DOM functions.
However the child node (#document) does not specify 'svg' as the root element, but instead 'HTML'. Something is not working.
Here is the relevant code in 'ScriptTest.html' which is the HTML in which the SVG is supposed to be embedded. Below it is the relevant code for 'svglib.js' which is supposed to contain code for building the SVG dynamically.
What this code is supposed to do is load the HTML page and execute the anonymous script, and draw a navy blue-bordered yellow rectangle on a blank page. This is similar to the example in the SVG 1.1 W3C Recommendation on page 202 of the 719-page PDF.
I am getting an exception when embedSVG object placeInHTML() method is called: NS_ERROR_DOM_HIERARCHY_REQUEST_ERR. I find in DOM Inspector in spite of or after the exception that a document is placed as a child of the object element, but it is HTML, with a default 'head', 'title', 'body' elements placed.
Determine what the previous page was that the user was viewing, even if the user arrived at my site by through the use of a browser function (history, location bar, refresh, etc.). Is this possible?
I'm not wuite sure how document.history functions - what degree of privacy is given to the user and to what extent can web pages get URLs from the user's history?
I am trying to make a function run if the mouse is moved over the document but when using the object onmousemove it seems to run the code even if the mouse is still over then document, how can I make it so if the mouse is over the document but isn't moving then don't run the code but once the mouse moves run the code? This is the code I made to handle the mouse move collections.
[Code]..
But with this code it runs even when the user doesn't move their mouse and the notification box pops up every second as the code seems to think a still mouse is a moving mouse.
I was thinking about having a run once system but that would mean if the mouse moves it runs once and then if the mouse moves again the code will not run as it has already ran before.
This code does not working in Mozilla. Works fine in IE. -------------- <input type=text value=100 name=textbox> <script> alert(textbox); </script> -------------- This perhaps, because of Microsoft policy to globalize all tag names. Is there any method for cross-browser fix without using getelementbyid? Is there any method to pass values from outside of <script>, inside? (something like "global" in php functions) Javascript must be kept inside <script> tag.
i'm wondering how i can get a reference to the next td in a row? Do i need to assign all td's an id or something? i could do that failry easily because the table gets generated dynamically via a php function.. i just hink this would be nice that way when i go to delete something (with those infamous checkboxes) i would like the javascript prompt to display what it is that will be deleted..
I want to switch a big function from a document.onkeydown = function to a document.onkeypress = function, or vice versa depeding on the type of browser.
However it is quite a big function so it's pretty much out of the question to have it appear in full twice.
Any ideas how to change the target event (onkeydown/onkeypress) without writing the whole function twice?
I am working on creating a document where you check a bunch of checkboxes to select what to include, then click on a button. A function then opens a new window and writes the HTML code to run scripts in .js files to populate the page. Code:
I have been searching for a way to trap changes done to the document object (mainly by the function document.write();).
Example of code that doesn't work:
function myFunction() { ed.document.onchange = doFunction(document.body.innerHTML); ed.document.open(); ed.document.write('Hello'); ed.document.close(); }
function do_function(body) { alert(body); }
It only fires when the page loads, not when I change the text. You are free to use any event that works, but i think onchange was the one to fit this problem. The alert will write the initialpage, but will never write the tekst 'Hello' that is the new change.
Any javagurus out there know a solution to pick up any fired events triggered by document.write();
I am trying to write a bunch of text onto a new document using document.write() and somehow need to format it to include line breaks.
For example: Code JavaScript: document.write(Line 1); document.write(Line 2);
I have tried including and it does not work. I have also tried document.writeln() and that also does not work. From what I have found on the Internet, one (if not both) of those methods should have worked.
I need to do a function in javascript to check or uncheck all checkboxes with the same id. I want this function to work in every form and every page of my site, as I will use the same id ("sel") for all checkboxes in the site. So I need to refer to these by id. Code:
I have a form that appears several times on a page, and would rather not assign IDs. Is there a way to have my validation function focus() a text input without IDs?
i have this code:if (! $_POST["Name"] || ! $_POST["LName"] || ! $_POST["email"] || ! $_POST["phone"]) { $Alert_Message = "Invalid Form"; }i got a js script from another forum here on this site that looks like this, and does work well:print <<<JSOUT <script type="text/javascript"> confirm("Form is INVALID");
[Code]...
exit;i have 4 different messages that i want to choose from to be displayed in the js script, and I want to store the message that i want to use in a PHP variable along the way. the variable is: $Alert_Message . i am trying to do this with my confirm() function in js:confirm($Alert_Message);the code is not registering, so something is obviously wrong. can i reference PHP this way in a js script? if not, how would i go about doing this another way? can i change a js variable along the way in my PHP code instead, and then reference THAT variable when i get to my js script?
We're in the process of re-writing the Intranet at work, and my javascript knowledge could be written on the back of a post card. ;-)
Can any of you point me in the direction of some code that would enable a form to open a specific pdf file? Details are below.
-------------------- All of our purchase orders are saved back to pdf files. Each pdf has the prefix "PO_" followed by the po reference, then the file extension ".pdf". For example, our file would be called "PO_12345M.pdf". Each set of files is archived into years (folders are called 2003, 2004, 2005 etc.) so it will probably need a drop down box to select year, unless it can search through all the folders.
The visitor should only need to enter the PO reference, and the code puts the "PO_" and the ".pdf" on the end of it, and hey presto Acrobat opens with the PO, or you get an error dialog if the file cannot be found. --------------------
Since a few years I make use of an online service which provides me statistics about visits to my web site. The only thing I have to do is to include a few lines of Javascript in the most important page. The company providing this service - Nedstat - has been acquired by a more commercial party called Webstats4U and they have now decided to cause a popup window to appear with a commercial message, every new day you start up the page. Given the nature of the web page, this is unacceptable. Does anybody know how to check whether a window has been opened from a page and - if so - how to get a reference to that popup window so that I can close it?
Example: I have an aspx page with several fields and a grid. When I click on the grid i use js to poulate the form layout. I have maybe 15 different forms each with a different table. I have a lot of common js code that I put in a separate file.
I have a function in that file that needs t obe specific to each webform because the data is different. so in the separate js file from a common function I want to call PopulateSpecificForm(DataRow) and put that method in each webform. It doesnt work? any ideas?
I'm working on an asp.net site and am trying to implement a popup help window. I want the window to close when the user advances to the next page in our application. The thing is, I'm doing this on a component basis and I don't have access to the body tag from within my help component, so I can't add the onunload tag. Is there some other way of achieving what I want? Can I add an eventhandler to the body tag through javascript?
I am writing a validation function: what I want to do when an error is detected is to open a second window containing error messages. The form being validated is rather long, and there are several points in the code where I write the messages. So, I would like to have a separate function just to open the second window with an appropriate title (something like "the following errors were detected in your form"). something labout like this: