473,500 Members | 1,929 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Passing values from a page to a Form Field

6 New Member
I’m fairly new on ASP and Javascript programming, I have read as much as I can to develop my website in a user friendly manner. I’m using javascript to pass some values in a Form, but is no working, I have tried to research, but being such a specific problem I haven’t being able to find any answers. Hope Somebody Can Help Me or put me in the right direction. Thanks in advance.

I have a form and when clicking on an image all I’m trying to do is select the airport name and code from another ASP page. I have a javascript function in a .js file:

Expand|Select|Wrap|Line Numbers
  1.  
  2. function passAirport(airport,formName,formField) {
  3.         var valuePath = eval("window.opener.document." + formName + "." + formField);
  4.         valuePath.value = airport;
  5.         window.close();
  6. }
You can view the 2 pages at ViajeroFrecuente dot NET/Compra.html. When you click in the B/W airplane image, another page (Aeropuertos_Spa.asp) opens, expecting you to select a city from the list. My goal is to pass the selected city/airport value back to the field (Origen) in the form on the previous page and close the window automatically.

My form name is travelrequest, the first field that I’m trying to make it work is Origen, the one mark with “*” as it is a required field. Here is the code section on the Compra page:

Expand|Select|Wrap|Line Numbers
  1.  
  2. <td align="right"><a href="javascript: MM_openBrWindow('Aeropuertos_Spa.asp?FldName=Origen','','scrollbars=yes,width=775,height=700')"><img src="/images/Icons/Aeropuerto.gif" alt="Seleccione Aeropuerto" width="16" height="16" border="0"></a>
And here is the code section on the Aeropuertos_Spa.asp page for the first airpot at the top.

Expand|Select|Wrap|Line Numbers
  1. <a href="javascript:passAirport('Aberdeen, SD (ABR)', 'travelrequest', '');" class="airport">Aberdeen, SD (ABR)</a><br>
When I select teh value in the Aeropuertos_Spa.asp page it gives me the following error

Can anybody please explain what I am doing wrong? Am I missing some variable definitions?
PLEASE HELP !
Oct 6 '07 #1
7 3330
acoder
16,027 Recognized Expert Moderator MVP
Welcome to TSDN!

You've forgotten to pass the name of the form field. You're passing an empty string as the third parameter.

No need to use eval. Change that line to:
Expand|Select|Wrap|Line Numbers
  1. var valuePath = window.opener.document.forms[formName][formField];
The correct way to use code tags would be:
[CODE=javascript]
JavaScript code...
[/code]
Oct 6 '07 #2
EyeHawk
6 New Member
I'll try that right away. Thanks for the other suggestions as well.
Keep you posted
Oct 6 '07 #3
EyeHawk
6 New Member
You are right I forgot to pass the FieldName. Since I'm doing the same process with different fields in the form, I should be able to use the variable FldName which I'm passing in the call and in my example has the value Origen. “….MM_openBrWindow('Aeropuertos_Spa.asp?FldName=Origen'…..”

How do I use that variable in the function call ? (instead of the XXX shown below)

Expand|Select|Wrap|Line Numbers
  1. <a href="javascript:passAirport('Aberdeen, SD (ABR)', 'travelrequest', XXX);" class="airport">Aberdeen, SD (ABR)</a><br>
I tried obviously the name of the variable but I get an error, as shown below:

Expand|Select|Wrap|Line Numbers
  1. <a href="javascript:passAirport('Aberdeen, SD (ABR)', 'travelrequest', FldName);" class="airport">Aberdeen, SD (ABR)</a><br>
  2.  
I also tried defining couple global variables and a function, but it did'nt resolve the problem

Expand|Select|Wrap|Line Numbers
  1. var formName; var fieldName
  2. function setFormElements(fn1,fn2) {formName=fn1; fieldName=fn2;}
  3.  
If you try the online version, #1 is not working and 2-7 airports are working now, since I'm putting the field name, but as a string not as a variable.

I also read online about the variable being located in indexSearch and other search mod components, but not sure what is it or how to use it..

What would be the right way to use the value of FldName..?
Thanks in advance for your help
Oct 6 '07 #4
EyeHawk
6 New Member
GOT IT.
I'm not sure if it is the most efficient way but this is how I solved:

Expand|Select|Wrap|Line Numbers
  1. <% FieldName = Request.QueryString("FldName") %>
  2. <a href="javascript:passAirport('Aberdeen, SD (ABR)', 'travelrequest', '<%=FieldName%>');" class="airport">Aberdeen, SD (ABR)</a><br>
  3.  
Oct 6 '07 #5
acoder
16,027 Recognized Expert Moderator MVP
Yes, that's the ASP way which is fine. In case you wanted the JavaScript way for some reason, try the location object's search property and parse it using the String object.

Anyway, glad to hear that you got it working.

Post again if you have any more questions.
Oct 6 '07 #6
EyeHawk
6 New Member
Thanks for helping me out. !!
Oct 6 '07 #7
acoder
16,027 Recognized Expert Moderator MVP
No problem. You're welcome.
Oct 7 '07 #8

Sign in to post your reply or Sign up for a free account.

Similar topics

5
5923
by: Paul | last post by:
I want to use sessions to cover myself in case the user switches off cookies so I am passing the session ID manually through a hidden input field. This is what I have so far. index.php page...
1
7766
by: Paul | last post by:
Hmmm, didn't seem to work. I have set session.use_cookies = 1 and session.use_trans_sid = 1 in my php.ini file. Index.php contains:...
12
6505
by: Kevin Lyons | last post by:
Hello, I am trying to get my select options (courses) passed correctly from the following URL: http://www.dslextreme.com/users/kevinlyons/selectBoxes.html I am having difficulty getting the...
4
1483
by: viktor | last post by:
Hi , I have a small problem.How can I pass value from form thru a few pages. I try with hidden field but my second page just validate and redirect to other one and when I use...
1
1313
by: Iyigun Cevik | last post by:
I'm passing my form to another page by using Server.Transfer method. I wrote readonly properties for each textbox in the first page, and i'm getting values of these textboxes from second page from...
2
1467
by: Ganesh | last post by:
Hi there, I'm new to .net just started with 2005 and asp.net 2.0, I'm passing control values to other page to retrieve the data from data set based on the passing values. It works fine. But when...
8
3375
by: ridgedale | last post by:
I wonder if anyone could explain how I pass the field values in my request form to the PHP processor page. My external javascript file is as follows: var sections = ; for (var i=0; i <...
5
2338
by: mwpclark | last post by:
I have javascript code which passes select input form field values in Firefox and Opera but it does not seem to work in IE7. This form runs a search, and the search results page has the same form...
5
3190
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...
0
7018
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...
0
7182
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,...
1
6906
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
5490
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,...
1
4923
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...
0
4611
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...
0
3110
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...
0
3106
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
672
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.