Hello!!
Where does your IF Statement get its condition???
After looking at the Function validate(), you don't have a category
until later in the code. You use validate() to check the values after
the click the submit button(Add Item). Right???
One thing you could do is...Since it looks like only
$category=Printer...opens a new window...have a variable all ready equal
to Printer...in store1.php
Or does $category= a bucnh of things...and you just put in Printer
Or I'm I missing something...
Dan
On Wednesday, September 26, 2001, at 08:36 AM, its me wrote:
i know guys what u rtalking about but u can't see the problem:
the problem is this ?brand=? echo $something?
this something is value in javascript
or value of a form field in same page called
input name=category
but i can't make echo $category as the form isn't posted
there is no submit button,there is a normal button when clicked
there is a new window opened(an already existing .php file)
and i wanna pass a value to it
here is the whole thing:
?php
require(VALIDATE.PHP);
?
html
head
titleuploadnbsp; brandnbsp; logo/title
script language=JavaScript
!--
function validate()
{
if (document.forms[0].category.selectedIndex ==0)
{
alert(Please choose category.);
document.forms[0].category.focus();
return;
}
if (document.forms[0].subcategory.selectedIndex == 0)
{
alert(Please choose sub-category.);
document.forms[0].subcategory.focus();
return;
}
x=document.forms[0].subcategory.selectedIndex
y= document.forms[0].subcategory.options[x].text
if(y==Printers )
{
open(store1.php?brand=?php echo $category; ?,newWindow)
return
}
}
var ComputersArray = new Array(('Select Sub-category','',true,true),
('Desktops'),
('Notebooks'),
('Printers'),
('Monitors'));
function populateCountry(inForm,selected) {
var selectedArray = eval(selected + Array);
while (selectedArray.length inForm.subcategory.options.length) {
inForm.subcategory.options[(inForm.subcategory.options.length - 1)] =
null;
}
for (var i=0; i selectedArray.length; i++) {
eval(inForm.subcategory.options[i]= + new Option +
selectedArray[i]);
}
if (inForm.category.options[0].value == '') {
if ( navigator.appName == 'Netscape') {
if (parseInt(navigator.appVersion) 4) {
window.history.go(0);
}
else {
if (navigator.platform == 'Win32' || navigator.platform == 'Win16') {
window.history.go(0);
}
}
}
}
}
--
/script
/head
body
pnbsp;/p
form form name=globe method=POST action=store1.php
enctype=multipart/form-data
div align=center
center
table border=1 width=658 bgcolor=#FBE3FB cellspacing=5
tr
td bgcolor=#742E74 width=361font color=#FFChoose
brand name/font/td
td bgcolor=#FBE3FB width=281font color=#F0select
size=1 name=brand
optionNo specific brand
?php
require(CONNECT.PHP);
$sql=select distinct brand from brands
where companyname='$valcompanyname' ;
$result=mysql_query($sql,$conn);
$num=mysql_num_rows($result);
$cur=0;
while($num $cur)
{
$row=mysql_fetch_array($result);
$brand=$row[brand];
echo option$brand/option;
$cur++;
}
?
/select/font/td
/tr
tr
td bgcolor=#742E74 width=361font color=#FFUpload
brand image/font/td
td bgcolor=#FBE3FB width=281font color=#F0input
type=file name=file size=30
/font/td
/tr
tr
td bgcolor=#742E74 width=361font color=#FFChoose
category/font/td
td bgcolor=#FBE3FB width=281font color=#F0
select size=1 name=category
onChange=populateCountry(document.globe,document.globe.category.options[
document.globe.category.selectedIndex].value)
optionSelect Category/option
option value='Computers'Computers/option
option value='Jewelry'Jewelry/option
/select
/font/td
/tr
tr
td bgcolor=#742E74 width=361font
color=#F0Sub-category/font/td
td bgcolor=#FBE3FB width=281
select size=1 name=subcategory
/select
/td
/tr
input type=hidden name=add value=yes
/table
/center
/div
p align=centerinput type=button value=Add items
onClick=validate()input type=reset value=Reset name=B2/p
/form
?php
session_register(y);
include(footer.inc);
?
/body
/html
Date: Wed, 26 Sep 2001 08:22:04 -0500
Dan Brunner [EMAIL PROTECTED] [EMAIL PROTECTED] Re: [PHP-DB] i
know i caused u a headache:)
Yep
He is right...
Use php to do the variable
Dan
On Wednesday, September 26, 2001, at 08:05 AM, Dave Watkinson wrote:
you need to do ?brand=? echo $something; ?
-Original Message-
From: its me [mailto:[EMAIL PROTECTED]]
Sent: 26 September 2001 14:11
To: [EMAIL PROTECTED]
Subject: [PHP-DB] i know i caused u a headache:)
here