473,804 Members | 2,111 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to get FORM values from an IFRAME ?

Pb with javascript.
I've a 'main.html' script containing an 'iframe.html' IFRAME.
The 'iframe.html' is containing a form.
My problem is that i'm unable to get form fields values. What's the
syntax ???

NB: the script has to be generic, because it has to work with any .html
(i may don't know form's name and iframe's name).

Thanks
=== MAIN.HTML ===

<html>
<head>
<meta name="generator " content="HTML Tidy, see www.w3.org">
<meta http-equiv="Content-Type" content="text/html; charset=Cp1252" >
<title>main</title>
</head>
<body>

<iframe name="pub" width="200" height="100" src="iframe.htm l">
</iframe>
<script language="Javas cript">

// HERE'S MY PROBLEM: IT DISPLAYS ANYTHING !!!
document.write( document.frames[0].document.forms[0].elements[0].value);

</script>

</body>
</html>
=== IFRAME.HTML ===

<html>

<head>
<meta http-equiv="Content-Type" content="text/html;
charset=iso-8859-1">
</head>
<body bgcolor="#fffff f" text="#000000" link="#0000ff" vlink="#800080"
alink="#ff0000" >

<form method="POST" action="x" name="formIFram e">
<input type="text" name="name2" value="value2">
<input type="submit" value="POST2">
</form>

</body>
</html>

Oct 2 '05 #1
8 13486


Ding dong!, frames[] collection is at the window level, not document,
including iframes, so, window.frames[0].

Danny
Oct 3 '05 #2
Sorry Danny, but i still got the problem

(...)
// HERE'S MY PROBLEM: IT DISPLAYS ANYTHING !!!
document.write( window.frames[0].document.forms[0].elements[0].value);
(...)

Djdave

Oct 3 '05 #3
djdave said the following on 10/3/2005 2:59 AM:
Sorry Danny, but i still got the problem
Ignore Danny, he seems to think that replying to nothing is the way to
post here, it's not. Please quote what you are replying to, this is
Usenet, not Email.
(...)
// HERE'S MY PROBLEM: IT DISPLAYS ANYTHING !!!
document.write( window.frames[0].document.forms[0].elements[0].value);


It won't be available until after the element in the form in the
document in the frame is loaded. In your sample code, it is trying to
access something that hasn't been loaded yet. Try changing it to the
onload event and alert it and see what you get.

--
Randy
comp.lang.javas cript FAQ - http://jibbering.com/faq & newsgroup weekly
Oct 3 '05 #4
Danny,

It works well when i've a form without iframe.

So, why it shouldn't when a form is insite a iframe ?

Furthermore, i need it works before the form is submitted.

Thanks.

Oct 3 '05 #5
Danny,
It works well when i've a form without iframe.
So, why it shouldn't when a form is inside a iframe ?
Furthermore, i need it works before the form is submitted.
Thanks.

Oct 3 '05 #6
djdave said the following on 10/3/2005 11:19 AM:
Danny,
This is Usenet, not Email.

Please quote what you are replying to.

It works well when i've a form without iframe.
So, why it shouldn't when a form is inside a iframe ?


Because your referencing is incorrect.

--
Randy
comp.lang.javas cript FAQ - http://jibbering.com/faq & newsgroup weekly
Answer: Not quoting at all.
Question: Whats worse than top-posting?
Answer:It destroys the order of the conversation
Question: Why?
Answer: Top-Posting.
Question: Whats the most annoying thing on Usenet?
Oct 3 '05 #7
Ok, but could you please tell me the referencing i've to use ?

(i'm javascript's beginner and my english isn't very good !!!)

Thanks for your help.

Oct 3 '05 #8
djdave said the following on 10/3/2005 12:47 PM:
Ok, but could you please tell me the referencing i've to use ?
You begin by quoting what you are replying to.

If you want to post a followup via groups.google.c om, don't use
the "Reply" link at the bottom of the article. Click on "show
options" at the top of the article, then click on the "Reply" at
the bottom of the article headers.
(i'm javascript's beginner and my english isn't very good !!!)


Nothing wrong with not being good in English.

Show a sample URL of a sample page that you can't get to work.
--
Randy
comp.lang.javas cript FAQ - http://jibbering.com/faq & newsgroup weekly
Oct 3 '05 #9

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

10
2122
by: Dave Karmens | last post by:
If I have say 10 fixed variables, how can I set their values = to that of a form that is built dynamically? column1 column2 email = formvalue(0) fname = formvalue(1) lname = formvalue(2) etc..
2
3431
by: Tim Chmielewski | last post by:
I have been trying to read values from a form into an array on a page without much success and was told to use a Scripting.Dictionary instead. There are a variable number of fields on the form as it is different according to which product is ordered (as are the fields that are used to create the record.) This is my first attempt: set OrderInfo = Server.CreateObject("scripting.dictionary") set OrderInfo("prodid") =...
1
6030
by: Randell D. | last post by:
HELP! I am determined to stick with this... I'm getting there... for those who haven't read my earlier posts, I'm createing what should be a simple function that I can call to check that required fields in a form have values. I'm writing the values to the client using document.write only so that I can confirm that the values are there to be played with - this is not the final result so please (unless it's leading to the script failure)...
1
2174
by: Miguel Dias Moura | last post by:
Hello, Can you help me out in making this work? What I want is as simple as sending form values to an email. The code I am using is the following:
4
1790
by: Miguel Dias Moura | last post by:
Hello, i created an ASP.net / VB page with a really big form. Now i want to create 4 pages and in each one i will place 1/4 of the big form. The last page will send all the form values by email. How can i send the form values from one page to the next one?
2
3194
by: KFactor | last post by:
Is it possible to pass form variables to a page on another server using response.redirect? Or is there a secure way of passing sensitive information from one site to another such as a userID? I would like to avoid using the querystring. This is what I would like to do: When a user clicks on the link, I need to add them to the database and then
1
3068
by: Anderh | last post by:
hi all, I have using iframe for call php file called , I wnat submit this form inside iframe from parent form in main page but I codnt make it. <input type="button" id="s" name="s" value="submit ID" onClick="javascript:submitPer();"> <iframe name="form11" src="perSearch.php" frameborder="0" width="680" height="150"></IFRAME><br> this is javascript function which should submit the form inside iframe function submitPer(){ ...
5
3209
by: jmartmem | last post by:
Greetings, I have built an Update Record Form in an ASP page. This form contains a number of fields, such as text boxes and menus, to name a few. Upon clicking the 'submit' button, I want the form values to pass to a confirmation page that shows the values entered and selected, with a CDONTS auto email generated at the same time. My problem is that I'm having trouble passing the values from the form to both the confirmation page and the...
3
3150
by: raaman rai | last post by:
Hi Fellas, i need to understand how to retain the submtted form values during an Edit/Update operation. When i add the information from a form, i retain the form values in the following way incase there is something missing or the values are incorrect. <input type="text" name="camount" tabindex="4" value="<?php echo $form->value("camount"); ?>" > When i edit this information i retrieve the value in the following manner <input...
0
9712
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10595
Oralloy
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...
0
10343
jinu1996
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...
1
10341
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,...
0
10089
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9171
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5530
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...
0
5673
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
3001
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.