Re: i know i caused u a headache:)
| From: | Dan Brunner | Date: | Wed, 26 Sep 2001 15:44:29 +0000 |
| Subject: | Re: i know i caused u a headache:) | ||
| References: | 1 | Groups: | php.db |
| Request: | Send a blank email to php-db+get-12728@lists.php.net to get a copy of this message | ||
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> <title>upload brand 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> <p> </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="361"><font color="#FFFFFF">Choose brand name</font></td> <td bgcolor="#FBE3FB" width="281"><font color="#FFFFF0"><select size="1" name="brand">< <option>No 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="361"><font color="#FFFFFF">Upload brand image</font></td> <td bgcolor="#FBE3FB" width="281"><font color="#FFFFF0"><input type=file name=file size=30> </font></td> </tr> <tr> <td bgcolor="#742E74" width="361"><font color="#FFFFFF">Choose category</font></td> <td bgcolor="#FBE3FB" width="281"><font color="#FFFFF0"> <select size="1" name="category" onChange="populateCountry(document.globe,document.globe.category.options[document.globe.category.selectedIndex].value)"><option>Select Category</option><option value='Computers'>Computers</option> <option value='Jewelry'>Jewelry</option> </select></font></td> </tr> <tr> <td bgcolor="#742E74" width="361"><font color="#FFFFF0">Sub-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="center"><input 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 <dan.brunner@duni.com> php-db@lists.php.net 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:fotna@egypt.net] Sent: 26 September 2001 14:11 To: php-db@lists.php.net Subject: [PHP-DB] i know i caused u a headache:) here is my situation: i select a category on store.php(from a form) then in the same page i have a javascript that tells: x=document.forms[0].subcategory.selectedIndex-- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: php-db-unsubscribe@lists.php.net For additional commands, e-mail: php-db-help@lists.php.net To contact the list administrators, e-mail: php-list- admin@lists.php.nety= document.forms[0].subcategory.options[x].text if(y=="Printers" ) { windowopen("store1.php","newWindow") return }so i'll open a .php page i already have and according to the category that is selected a different page will be opened..ok? what i need is to have the value of the field category in the stor1.php page i tried to do it withsession(its the only point i got from u:)) but how ??? the variable y is what i wanna register...but its within javascript..i couldn't write like this: session_register("y") so????i hope u got me.... i tried: open("store1.php?brand='y'","newWindow") but then brand =y ------------------------------------------------------------ ------------------------------------------------------------ -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: php-db-unsubscribe@lists.php.net For additional commands, e-mail: php-db-help@lists.php.net To contact the list administrators, e-mail: php-list- admin@lists.php.net -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: php-db-unsubscribe@lists.php.net For additional commands, e-mail: php-db-help@lists.php.net To contact the list administrators, e-mail: php-list- admin@lists.php.net