473,776 Members | 1,650 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Pass on values from drop-down box

Hello all,
I wonder if anybody can give me a hint about what I have to do to get
this working: I am creating a drop down box using the script below. The

result is two text fields; now I want to pass those values, which come
from the drop down box, to the next page. The next page should then
simply look like this:
Month:
Year:
And the values should be the ones from the drop-down box...
I have been staring myself blind about how to get this accomplished.
Would be more than grateful if somebody could have a look...here is
what I got so far:
<script language="JavaS cript"><!--
function setForm2Value() {
var selectedItem = document.formNa me1.selectName1 .selectedIndex;
var selectedItemVal ue =
document.formNa me1.selectName1 .options[selectedItem].value;
var selectedItemTex t =
document.formNa me1.selectName1 .options[selectedItem].text;
if (selectedItem != 0) {
document.formNa me2.textboxName 1.value = selectedItemTex t;
document.formNa me2.textboxName 2.value = selectedItemVal ue;
}
else {
document.formNa me2.textboxName 1.value = "";
document.formNa me2.textboxName 2.value = "";

}
}
//--></script>
Incident Level <br>
<form name="formName1 ">
<select name="selectNam e1" onChange="setFo rm2Value()">
<option>Make A Selection:
<option value="2000">Ja nuary
<option value="2001">Fe bruary
<option value="2002">Ma rch
</select>
</form>

<p>
<form name="formName2 " method="POST" action="step2.h tm">
<input type="text" name="textboxNa me1" value="" size="20"> Euro
<input type="text" name="textboxNa me2" value="" size="6">
<input type="submit" VALUE="Next" class=button>
</FORM>
This creates the drop down list, and when a selection is made, two
textboxes at the bottom are filled. When I hit the ´Next´ button,
that takes me to the new page. So far, so good. The problem is: how do
I get the values from those two textboxes to two new text fields on the

new page ? I have been staring at this for the last two days, and tried

about everything I could find in sample codes, but I must be doing
something wrong, because the values do not appear on the new page. Can
anybody provide me with a hint, or better yet, some sample code ?
Thanks a bunch in advance !
Naz

Nov 25 '05 #1
19 9082
"nazgulero" <ge**********@w anadoo.nl> wrote in message
news:11******** **************@ g49g2000cwa.goo glegroups.com.. .
Hello all,
I wonder if anybody can give me a hint about what I have to do to get
this working: I am creating a drop down box using the script below. The

result is two text fields; now I want to pass those values, which come
from the drop down box, to the next page. The next page should then
simply look like this:
<snipped />
<form name="formName2 " method="POST" action="step2.h tm">
<input type="text" name="textboxNa me1" value="" size="20"> Euro
<input type="text" name="textboxNa me2" value="" size="6">
<input type="submit" VALUE="Next" class=button>
</FORM>

This creates the drop down list, and when a selection is made, two
textboxes at the bottom are filled. When I hit the ´Next´ button,
that takes me to the new page. So far, so good. The problem is: how do
I get the values from those two textboxes to two new text fields on the
new page ? I have been staring at this for the last two days, and tried


You need server-side code to do that...

