473,405 Members | 2,334 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,405 software developers and data experts.

Getting user input into JavaScript

Is it possible to open a browser window from a javascript for the purpose of
gathering user input on a form and then use data from the form in the
javascript? How do you get the data from the form into the script?

Don W.
Jul 20 '05 #1
4 13367
Hi,

Don W. wrote:
Is it possible to open a browser window from a javascript for the purpose of
gathering user input on a form and then use data from the form in the
javascript? How do you get the data from the form into the script?

Don W.


A form can be reached through different syntaxes, for example:

document.formName
document.forms[ "formName" ]
document.forms[ index ] (not recommended)

Once you have the Form object, you can access the elements with

document.formName.elementName
document.formName.elements[ "elementName" ]
document.formName.elements[ index ]

or other variations.

Depending on the type of the element, you can access its value with:

document.formName.elementName.value (for textfields, textareas)
document.formName.elementName.checked (for checkboxes or single
radiobuttons)
document.formName.elementName[ index ].checked (for radiobutton groups)

I recommend you to read the following for more information about this:

<URL:
http://devedge.netscape.com/library/manuals/2000/javascript/1.3/reference/form.html>

HTH,

Laurent
--
Laurent Bugnion, GalaSoft
Webdesign, Java, javascript: http://www.galasoft-LB.ch
Private/Malaysia: http://mypage.bluewin.ch/lbugnion
Support children in Calcutta: http://www.calcutta-espoir.ch

Jul 20 '05 #2
Thank you for taking the time to provide me with all that information!

I may not have been clear in my question. If I open a window from a script
using something like this:
window.open("user_input.htm") from within a script, then how can I retrieve
the data from a form in user_input.htm?

The only way I can find to do this is to open a file in user_input.htm and
write the data to the file. I still need some way for the script to know
when to read the file.

I don't like using this intermediate file. Do you know a better way?

Don W.
"Laurent Bugnion, GalaSoft" <galasoft-LB@bluewin_NO_SPAM.ch> wrote in
message news:bm**********@rex.ip-plus.net...
Hi,

Don W. wrote:
Is it possible to open a browser window from a javascript for the purpose of gathering user input on a form and then use data from the form in the
javascript? How do you get the data from the form into the script?

Don W.
A form can be reached through different syntaxes, for example:

document.formName
document.forms[ "formName" ]
document.forms[ index ] (not recommended)

Once you have the Form object, you can access the elements with

document.formName.elementName
document.formName.elements[ "elementName" ]
document.formName.elements[ index ]

or other variations.

Depending on the type of the element, you can access its value with:

document.formName.elementName.value (for textfields, textareas)
document.formName.elementName.checked (for checkboxes or single
radiobuttons)
document.formName.elementName[ index ].checked (for radiobutton groups)

I recommend you to read the following for more information about this:

<URL:

http://devedge.netscape.com/library/manuals/2000/javascript/1.3/reference/form.html>
HTH,

Laurent
--
Laurent Bugnion, GalaSoft
Webdesign, Java, javascript: http://www.galasoft-LB.ch
Private/Malaysia: http://mypage.bluewin.ch/lbugnion
Support children in Calcutta: http://www.calcutta-espoir.ch

Jul 20 '05 #3
Hi,

Don W. wrote:
Thank you for taking the time to provide me with all that information!

I may not have been clear in my question. If I open a window from a script
using something like this:
window.open("user_input.htm") from within a script, then how can I retrieve
the data from a form in user_input.htm?

The only way I can find to do this is to open a file in user_input.htm and
write the data to the file. I still need some way for the script to know
when to read the file.
You couldn't do this anyway, since client-side JavaScript is not allowed
to write files, unless in certains special security conditions, and in
very specific (not cross-browser) ways.
I don't like using this intermediate file. Do you know a better way?


You can read the data in the pop-up with:

-------------------------------------------------
// In the main window

var g_wPopUp = open( ... );

// This method is called from the pop-up when
// the user presses the "Validate" button
function validateForm()
{
var strUserName = g_wPopUp.document.formName.tfUserName.value;
// etc...
}

// In the pop-up:

<INPUT TYPE="button" VALUE="validate form"
ONCLICK="opener.validateForm();">

-------------------------------------------------
Or even better:

// In the main window

var g_wPopUp = open( ... );

