473,480 Members | 3,106 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Auto updation problem

1 New Member
Hi all,

I have a javascript that is reloading itself on every menu change, Now the problem is that the values of the product doesn`t reset itself on catalogue change,

the code is

[HTML]
<html>
<head>
<title></title>
</head>
<body>
<SCRIPT language=JavaScript>
function reload(form)
{
// Setting the variable with the value of selected country's ID
var val=populate.catalogue.options[populate.catalogue.options.selectedIndex].value;
self.location='eform.php?catalogueId=' + val;
var val2=val+'&categoryID='+populate.category.options[populate.category.options.selectedIndex].value;
self.location='eform.php?catalogueId=' + val2;
var val3=val2+'&productsID='+populate.products.options[populate.products.options.selectedIndex].value;
self.location='eform.php?catalogueId=' + val3;
var val3=val2+'&quantityID='+populate.quantity.options[populate.quantity.options.selectedIndex].value;
self.location='eform.php?catalogueId=' + val3;
}
JOptionPane.showMessageDialog(frame, "Eggs aren't supposed to be green.");
</script>
<?php
function getCatalogueList()
{ $catalogue = array (
'1' => 'Catalogue',
'2' => 'Non - Catalogue',
);
return $catalogue;
}
function getCategoryList($catalogueId)
{
$category= array (
'Catalogue' => array ('CD', 'SD', 'AG', 'FD', 'CM', 'TB', 'GB', 'TG', 'MD', 'PD' ),
);
return $category[$catalogueId];
}
function getProductList($categoryID)
{
$products= array (
'CD' =>array ('CD001 ' , ' CD002 ' , ' CD003 ' , ' CD004 ' , ' CD005 ' , ' CD006 ' , ' CD007 ' , ' CD008 ' , ' CD009 ' , ' CD010 ' , ' CD011 ' , ' CD012 ' , ' CD013 ' , ' CD014 ' , ' CD015 ' , ' CD016 ' , ' CD017 ' , ' CD018 ' , ' CD019 ' , ' CD020 ' , ' CD021 ' , ' CD022 ' , ' CD023 ' , ' CD024 ' , ' CD025 ' , ' CD026 ' , ' CD027 ' , ' CD028 ' , ' CD029 ' , ' CD030 ' , ' CD031 ' , ' CD032 ' , ' CD033 ' , ' CD034 ' , ' CD035 ' , ' CD036 ' , ' CD037 ' , ' CD038 ' , ' CD039 ' , ' CD040 ' , ' CD041 ' , ' CD042 ' , ' CD043 ' , ' CD044 ' , ' CD045 ' , ' CD046 ' , ' CD047 ' , ' CD048 ' , ' CD049 ' , ' CD050 ' , ' CD051 ' , ' CD052 ' , ' CD053 ' , ' CD054 ' , ' CD055 ' , ' CD056 ' , ' CD057 ' , ' CD058 ' , ' CD059 ' , ' CD060 ' , ' CD061 ' , ' CD062'),

'SD' => array (' SD001 ' , ' SD002 ' , ' SD003 ' , ' SD004 ' , ' SD005 ' , ' SD006 ' , ' SD007 ' , ' SD008 ' , ' SD009 ' , ' SD010 ' , ' SD011 ' , ' SD012 ' , ' SD013 ' , ' SD014 ' , ' SD015 ' , ' SD016 ' , ' SD017 ' , ' SD018 ' , ' SD019 ' , ' SD020 ' , ' SD021 ' , ' SD022 ' , ' SD023 ' , ' SD024 ' , ' SD025 ' , ' SD026 ' , ' SD027 ' , ' SD028 ' , ' SD029 ' , ' SD030 ' , ' SD031 ' , ' SD032 ' ),

'FD' => array(' FD001 ' , ' FD002 ' , ' FD003 ' , ' FD004 ' , ' FD005 ' , ' FD006 ' , ' FD007 ' , ' FD008 ' , ' FD009 ' , ' FD010 ' , ' FD011 ' , ' FD012 ' , ' FD013 '),

'AG' => array(' AG001 ' , ' AG002 ' , ' AG003 '),

'GB' => array(' GB001 ' , ' GB002 ' , ' GB003 ' , ' GB004 ' , ' GB005 ' , ' GB006 ' , ' GB007 ' , ' GB008 ' , ' GB009 ' , ' GB010 ' , ' GB011 ' , ' GB012 ' , ' GB013 ' , ' GB014 ' , ' GB015 ' , ' GB016 ' , ' GB017 ' , ' GB018 ' , ' GB019 ' , ' GB020 ' , ' GB021 ' , ' GB022 '),

'CM' => array(' CM001 ' , ' CM002 ' , ' CM003 ' , ' CM004 ' , ' CM005 ' , ' CM006 ' , ' CM007 ' , ' CM008 ' , ' CM009 ' , ' CM010 ' , ' CM011 ' , ' CM012 ' , ' CM013 ' , ' CM014 ' , ' CM015 ' , ' CM016 ' , ' CM017 ' , ' CM018 ' , ' CM019 ' , ' CM020 ' , ' CM021 ' , ' CM022 ' , ' CM023 ' , ' CM024 ' , ' CM025 ' , ' CM026 ' , ' CM027 ' , ' CM028 ' , ' CM029 ' , ' CM030 ' , ' CM031 ' , ' CM032 ' , ' CM033 '),

'TB' => array( ' TB001 ' , ' TB002 ' , ' TB003 ' , ' TB004 ' , ' TB005 ' , ' TB006 ' , ' TB007 ' , ' TB008 ' , ' TB009 ' , ' TB010 ' , ' TB011 ' , ' TB012 ' , ' TB013 '),

'TG' => array(' TG001 ' , ' TG002 ' , ' TG003 ' , ' TG004 ' , ' TG005 ' , ' TG006 ' , ' TG007 ' , ' TG008 ' , ' TG009 ' , ' TG010 ' , ' TG011 ' , ' TG012 ' , ' TG013 ' , ' TG014 ' , ' TG015 ' , ' TG016 ' , ' TG017 ' , ' TG018 ' , ' TG019 ' , ' TG020 ' , ' TG021 ' , ' TG022 ' ),

'MD' => array(' MD001 ' , ' MD002 ' , ' MD003 ' , ' MD004 ' , ' MD005 ' , ' MD006 ' , ' MD007 ' , ' MD008 ' , ' MD009 ' , ' MD010 ' , ' MD011 '),

'PD' => array( ' PD001 ' , ' PD002 ' , ' PD003 ' ),

);
return $products[$categoryID];
}
?>

<form action="eform.php" name="populate" method="post">
<?
// Retrieving the country list
$catalogue = getCatalogueList();

// Setting the variable if the country is selected for its city list
@$catalogueId = $_GET['catalogueId'];
@$categoryID = $_GET['categoryID'];
@$productsID = $_GET['productsID'];

// Retrieving the city list if a country is selected
$category= ($catalogueId) ? getCategoryList($catalogueId) : null;
$products= ($categoryID) ? getProductList($categoryID) : null;
if (!empty($catalogue))
{
// Generating the catalogue drop down menu
echo "<select onChange='reload(this.form)' name='catalogue'>";
foreach ($catalogue as $value)
{
echo "<option value='$value'";
if ($catalogueId == $value)
echo "selected";
echo ">$value</option>";

}
echo "</select>";
}
if (!empty($category))
{
// Generating the category drop down menu if a catalogue is selected
echo "<select onChange='reload(this.form)' name='category'>";
foreach ($category as $value)
{
echo "<option value='$value'";
if ($categoryID == $value)
echo "selected";
echo ">$value</option>";
}
echo "</select>";
}
if (!empty($products))
{
// Generating the products drop down menu if a country is selected
echo "<select onChange='reload(this.form)' name='products'>";
foreach ($products as $value)
{
echo "<option value='$value'";
if ($productsID== $value)
echo "selected";
echo ">$value</option>";
}
echo "</select>";
}
?>
</body>
</html>
[/HTML]

I want the Product also to be resetted on changing the catalgoue value
Aug 30 '07 #1
1 1458
phvfl
173 Recognized Expert New Member
Hi,

Welcome to TSDN...

Just have to ask a few questions first as I am not fluent with PHP so I want to make sure that I understand all the client side stuff.

Whenever any of the selects (catalogue, category, products) are changed you refresh the page using the reload javascript. You then parse the values of the select boxes so that the values can be added into the querysring and you redirect the browser so that the page can be refreshed on the server side.

If this is the case then there are a couple of issues that seem to effect this. Firstly you are repeatedly using the self.location property. You should avoid doing this as what would happen if that four calls to the server are issued, one for each of the self.location statements. If you build up your querystring and then do one self.location change this should improve the script.

Secondly you try to use the value of an option for quantity, this does not seem to be in the HTML, in the javascript it also assigns this to val3 which is already used for category.

I would try the javascript as follows:
Expand|Select|Wrap|Line Numbers
  1. function reload(form){
  2.  
  3. // Setting the variable with the value of selected country's ID
  4.  
  5. var $catalogue = populate.catalogue.options[populate.catalogue.options.selectedIndex].value;
  6.  
  7. var $category = populate.category.options[populate.category.options.selectedIndex].value;
  8.  
  9. var $products populate.products.options[populate.products.options.selectedIndex].value;
  10.  
  11. self.location='eform.php?catalogueId=' + $catalogue + '&categoryID=' + $category + '&products=' + $products;
  12. }
  13.  
I have loaded the values of the options into variables and then built up the redirection URL and done the redirect the once.

Hope this helps

P.S. The dollar notation is just something that I use to help distinguish variables in javascript and make sure that I don't use any reserved words for variable names. It will not interfere with the PHP.
Aug 30 '07 #2

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

Similar topics

1
1403
by: AA | last post by:
We want to edit, update data of DataGrid in Asp.Net with VB.Net.and are writing the following code for EditCommand and UpdateCommand Event is : DataGrid1_EditCommand
0
1069
by: Lakshmi Narayanan.R | last post by:
Hi Experts I am new to .NET. I need great explanation for "the updation in the disconnected data". How it is handled. That is, if mutiple user is interacting with the data, one will delete another...
1
1191
by: Babz | last post by:
Hi, How I can prevent concurrent updation of a records in .net. I am using Dataset which is disconnected from the data source. In this situation if two users opens the same record, modifies the...
1
2021
by: r2destini | last post by:
Hi Friends, I am new to .Net. So I don't know much. I am facing a problem in updating database through ADO.Net I am creating the dataset and there is no problem in the updation and...
0
1279
by: prashant | last post by:
Hi, I am trying to set up Transactional replication with immediate updation. The configuration is as follows: 1. Publisher is SQL server 2000 Enterprise Edition, and Distributor is on the...
0
806
by: hellboss | last post by:
Hi Everyone ! Im using asp.net vs05 , I have a Couple of Table adapter ( in the Xsd file) which is used for updation and Insertion and viewing , What i Exactly needed is a code to Auto...
1
1824
by: roshan56us | last post by:
Hi, i have problem in updation of access database, which is in backend and Visual basic as front end. its using 800 records in MS-Access but,while updating the database, it doesn't update sometime...
2
1389
by: jestin | last post by:
hi friends we have a ASP intranet system and its backend is in MSAccess now we r upgrading its back end with Oracle 8i. and i have a problem regarding the record set updation the code is as...
1
1667
by: siri11 | last post by:
Hi everyone!!!!!!!!! If i update a record in a table in sqlserver from front end (c#.net),using a stored procedure for updating then after updation if i open the table then it is showing the same...
0
7055
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
6920
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
7061
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
6763
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
5367
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
4799
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
3015
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
3011
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
210
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...

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.