Hi,
I am doing the following in a javascript function: -
var hiddenElement = document.createElement("input");
-
hiddenElement .setAttribute("type", "hidden");
-
hiddenElement .setAttribute("name", ""hiddenElement");
-
hiddenElement .setAttribute("id", "hiddenElement");
-
hiddenElement .setAttribute("value", x.value);
-
forms[formCount].appendChild(hiddenElement );
-
I want to create this hidden input element in the parent form from where contol passes to this javascript function.
This is not working. Please help!
Thanks!
5 13430 gits 5,390
Recognized Expert Moderator Expert
hi ...
welcome to TSDN ...
as you can see, after i have applied the code-tags for you, we may notice the syntax-error in line 3. very easy (that will give you an js-error) ... there you have an error with the quotes ... fix it and it should work ...
when using the code tags you may find such simple errors very fast ... during developement you may also use firefox and the firebug extension locally that gives you a lot of hints on such errors when you try to execute the code ...
kind regards
hi!!
Thanks for the reply! I modified parts of the code and have made some progress...
Now my problem is this..
I have a parent form from where the control has passed to a pop-up. Now is the JSP of the pop-up, I have a javascript which, based on some criteria, creates hidden elements in the parent form. How do i do that???
This is what i am doing in the pop-up... -
var hiddenId = window.opener.document.getElementById(id).createElement("input");
-
hiddenId.setAttribute("type", "hidden");
-
hiddenId.setAttribute("name", "hiddenId");
-
hiddenId.setAttribute("id", hiddenId);
-
hiddenId.setAttribute("value", value);
-
window.opener.document.getElementById(id).appendChild(hiddenId);
-
But this is giving me error in the first line -
var hiddenId = window.opener.document.getElementById(id).createElement("input");
This line is not working in the first place.. I want to create the hidden element in the parent form and not in this form.
Kindly help!!
Thanks!
gits 5,390
Recognized Expert Moderator Expert
hi ...
you have to create your node in the document first and you append it to the form ... so simply remove the 'getElementById (id)' from your first line ...
kind regards
thanks!
i did that.. It is creating the hidden element but it is not appending to the form
I can't seem to append the child to the parent form, from a pop-up JSP page which has this javascript function..
Is it not possible to append to a parent form?
Please help..
gits 5,390
Recognized Expert Moderator Expert
i tested it ... it is working (assuming id, value are correct) but, have a close look at your code ... i missed that too: - hiddenId.setAttribute("id", hiddenId);
you assign a node to the id ... don't do it ;)
and to prove that it is working ... set the type to 'text' ... so you may see the appended field appearing in your parent document
kind regards
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: Matt Herson |
last post by:
I have been trying to find a way to use JavaScript to change the value of a
hidden field on submit. I am already invoking a JavaScript to handle the
validation on submit.
The reason I need to change this field is some of the forms have two buttons
on them, each needs to process the form differently. If I can change the
value of the hidden field dynamically it will solve my issue as I can run
each against a diffent cgi.
Currently my...
|
by: Raghuram Banda |
last post by:
Hi All,
Can any one help me how to create a HIDDEN element using JavaScript
(DOM) dynamically
The following codes works fine with IE but not in Netscape
currentElement = document.createElement("input");
currentElement.setAttribute("type", "hidden");
currentElement.setAttribute("name", "hiddenName");
currentElement.setAttribute("id", "hiddenName");
|
by: yurps |
last post by:
Hello here is my html, if you click the missing image in the first
column on the left, the div is shown, when clicked again the div
disappears...but the bottom border disappears as well...Is there anyway
to stop this...???
<HTML>
<HEAD>
<title>Conform Inbox</title>
<meta content="False" name="vs_snapToGrid">
|
by: Randell D. |
last post by:
Folks,
I have a large amount of values to store (we're talking tens, if not
hundreds of bytes). I need this for a client side application - ignore
the security consequences for the moment - however my question is, which
is more performance effective, or easier on a clients resources?
I mean - if I have several <input type=hidden> tags with my values that
I can reference, would this have a greater overhead then, for example,
having an...
|
by: Geoff Cox |
last post by:
Hello,
How do I create a form without using document.write() which opens a
new window?
I imagine it has to do with using a <SPAN ID='idvalue' etc element and
document.getElementById("idvalue").innerHTML but not clear how to do
it...
This is how I have done it at the moment ...
| |
by: Phil Powell |
last post by:
Requirement is to refresh a page in the form of a continual form
submittal (for server-side validation and action)
Here is the Javascript I came up with that I thought would do that:
<script type="text/javascript">
function generateForm() {
document.forms.elements.name = 'username';
document.forms.elements.type = 'hidden';
document.forms.elements.value = 'ppowell'
|
by: Bill Steele |
last post by:
I want to have a window pop up with a form. When the form is submitted,
it needs to pass along the URL of the original window. If find on th
web eight gazillion descriptions of how to pass data from one page to
another via hidden fields, but not a word about how to pass that data a
second time.
I find that
<SCRIPT LANGUAGE="JavaScript"><!--
document.write(document.referrer);
|
by: Bosconian |
last post by:
I've been fighting with this for an hour.
My form contains a hidden input with the value initially set to "".
When a user clicks on the link, a function is called that updates the hidden
form value and submits the form.
Unfortunately this generates an error which states the form object is
undefined.
|
by: newbie |
last post by:
i have a form in which a hidden field (initial value as '0', and my
javascript set it to '1' when an event is trigged).
In the same form, i have a reset field. But I realized that the hidden
field is not reset to '0' when i push the
reset button. If I simply change the node from
"<input type="hidden" id='IsChanged' value='0'>"
to
"<input type="text" id='IsChanged' value='0'>"
Everything is working as expected (the value is reset to '0'...
|
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: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
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: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
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.
| |