473,387 Members | 1,561 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,387 software developers and data experts.

Populate form B with values based on form A

12
Hi

I am struck with this problem .

i have 2 forms ..

Form A has 2 dropdown box

state :
city :

Form B

State :
City:


how to populate form B with the same values which the user selected in Form A

I would be very thankful .. if anyone can help me out

Thank You
Jun 1 '07 #1
21 2029
acoder
16,027 Expert Mod 8TB
Welcome to TSDN!

If the form has an id, you can use
Expand|Select|Wrap|Line Numbers
  1. document.getElementById('formB')
to access form B.

In form B, what are State and City? Are they textboxes?

Post the HTML for both form A and form B.
Jun 4 '07 #2
bha123
12
Welcome to TSDN!

If the form has an id, you can use
Expand|Select|Wrap|Line Numbers
  1. document.getElementById('formB')
to access form B.

In form B, what are State and City? Are they textboxes?

Post the HTML for both form A and form B.
Hi

Thank you so much for replying

my sample code

home.htm

<form name="homePage" id="homePage" action="" method="post" >
<select id="month" name="month">
<option>jan</option>
<option>feb</option>
<option>mar</option>
</select>
</form>


user.htm

<form name="userPage" id="userPage" action="" method="post" >
<select id="month" name="month">
<option>jan</option>
<option>feb</option>
<option>mar</option>
</select>
</form>


wht ever the month the user selects in the Home.htm
that should be populated in the user.htm drop down box
these 2 different form are present in 2 different pages..

Please help me about the way i can solve this

Thank you so much
Jun 5 '07 #3
acoder
16,027 Expert Mod 8TB
If they're on different pages, you'll need a server-side language to set the values.

You could possibly do this using cookies, but is it worth the hassle?
Jun 5 '07 #4
bha123
12
If they're on different pages, you'll need a server-side language to set the values.

You could possibly do this using cookies, but is it worth the hassle?
is there any way i can do using java script ??

Thanks You
Jun 5 '07 #5
acoder
16,027 Expert Mod 8TB
How do you get from one page to the other? Are they linked in any way?

Read up on cookies here and here, so you know how to keep 'state' persistent over more than one page.

Of course, if cookies are disabled, you're a bit stuck.
Jun 5 '07 #6
bha123
12
Hi

Thank you so much for ur reply

I got this code at http://www.irt.org/articles/js063/index.htm

function load()
{
var passed = location.search.substring(1);
document.form2.month.value=getParm(passed,month);
document.form2.route.options.value = getParm(passed,year);
}

function getParm(string,parm)
{
var startPos = string.indexOf(parm + "=");
if (startPos > -1)
{
startPos = startPos + parm.length + 1;
var endPos = string.indexOf("&",startPos);
if (endPos == -1){endPos = string.length;}
return unescape(string.substring(startPos,endPos));
}
return '';
}

i am calling load() function when loading the form
PROBLEM IS THIS CODE WORKS FINE IN - " IE 7" BUT DOES NOT WORK IN - MOZILLA FIREFOX.. CAN YOU PLEASE TELL ME HOW CAN I USE IT IN MOZILLA FIREFOX

It would be of great help
Thansk u once again
Jun 7 '07 #7
acoder
16,027 Expert Mod 8TB
Are you using the GET method?
Jun 8 '07 #8
bha123
12
ya ,i am able to get the values from the the form A in this form

http://www.irt.org/articles/js054/output.htm?city=value&state=qwerty

in form B i have parse this output statement which i get from form A and put the
first value i.e city value in text box
second value i.e state value in dropdown box

the above code as i said in my previous post works fine only in IE 7 , but not able to work in mozilla FireFox

I am not able to to figure out the reson .. could u please help me , how to make it work in mozilla firefox

Thanks a lot
Jun 8 '07 #9
acoder
16,027 Expert Mod 8TB
Are you getting any errors in Firefox?
Jun 9 '07 #10
bha123
12
Hi

I am not getting any errors in FireFox , but this particular code is not working , i.e its not copying the data from Form A to form B

Can u plz , let me know the way i can solve this problem

Thanks
Jun 11 '07 #11
acoder
16,027 Expert Mod 8TB
How are you accessing month and year?
Jun 11 '07 #12
bha123
12
Hi

from Form A i pass the values in the form of query

http://www.irt.org/articles/js054/output.htm?month=value&year=value

In Form B i parse these elements using the following code ,


function loading()
{
var passed = location.search.substring(1);
document.form2.month.value=getParm(passed,month);
document.form2.year.options.value = getParm(passed,year);
}


function getParm(string,parm)
{
var startPos = string.indexOf(parm + "=");
if (startPos > -1)
{
startPos = startPos + parm.length + 1;
var endPos = string.indexOf("&",startPos);
if (endPos == -1){endPos = string.length;}
return unescape(string.substring(startPos,endPos));
}
return '';
}


