473,699 Members | 2,300 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Gathering data from form fields within iFrames

Jon
All,

I'm currently working with a PHP-based CMS application, and am begining to
put the finishing touches on it via Javascript validation. Currently, I'm
using fairly standard methods of validation of each form field, the
algorithm is much like:

if(document.for mName.field.val ue == ""){
//throw an error and return false
}

This works great except for one particular field. I have a javascript-based
Rich Text Editor (RTE) that currently places the body of each page within an
iFrame. When the page loads, I populate a field within the iFrame that is a
textarea with data coming from the DB (MySQL). All works fine this way, and
when the user makes a change and clicks submit, I'm able to get that data
from the form and submit.

The problem comes up with two things - building a preview page, and
validating data within the field. The algorithm I'm using above will work
within the field, however it will only give me the ORIGINAL value of the
textarea field. If the user changes it, I'm simply unable to grab the NEW
value of the field. As all of my other field validation works fine, I'm
assuming this has something to do with the iFrame.

So, can anyone give me some info on how I can grab CURRENT values of a
textarea field within an iFrame? Currently, any changes made within the
textarea (inside the iFrame) simply are not recognized by normal javascript
Validation. I'm somewhat of a JS newb, but can work off any any algorithm -
so at this point, ANY help is appreciated. Thank you in advance.
Jan 25 '06 #1
2 2337
Jon wrote:
if(document.for mName.field.val ue == ""){
//throw an error and return false
}

The algorithm I'm using above will work within the field,
however it will only give me the ORIGINAL value of the
textarea field. If the user changes it, I'm simply unable to grab the NEW
value of the field. As all of my other field validation works fine, I'm
assuming this has something to do with the iFrame.


Jon,

The only thing I can think of is that you are accessing the wrong
document. An iframe has its own document object - I believe the
property is called contentDocument , but I am not sure, so don't flame
me if I'm incorrect. Anyway, you might want to try getting the form in
that document object and see if that helps.

--
Joe Attardi

Jan 25 '06 #2
Jon
hehe - I don't flame on newsgroups or message boards :p

Thanks for the info - Though I was unable to build a solution exactly how I
wanted originally, I researched what you were talking about and found a
better way. I basically built the 'preview' functionality within the iFrame
itself to avoid any problems of the different objects on the same page. So
it calls the ID of the textarea from a link that sits inside the actual
iFrame, and pushes the current value to a new window. Looks to be working
fine now - Thanks :)

I really need to take some Javascript classes - it's much different than
what I'm used to (PHP/ASP) :(

"Joe Attardi" <ja******@gmail .com> wrote in message
news:11******** **************@ f14g2000cwb.goo glegroups.com.. .
Jon wrote:
if(document.for mName.field.val ue == ""){
//throw an error and return false
}

The algorithm I'm using above will work within the field,
however it will only give me the ORIGINAL value of the
textarea field. If the user changes it, I'm simply unable to grab the NEW
value of the field. As all of my other field validation works fine, I'm
assuming this has something to do with the iFrame.


Jon,

The only thing I can think of is that you are accessing the wrong
document. An iframe has its own document object - I believe the
property is called contentDocument , but I am not sure, so don't flame
me if I'm incorrect. Anyway, you might want to try getting the form in
that document object and see if that helps.

--
Joe Attardi

Jan 25 '06 #3

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

Similar topics

5
2398
by: Carlos Ribeiro | last post by:
Hello all, I'm posting this to the list with the intention to form a group of people interested in this type of solution. I'm not going to spam the list with it, unless for occasional and relevant announcements. If you're interested, drop me a note. But if for some reason you think that this discussion is fine here at the c.l.py, please let me know. ** LONG POST AHEAD **
5
5193
by: Ben | last post by:
Hi, I'm having trouble with the CSS apparently not working fully on the form input fields when inside an iFRAME. The problem is that if I resize the text size on the test.html page(see below) the controls inside the iframe do not resize. However, if I view the source.html by itself I'm able to resize both text and input box size. I'm using IE 6.0, but this is also broken on Netscape 7.0 as well. Can anyone think of work arounds...
5
2507
by: Victor | last post by:
Hi I need to open an html file from the file system and embed that html file within my main aspx form. I have 2 questions: 1) How do I open the html file? I tried the File.open(Path, mode) didnt work. 2) I would like to display the html file at a certain location in my main aspx page. How can I achieve this? I'm brain dead and I have to finish this tonight! Please help. Thanks
1
1532
by: junkaccount | last post by:
In Access 2000, I want to create a form that upon initial data entry, matches data from one table and places it in the form. The user will then enter additional data in the form, at which point all data is sent to a new table. For example, a user will enter a job number in a field within the form which will call up related info from Table A and fill in separate text boxes. The user will then fill in new information in the remaining text...
9
5335
by: Timm | last post by:
I have an ASP.NET 2.0 page with two DropDownLists. I am using declarative data binding wherever possible and trying to minimize the use of code. The list of values in DropDownList DDL2 should be (filtered) dependent upon the selection in DDL1. I think this inevitably needs some code, but I'd be happy to be told otherwise! I have some code to handle OnSelectedIndexChanged for DDL1 that sets the FilterExpression associated with the...
23
14507
by: Bjorn | last post by:
Hi. Every time i post data in a form the contents are being checked for validity. When i click the back-button, all data is gone and i have to retype it. It's obvious that only a few or none of the visitors will retype it all so i'm asking: "how to preserve POST-data when clicking the back-button?" i've already tried to print post data as a value in a HTML tag but
4
32539
by: vunet.us | last post by:
Hi all, I am converting my app to AJAX-based. I have a form that submits some data including images. When I use AJAX XmlHttpRequest I am unable to submit the form with ENCTYPE="multipart/form-data" (error 500). Without ENCTYPE="multipart/form-data", everything goes well. I think there is a header I must use in addition, but I cannot seem to find a good solution. Can you suggest? Thank you. Here is a part of xmlhttp request where I set...
2
1583
by: shankar2 | last post by:
Hello All, This is my first try at posting a query in this forum, your patience is appreciated. App Details: Access 2000 on Win 2000, Slightly better than a Novice, comfortable with various acess terminologies and usages. Problem on Hand: I have a form A which is based on table A exclusively. I have a form B which is based on table A and B. Within Form B, you can select, by using combo boxes, fields from table A, and the pertinent data...
1
1637
by: filmfanatic | last post by:
In this emal form, I'm trying to consolidate all the input into the TEXTAREA portion and then have it emailed to a specific person. I've tried the onClick and onBlur commands but only one field's input shows at a given time in the TEXTAREA box. Then, then when I move to the next field and input text, it just erases the choice from the first field in the TEXTAREA box below. Basically, I want the data to consolidate in the TEXTAREA box and...
0
8697
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
9184
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
9045
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
8930
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
5878
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();...
0
4382
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
4634
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3062
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2359
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.