473,789 Members | 2,694 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
19 9084
Georg Pauwen wrote:
thanks everybody for the continued support.
You're welcome.
To be honest, most of the replies are way over my head,
Are you incapable of learning?
Are you incapable of asking about things you did not understand?
Hopefully not.
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.
First you have to understand that JavaScript is not Java, that HTML is not
a programming language (and that Java is, in contrast to HTML, no acronym).

And ASP is a server-side CGI application platform (often one using the IIS
API), not a language. As I pointed out, it is entirely possible to use
JScript (kind of Microsoft's JavaScript dialect) for those applications.

However, it is possible to pass values to another document resource solely
with client-side scripting: use your web form and in the target document
use the `location.searc h' property. Whether that is a viable approach is
a different matter as client-side script support as well as host objects
and their properties do not need to be present.
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.


A "beginner forum" (whatever that might be) will not provide you with
(information on how to create) interoperable code, that's for sure.
PointedEars
Nov 25 '05 #11
Hello,

thanks for your help.
Would you happen to have a sample code using the location.search for my
specific purpose ?

Regards,

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

thanks for your help.
Would you happen to have a sample code using the location.search for my
specific purpose ?

Regards,

Naz
*** Sent via Developersdex http://www.developersdex.com ***
Nov 25 '05 #13
Georg Pauwen wrote:
Would you happen to have a sample code using the location.search
for my specific purpose ?


In the "sending" document, use your current form (and reasonable
element names) but do not use method="POST". This will include
the control's names and values URLencoded in a GET request when
it is submitted.

In the "receiving" document (specified in the `action' attribute
value of the aforementioned `form' element), use

<script type="text/javascript" src="search.js" ></script>
<script type="text/javascript">
if (location.searc h)
{
// split components into properties used below
var s = new SearchString();

document.write([
"Month: " + s.getValue("mon th") + "<br>",
"Year: " + s.getValue("yea r")
].join("\n"));
}
</script>

somewhere appropriate in the `body' element.

Examples of a possible content of search.js which would need
to provide the SearchString prototype, have been posted before,
search for "location.searc h split", for example.
PointedEars
Nov 25 '05 #14
Hello,

great, thanks a bunch, I will give that a try and piece it all together
!

Regards,

Naz
*** Sent via Developersdex http://www.developersdex.com ***
Nov 25 '05 #15
Georg Pauwen wrote:
Hello,

thanks for your help.
Would you happen to have a sample code using the location.search for my
specific purpose ?


That's what my first reply used in the function to get the year and
month values. I've repeated it in a simplified form below with comments.

The search string will be something like:

&month=January& year=2003
function getMonthYear(){

// Get the search string from the URL
var s = window.location .search;

// Remove the leading '?'
s = s.replace(/^\?/,'');

// Split it into an array using the '&' character
s = s.split('&');

// Now s is now an array of the name/value pairs from the
// search string, from the example: ['month=January' , 'year=2003']

// For each element in s (the array of bits of the search string)
for (var i=0, len=s.length; i<len; ++i){

// Split the element using the '='
var x = s[i].split('=');

// Use the name part x[0] and the value part x[1]
// From the example,
// the 1st time thu x[0] is month and x[1] is January
// the 2nd time thu x[0] is year and x[1] is 2003
document.getEle mentById(x[0]).innerHTML = x[1];
}
}

--
Rob
Nov 25 '05 #16
RobG wrote:

[...]
The search string will be something like:

&month=January& year=2003


Ooops:

?month=January& year=2003
[...]
--
Rob
Nov 25 '05 #17
Hello,

thanks for your response. Actually, your initial post was very useful.
The only problem is that my code does not create two drop down boxes,
but two text boxes based on one value selected from a drop down box. Now
I need to pass those two textbox values on to the next page...
Here is the initial code again, maybe you can run it, you´ll see what
the difference is:

<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 " action="step2.h tm">
<input type="text" name="textboxNa me1" value="" size="20">
<input type="text" name="textboxNa me2" value="" size="6">
<input type="submit" VALUE="Next" class=button>
</FORM>

I will try and play around with your suggestions, as well as those made
by the other posts. Of course, if you have any ideas, I would be more
than grateful !

Regards,

Naz


*** Sent via Developersdex http://www.developersdex.com ***
Nov 26 '05 #18
On 2005-11-25, nazgulero <ge**********@w anadoo.nl> wrote:

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 !


you can't easily pass the vaues between pages on the client side,
but you can echo them back in hidden fields.

have your server-side cgi script emit somethinge like this in the form
on the second page....

<input type="hidden" name="value1 value="the first value goes here" />
<input type="hidden" name="value2 value="the second value goes here" />

when that form is finally submitted you'll get those values back.
when you get that form back do a validation on all the fields, someone
naughty might fiddle the hidden fields.

Bye.
Jasen
Nov 26 '05 #19
On 2005-11-25, Georg Pauwen <ge**********@w anadoo.nl> wrote:
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.
ASP is not the only way. what does your server support?
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.
without some sort of server-side scripting what is the purpose of the form?
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...

--

Bye.
Jasen
Nov 27 '05 #20

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
1820
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
9511
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
10195
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
10136
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
9979
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7525
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...
0
6765
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
5415
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...
1
4090
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
3695
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.