You post your two textboxes to the next page, so all is well so far.
But the next page is a .htm file (step2.htm", with no ability to run
serverside script to extract the data you posted.

As an example (using ASP on the server):

* Replace "step2.htm" with step2.asp, and put this in the .asp file:
<%@LANGUAGE="VB SCRIPT"%>
<%
Dim monthValue
monthValue = Request.Form("t extboxName1")

Dim yearValue
yearValue = Request.Form("t extboxName2")
%>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dt d">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Page Title</title>
</head>

<body>
<p>Month: <%=monthValue%> </p>
<p>Year: <%=yearValue% ></p>
</body>
</html>

--
Dag.
Nov 25 '05 #2

Hello Dag,

great, thanks for your quick help. I´ll give that a try and let you know
!

Regards,

Naz
*** Sent via Developersdex http://www.developersdex.com ***
Nov 25 '05 #3
nazgulero wrote:
Hello all,
I wonder if anybody can give me a hint about what I have to do to get
this working: I am creating a drop down box using the script below. The

The following example may help:

<!-- Page 1 HTML: -->

<html>
<title>Play</title>

<form action="page2.h tml">
<select name="month">
<option>January </option>
<option>Februar y</option>
<option>March </option>
</select>
<select name="year">
<option>2005</option>
<option>2006</option>
<option>2007</option>
</select>
<input type="submit">
<form>
</html>
<!-- Page 2 HTML: -->

<html> <title>page 2</title>
<script type="text/javascript">
function getMonthYear(){
var s = window.location .search.replace (/^\?/,'').split('&') ;
for (var i=0, len=s.length; i<len; ++i){
var x = s[i].split('=');
document.getEle mentById(x[0]).innerHTML = x[1];
}
}
</script>
<body onload="getMont hYear();">

<span id="month"></span>&nbsp;<spa n id="year"></span>
</body></html>

--
Rob
Nov 25 '05 #4
Hello Rob,

thanks a bunch for your help. The problem seems to be that the script I
am using creates two text boxes, filled with values form the drop down
box. Now I need to get those two values to two separate text boxes on
the next page. Also, the values need to appear not next to each other,
but in two different lines...
I will try to tweak your script and see if I somehow get it working.
Thanks again for your response.

Regards,

Naz

*** Sent via Developersdex http://www.developersdex.com ***
Nov 25 '05 #5
Hello Dag,

sorry to bother you again. I have tried your script, but still nothing
is being sent. Here is the code I am using:

On page 1:
<script language="JavaS cript"><!--
function setForm2Value() {
var selectedItem =
document.formNa me1.selectName1 .selectedIndex;
var selectedItemVal ue =
document.formNa me1.selectName1 .options[selectedItem].value;
var selectedItemTex t =
document.formNa me1.selectName1 .options[selectedItem].text;

if (selectedItem != 0) {
document.formNa me2.textboxName 1.value = selectedItemTex t;
document.formNa me2.textboxName 2.value = selectedItemVal ue;
}
else {
document.formNa me2.textboxName 1.value = "";
document.formNa me2.textboxName 2.value = "";
}
}
//--></script>
Incident Level <br>
<form name="formName1 ">
<select name="selectNam e1" onChange="setFo rm2Value()">
<option>Make A Selection:
<option value="January" >2004
<option value="February ">2006
<option value="March">2 005
</select>
</form>

<p>

<form name="formName2 " action="page2.a sp">
<input type="text" name="textboxNa me1" value="" size="20">
<input type="text" name="textboxNa me2" value="" size="6"><br><b r>
<input type="submit" value="Continue ">
</form>

And on page 2:
<%@LANGUAGE="VB SCRIPT"%>
<%
Dim monthValue
monthValue = Request.Form("t extboxName1")

Dim yearValue
yearValue = Request.Form("t extboxName2")
%>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
<html xmlns="page1.ht m">
<head>
<meta http-equiv="Content-Type" content="text/html;
charset=iso-8859-1" />
<title>Page title</title>
</head>

<body>
<p>Month: <%=monthValue%> </p>
<p>Year: <%=yearValue% ></p>
</body>
</html>

I can see both the ´Month´ and ´Year´ fields on the new page, page2.asp,
but nothing gets passed on from the previous page...
I am at a loss, been looking at this for too long probably...do you see
anything wrong with this code ?

Thanks again for your help.

Regards,

Naz
*** Sent via Developersdex http://www.developersdex.com ***
Nov 25 '05 #6
Georg Pauwen wrote:
Hello Dag,
Instead of strangely addressing _one_ individual in a public medium
where _everybody_ may read and post (otherwise you should use private
e-mail), you should quote what you are referring to, trim quotes and
provide attribution of quoted material, as described in
<URL:http://jibbering.com/faq/faq_notes/pots1.html>.
<script language="JavaS cript"><!-- [1]^^^^^^^^^^^^^^^ ^^^^^^ ^^^^[2]
[1] Use <URL:http://validator.w3.or g/> before complaining.

[2] It is both unnecessary and potentially harmful to use
SGML comment delimiters at this point.
function setForm2Value() {
function setForm2Value(f )
{
var selectedItem =
document.formNa me1.selectName1 .selectedIndex;
var selectedItemVal ue =
document.formNa me1.selectName1 .options[selectedItem].value;
var selectedItemTex t =
document.formNa me1.selectName1 .options[selectedItem].text;
Inefficient, error-prone and hard to maintain (what if the form name
changes?). Instead use:

if (f && f.elements)
{
var
o,
selectedItem =
(o = f.elements['selectName1']).options[o.selectedIndex];
if (selectedItem != 0) {
document.formNa me2.textboxName 1.value = selectedItemTex t;
document.formNa me2.textboxName 2.value = selectedItemVal ue;
}
else {
document.formNa me2.textboxName 1.value = "";
document.formNa me2.textboxName 2.value = "";
}
I do not understand why it would be necessary to use a second form.
FWIW, instead use:

var
f2 = document.forms['formName2'],
f2t1 = f2.elements['textboxName1'],
f2t2 = f2.elements['textboxName2'];

if (o.selectedInde x != 0)
{
f2t1.value = selectedItem.te xt;
f2t2.value = selectedItem.va lue;
}
else
{
f2t1.value = "";
f2t2.value = "";
}
} }
//--></script> ^^^^^
See above.
Incident Level <br>
If you have a heading, use an `hX' (X := 1..6) element.
<form name="formName1 ">
<select name="selectNam e1" onChange="setFo rm2Value()">
<option>Make A Selection:
The `option' element's close tag should be used.
<option value="January" >2004
<option value="February ">2006
<option value="March">2 005
</select>
</form>

<p>

<form name="formName2 " action="page2.a sp">
<input type="text" name="textboxNa me1" value="" size="20">
<input type="text" name="textboxNa me2" value="" size="6"><br><b r>
type="text" is the default here, it can be safely omitted. Do not use
`br' for margins, use block-elements like `div' being formatted via CSS.
<input type="submit" value="Continue ">
</form>

And on page 2:
<%@LANGUAGE="VB SCRIPT"%>
<%
Dim monthValue
monthValue = Request.Form("t extboxName1")

Dim yearValue
yearValue = Request.Form("t extboxName2")
%>
That could also be

<%@LANGUAGE = JScript %>
<%
var monthValue = Request.Form("t extboxName1");
var yearValue = Request.Form("t extboxName2");
%>

However, Request.Form() retrieves POST data. You are using GET (default for
the `form' element is method="GET"). Either you switch to method="POST" in
your markup or switch to Request.QuerySt ring() in your server-side script
code.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
<html xmlns="page1.ht m">
<head>
<meta http-equiv="Content-Type" content="text/html;
charset=iso-8859-1" />
See the W3C Validator again, and <URL:http://hixie.ch/advocacy/xhtml>
<title>Page title</title>
</head>

<body>
<p>Month: <%=monthValue%> </p>
<p>Year: <%=yearValue% ></p>
</body>
</html>

I can see both the ?Month? and ?Year? fields on the new page, page2.asp,
but nothing gets passed on from the previous page...
I am at a loss, been looking at this for too long probably...do you see
anything wrong with this code ?


Plenty.
HTH

PointedEars
Nov 25 '05 #7
Thomas 'PointedEars' Lahn wrote:
Georg Pauwen wrote:
function setForm2Value() {


function setForm2Value(f )
{
var selectedItem =
document.formNa me1.selectName1 .selectedIndex;
var selectedItemVal ue =
document.formNa me1.selectName1 .options[selectedItem].value;
var selectedItemTex t =
document.formNa me1.selectName1 .options[selectedItem].text;


Inefficient, error-prone and hard to maintain (what if the form name
changes?). Instead use:

if (f && f.elements)
{
[...]
<form name="formName1 ">
<select name="selectNam e1" onChange="setFo rm2Value()">


Of course this line then has to be changed to

<select name="selectNam e1" onChange="setFo rm2Value(this.f orm)">

as well. Which is why it is prudent to use

function setForm2Value(o )
{
if (o)
{
var f = o.form;

if (f && f.elements)
// inferring feature test for formName2 later -- comments?
{
// o is already properly defined
var selectedItem = o.options[o.selectedIndex];
// ...
}
}
}

<select name="selectNam e1" onChange="setFo rm2Value(this)" >
...
</select>

instead.
PointedEars
Nov 25 '05 #8
"Georg Pauwen" <ge**********@w anadoo.nl> wrote in message
news:0Q******** *****@news.uswe st.net...
Hello Dag,

sorry to bother you again. I have tried your script, but still nothing
is being sent. Here is the code I am using:

On page 1:
<snipped />

<form name="formName2 " action="page2.a sp">
<input type="text" name="textboxNa me1" value="" size="20">
<input type="text" name="textboxNa me2" value="" size="6"><br><b r>
<input type="submit" value="Continue ">
</form>


Add the "method=" attribute to the form element, and set it to POST:

<form name="formName2 " action="page2.a sp" method="POST">

--
Dag.
Nov 25 '05 #9
Hello,

thanks everybody for the continued support. To be honest, most of the
replies are way over my head, I actually thought that it was much easier
to just pass the two values in the text box on to the next page. My
server apparently does not support ASP, so I have to use HTML or JAVA
scripting.
I think what I am looking for is more a beginner´s forum, where people
are not expected to know all the intricacies of scripting, and where, it
seems to me, and that is because I am not an experienced user, things
get ever more complicated.
So, I apologize for taking up people´s time, I think this forum is more
for real developers and people that have been working with scripting for
a long time, rather than for beginners...

So, thanks again for the support, and I apologize for inappropriately
posting here.

Regards,

Naz

*** Sent via Developersdex http://www.developersdex.com ***
Nov 25 '05 #10

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

Similar topics

6
5295
by: Ray | last post by:
Group, Passing inline values to a udf is straightforward. However, how or is it possible to pass a column from the select of one table into a udf that returns a table variable in a join to the original table. The goal is to explode the number of rows in the result set out based on the result of the udf. Although the example I am providing here is simplified, we are trying to parse out multiple values out of a text column and using a...
2
3392
by: Zitan Broth | last post by:
Greetings All, Running pg 7.3.4 and was reading: http://archives.postgresql.org/pgsql-interfaces/2003-09/msg00018.php . Basically want to assign values to an array and then a 2d array. However I can't get this to run in properly I get a syntax error (at or near ", output_txt_arr TEXT, output_str text ); CREATE OR REPLACE FUNCTION F_TEST(TEXT) RETURNS NUMERIC AS '
4
2826
by: Alan Silver | last post by:
Hello, I have a user control that has a property StartYear. Logically enough, this takes an Int32 value. I have no problem doing something like ... <ctls:fred id="frdFred" StartYear="2000" Runat="Server" /> but if I try ... <ctls:fred id="frdFred" StartYear='<%=DateTime.Now.Year%>'
1
1626
by: Support | last post by:
Hello: I have a VB.NET DLL with a public structure: Public Class OCIDIIRRegistry Public Structure OCIDIIRRegistryReturn Public OCIDIIRimpliciterror As String Public OCIDIIRexpliciterror As String Public OCIDIIRvalueRequested End Structure
1
3941
by: Josué Maldonado | last post by:
Hello list, Is there a way to pass a collection of values (array) to a a function in plpgsql? Thanks in advance -- Sinceramente,
14
2472
by: xdevel | last post by:
Hi, I need your help because I don't understand very well this: in C arguments are passed by-value. The function parameters get a copy of the argument values. But if I pass a pointer what really is happening? also a copy is passed ? in C++ there is a pass-by-reference too... and in that case the paramter can be considered as an alias of the argument...
4
1819
by: J | last post by:
I am editing a pre-existing view. This view is already bringing data from 40+ tables so I am to modify it without screwing with anything else that is already in there. I need to (left) join it with a new table that lists deposits and the dates they are due. What I need is to print, for each record in the view, the due date for the next deposit due and the total of all payments that they will have made by the next due date.
28
4717
by: Bill | last post by:
Hello All, I am trying to pass a struct to a function. How would that best be accomplished? Thanks, Bill
3
3179
by: Aussie Rules | last post by:
Hi, I have a few aspx (.net2) form. The first form allows the user to enter into text box, and select values from drop downs The second form needs to use these values to process some data. I am currently using the url to pass the values such as
2
1687
mageswar005
by: mageswar005 | last post by:
Hello sir, How can i pass the infinity values from one page to another page with out using post method. 1) I know in Get method some limitations are there.I think Only 1024 characters are pass in GET METHOD. 2) Can any body tell me if i use SESSION METHOD Means ,How many values can able to pass in SESSION METHOD. Please some body help me , now i am struggling to pass the bulk(more than...
0
9628
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
9464
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 synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10292
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
10122
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
10061
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
8954
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...
1
7471
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 instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
2
3627
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2860
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.