i will be calling loading function when i load the form
my form B looks like this

<body onload="loading()">
<form name="userPage" id="userPage" action="" method="post" >
<select id="month" name="month">
<option>jan</option>

<option>Dec</option>
</select>
<select id="year" name="year">
<option>2000</option>

<option>2100</option>
</select>
</form>
</body>


this is how i accress the elements
Please let me know if i am not clear

Thanks
Jun 11 '07 #13
bha123
12
i am able to work in IE 7 , but its not working in FireFox
Jun 11 '07 #14
acoder
16,027 Expert Mod 8TB
month and year should be strings, i.e. "month" and "year" when passed to getParm.
Jun 11 '07 #15
bha123
12
yes , getparm function considers any character a-z and digits 0 - 9

Thanks
Jun 12 '07 #16
acoder
16,027 Expert Mod 8TB
No, I mean the variables month and year should be strings unless you are defining them so somewhere else.

See your code:
Expand|Select|Wrap|Line Numbers
  1. function loading()
  2. {
  3. var passed = location.search.substring(1);
  4. document.form2.month.value=getParm(passed,month);
  5. document.form2.year.options.value = getParm(passed,year);
Line 4 should be:
Expand|Select|Wrap|Line Numbers
  1. document.form2.month.value=getParm(passed,"month");
Jun 12 '07 #17
bha123
12
I am really sorry , when copying the code i missed the quotes .
what u said is correct , i missed the quotes

function loading()
{
var passed = location.search.substring(1);
document.form2.month.value=getParm(passed,'month') ;
document.form2.year.options.value = getParm(passed,'year');
}

this is the right code
really sorry for this confusion , but its not working in mozilla

Thanks a lot
Jun 14 '07 #18
bha123
12
main problem i am finding with mozilla is ..

function loading()
{
var passed = location.search.substring(1);
document.form2.month.value=getParm(passed,'month') ;
alert(document.form2.month.value);
document.form2.year.value = getParm(passed,'year');
alert(document.form2.year.value);
}

in the above function is i am able to get mnth valuue properly
but not able to get the year value ..
alert(document.form2.month.value); ... gives me January
alert(document.form2.year.value);...... gives me nothing ,, its blank

This is the problem i am having with mozilla .. plz suggest me , the ways i can proceed
Thanks a lot
Jun 14 '07 #19
acoder
16,027 Expert Mod 8TB
Give your 'year' select options values, e.g.
[HTML]<option value="2000">2000</option>[/HTML]
Jun 14 '07 #20
bha123
12
Give your 'year' select options values, e.g.
[HTML]<option value="2000">2000</option>[/HTML]
Hi

I have given that already

Thanks
Jun 18 '07 #21
acoder
16,027 Expert Mod 8TB
I have given that already
You hadn't in post 13. Ok, what is the value of passed (the location.search string)?
Jun 19 '07 #22

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

Similar topics

2
by: Chand | last post by:
Hello Everyboy I am creating a small scale db with following fields in the table and form for the data entry purpose. Product ID Product Name Manufacturer Location 101 ...
3
by: Yul | last post by:
Hi, We are in the process of designing an ASP.NET app, where a user will enter some 'Customer ID' to be queried in the database. If the ID is valid, several stored procedures will be called to...
1
by: Flanman | last post by:
I have an ASP web form that I want to populate fields based on the first field choice. Example I have 4 fields item, price, delivery, availability. I have all these items setup in an access table....
1
by: vj | last post by:
How i can populate all fileds dynamically in jsp page based on contents found in xml file? I have written jsp servlets and java class file. i transferred automatic data from jsp to servlet then to...
0
by: vijendra | last post by:
How i can populate all fileds dynamically in jsp page based on contents found in xml file?I have written jsp servlets and java class file. i transferred automatic data from jsp to servlet then to...
1
by: dmeyr | last post by:
Hello, I am new to Access and am having difficulty with a Dlookup function. I have a form that I wish to autopopulate 10 fields with values based on two criteria which are also fields on the form....
5
by: joshua.nicholes | last post by:
I have an access database that consists of two tables.A data collection table and a species list table. The data collection table has about 1500 records in it and the species list has about 600....
0
by: SimpDogg | last post by:
Hey guys another Newbie here... I have a combobox(JobName) on my form tied to a table named (Jobs) with one field for all of the jobs in the comboxbox. I want to auto populate the Due Out Date...
4
by: whamo | last post by:
I have the need to populate a field based on the selection in a combo box. Starting out simple. (2) tables tbl_OSE_Info and tbl_Input; tbl_OSE_Info has three fields: Key, OSE_Name and OSE_Wt...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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: 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
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,...
0
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
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...

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.