// This method is called from the pop-up when
// the user presses the "Validate" button
function validateForm( frmToValidate )
{
var strUserName = frmToValidate.tfUserName.value;
// etc...
}

// In the pop-up:

<INPUT TYPE="button" VALUE="validate form"
ONCLICK="opener.validateForm(this.form);">

-------------------------------------------------
HTH,

Laurent
--
Laurent Bugnion, GalaSoft
Webdesign, Java, javascript: http://www.galasoft-LB.ch
Private/Malaysia: http://mypage.bluewin.ch/lbugnion
Support children in Calcutta: http://www.calcutta-espoir.ch

Jul 20 '05 #4
Thank you, that's just what I was looking for!

Don W.
"Laurent Bugnion, GalaSoft" <galasoft-LB@bluewin_NO_SPAM.ch> wrote in
message news:bm**********@rex.ip-plus.net...
Hi,

Don W. wrote:
Thank you for taking the time to provide me with all that information!

I may not have been clear in my question. If I open a window from a script using something like this:
window.open("user_input.htm") from within a script, then how can I retrieve the data from a form in user_input.htm?

The only way I can find to do this is to open a file in user_input.htm and write the data to the file. I still need some way for the script to know when to read the file.


You couldn't do this anyway, since client-side JavaScript is not allowed
to write files, unless in certains special security conditions, and in
very specific (not cross-browser) ways.
I don't like using this intermediate file. Do you know a better way?


You can read the data in the pop-up with:

-------------------------------------------------
// In the main window

var g_wPopUp = open( ... );

// This method is called from the pop-up when
// the user presses the "Validate" button
function validateForm()
{
var strUserName = g_wPopUp.document.formName.tfUserName.value;
// etc...
}

// In the pop-up:

<INPUT TYPE="button" VALUE="validate form"
ONCLICK="opener.validateForm();">

-------------------------------------------------
Or even better:

// In the main window

var g_wPopUp = open( ... );

// This method is called from the pop-up when
// the user presses the "Validate" button
function validateForm( frmToValidate )
{
var strUserName = frmToValidate.tfUserName.value;
// etc...
}

// In the pop-up:

<INPUT TYPE="button" VALUE="validate form"
ONCLICK="opener.validateForm(this.form);">

-------------------------------------------------
HTH,

Laurent
--
Laurent Bugnion, GalaSoft
Webdesign, Java, javascript: http://www.galasoft-LB.ch
Private/Malaysia: http://mypage.bluewin.ch/lbugnion
Support children in Calcutta: http://www.calcutta-espoir.ch

Jul 20 '05 #5

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

Similar topics

4
by: gimme_this_gimme_that | last post by:
Hi, This is sort of a : How to build a Yes/No dialog box qquestion. Or perhaps a question about getting javascript variables from a pop-up window and processing them on a submit. This is...
9
by: Good Man | last post by:
Hi This is sort of a weird question, perhaps a bit off-topic... I am on the 'edit' screen of a web form, and I have a bunch of variables coming from a database that need to be placed into the...
3
by: dei3cmix | last post by:
Hey, I am having a problem with a program I am working on. Basically, the first part of the program gets input from a file using cin.getline. Then the second part, (still in the same main as the...
1
by: simbarashe | last post by:
Hie could someone please help me with getting and using the current page url. I have a function that gets the url, I want to use it with header(location : XXX) but it wont work. The code is as...
4
by: jeet | last post by:
Plz help me.Problem is that On the first page I display all other user with checkbox and give user option to select only two user which he wants to send message. Tell me please how I'll get those...
21
vikas251074
by: vikas251074 | last post by:
I am getting error while entry in userid field. When user enter his user id, an event is fired immediately and user id is verified using AJAX method. But I am getting error 'Object doesn't support...
1
by: raghuvendra | last post by:
Hi I have a jsp page with 4 columns: namely Category name , Category order, Input field and a submit button. All these are aligned in a row. And Each Category Name has its corresponding Category...
9
Catalyst159
by: Catalyst159 | last post by:
I have a form which is used to calculate residential Floor Area Ratio (FAR). The form is structured into seven parts as follows: Part A: Maximum FAR and Floor Area: Part B: Gross Floor Area of...
7
vikas251074
by: vikas251074 | last post by:
I am getting error above in following code since few days giving tension day and night. How can I solve this? I am facing since Oct.25. in line no. 362 After doing a lot of homework, I am...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
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...
0
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...
0
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,...

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.