473,569 Members | 2,463 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 13377
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.formNa me
document.forms[ "formName" ]
document.forms[ index ] (not recommended)

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

document.formNa me.elementName
document.formNa me.elements[ "elementNam e" ]
document.formNa me.elements[ index ]

or other variations.

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

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

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

<URL:
http://devedge.netscap e.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("us er_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_S PAM.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.formNa me
document.forms[ "formName" ]
document.forms[ index ] (not recommended)

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

document.formNa me.elementName
document.formNa me.elements[ "elementNam e" ]
document.formNa me.elements[ index ]

or other variations.

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

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

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

<URL:

http://devedge.netscap e.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("us er_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.docume nt.formName.tfU serName.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.t fUserName.value ;
// etc...
}

// In the pop-up:

<INPUT TYPE="button" VALUE="validate form"
ONCLICK="opener .validateForm(t his.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_S PAM.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("us er_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.docume nt.formName.tfU serName.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.t fUserName.value ;
// etc...
}

// In the pop-up:

<INPUT TYPE="button" VALUE="validate form"
ONCLICK="opener .validateForm(t his.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
4923
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 what I'd like to have happen :
9
3958
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 form. In the past, I have been using PHP to pre-populate each field, something like <input type="text" id="firstName" value="<?= $first_name ?>"...
3
3677
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 first part) needs to get input from the user, and I want to do this with cin.getline also. The problem I am getting, is when I run the program, the...
1
3177
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 follows: The code below is for the first page:session_start is in line 3 <link href="css/jobSheet.css" rel="stylesheet" type="text/css" /> ...
4
3304
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 checkboxes value and name on the next page and send message to only those two selected user. Thanx in advance
21
3812
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 this property or method'. <form name="myform" action="main.asp" method="post"> <div id="content"> <h2 id="pageName">Main Page</h2> <div...
1
4910
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 order, Input field and a submit button. The Category name is being fetched from the oracle db along with the corresponding Category order. In...
9
2607
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 the main floors of the main house: Part C: Gross Floor Area of the basement or cellar: Part D: Gross Floor Area of the attic:
7
4429
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 surrendered to you. <%@ Language=VBScript%> <%Option Explicit%>
0
7703
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...
0
7618
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...
0
8132
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...
0
6286
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...
1
5514
isladogs
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...
0
5222
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...
0
3644
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2116
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
1
1226
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.