As part of a response I create a form. When the user clicks one
of two buttons I invoke a javascript function:
<input type="button" name="submit" value="Update" onclick="javascript:saveItem()"/>
here is the top of that function----------------
function saveItem () { // save updated Item - from itemsToEdit
alert ("saveItem - entering 208")
alert ("saveItem - " + document.getElementById("EditItemsForm");
The problem is that returns null, as if the form did not exist,
but inspection of the source shows it present.
I presume the problem is that the form has not been created when
the .js is evaluated even though it is there by the time it is
executed.
I have many similar functions that work fine but this is the only
one that references a form created on the fly.
The apparent solution is to move the form definition to a static
part of the script but I don't know how to reference it so that
it appears when the onclick event happens.
--bill
Either the needed element has the wrong ID, or is served within an IFRAME.
On Sat, 18 Sep 2021 22:40:48 +0700, JJ wrote:
Either the needed element has the wrong ID, or is served within an IFRAME.
Or is within a Shadow DOM.
On Sat, 18 Sep 2021 22:40:48 +0700, JJ wrote:within an IFRAME.
Either the needed element has the wrong ID, or is served
Or is within a Shadow DOM.
If I change the EditItemsForm to another element that is not
dynamically generated it does not fail; it returns the id.
Sysop: | Keyop |
---|---|
Location: | Huddersfield, West Yorkshire, UK |
Users: | 376 |
Nodes: | 16 (2 / 14) |
Uptime: | 27:36:59 |
Calls: | 8,036 |
Files: | 13,034 |
Messages: | 5,829,514 |