Re: [PHP] combo box validation
Hi Dave, In general, you can validate this condition with javascript before to send the form, and if some errors exist, the form is not submitted. or validate the conditions in the server side with php. Gerardo. www.webseficientes.com.ar On Mon, Jun 7, 2010 at 2:49 PM, David Mehler dave.meh...@gmail.com wrote: Hello, I've got a form with two combo boxes, one for the month one for the day. Both are required. I've got code that checks the post submission to ensure neither is empty. My problem is that if a user does not select anything in the combo boxes January first is sent, this i don't want. If they haven't selected anything i'd like that to show as an error. Thanks. Dave. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] combo box validation
On Tue, 2010-06-08 at 12:57 -0300, Gerardo Benitez wrote: Hi Dave, In general, you can validate this condition with javascript before to send the form, and if some errors exist, the form is not submitted. or validate the conditions in the server side with php. Gerardo. www.webseficientes.com.ar On Mon, Jun 7, 2010 at 2:49 PM, David Mehler dave.meh...@gmail.com wrote: Hello, I've got a form with two combo boxes, one for the month one for the day. Both are required. I've got code that checks the post submission to ensure neither is empty. My problem is that if a user does not select anything in the combo boxes January first is sent, this i don't want. If they haven't selected anything i'd like that to show as an error. Thanks. Dave. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php You should change that to 'and' instead of an 'or'. Javascript validation is nice, but you should always validate everything on the server too. Thanks, Ash http://www.ashleysheridan.co.uk
Re: [PHP] combo box validation
your advice is welcome! Gerardo www.webseficientes.com.ar On Tue, Jun 8, 2010 at 1:01 PM, Ashley Sheridan a...@ashleysheridan.co.ukwrote: On Tue, 2010-06-08 at 12:57 -0300, Gerardo Benitez wrote: Hi Dave, In general, you can validate this condition with javascript before to send the form, and if some errors exist, the form is not submitted. or validate the conditions in the server side with php. Gerardo.www.webseficientes.com.ar On Mon, Jun 7, 2010 at 2:49 PM, David Mehler dave.meh...@gmail.com wrote: Hello, I've got a form with two combo boxes, one for the month one for the day. Both are required. I've got code that checks the post submission to ensure neither is empty. My problem is that if a user does not select anything in the combo boxes January first is sent, this i don't want. If they haven't selected anything i'd like that to show as an error. Thanks. Dave. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php You should change that to 'and' instead of an 'or'. Javascript validation is nice, but you should always validate everything on the server too. Thanks, Ash http://www.ashleysheridan.co.uk -- Gerardo Benitez
[PHP] combo box validation
Hello, I've got a form with two combo boxes, one for the month one for the day. Both are required. I've got code that checks the post submission to ensure neither is empty. My problem is that if a user does not select anything in the combo boxes January first is sent, this i don't want. If they haven't selected anything i'd like that to show as an error. Thanks. Dave. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] combo box validation
On Mon, 2010-06-07 at 13:49 -0400, David Mehler wrote: Hello, I've got a form with two combo boxes, one for the month one for the day. Both are required. I've got code that checks the post submission to ensure neither is empty. My problem is that if a user does not select anything in the combo boxes January first is sent, this i don't want. If they haven't selected anything i'd like that to show as an error. Thanks. Dave. Make the first item in the select list something like this: option value=0 selected=selected-- select month --/option Then just check for the 0 value in PHP when the form is submitted. Thanks, Ash http://www.ashleysheridan.co.uk
[PHP] combo box
hi :) i am creating a webpage. i use a combo box to let user choose which folder they want. after they choose, it will be saved into the database. the next time they load this page, it will retrieve the data from database and appear at the combo box. i already done that. but now the problem isthe data that i retrieve from the database will same with the options in the combo box. so, it will become 2 same options. i am afraid this will confuse the user. so i want to fix it. if u dont understand what i mean, try look at the picture coding below: folder: husband friend family boss husband ___ this is the code: select size=1 name=groupMailbox1 option?php echo $row[groupMailbox1]; ?/option ?php //Open Directory you want to include //$base='/home/a/mail'; $handel = opendir($base); //Get contents of the directory while (false !== ($file = readdir($handel))) { if (is_dir($base . / . $file) ($file !== .) ($file !== ..)) { list($filename, $ext) = explode(., $file); list($main, $sub, $include) = explode(/, $PHP_SELF); echo option value=\$file\; //Echo the file name in a combo box if ($inc==$file) echo selected; echo$file/option\n; echo $file; } } ? /selectp/p ___ how to make it so that the data that we retrieve from database, if same with the options we have, we only need to make that option selected? thanks :) hweefarn __ Do you Yahoo!? Free Pop-Up Blocker - Get it now http://companion.yahoo.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Combo box selected value...
Sounds like you are working on a windows box with a bad battery back up for the clock! Bruce Karstedt President Technology Consulting Associates, Ltd. Tel: 847-735-9488 Fax: 847-735-9474 -Original Message- From: Miguel Cruz [mailto:[EMAIL PROTECTED]] Sent: Thursday, June 06, 2002 4:01 PM To: Alexandra Aguiar Cc: [EMAIL PROTECTED] Subject: Re: [PHP] Combo box selected value... On Fri, 4 Jan 1980, Alexandra Aguiar wrote: I got the followin code to generate a combo box... Your clock is off by about 20 years. Is it possible to fix it before posting to the list? Thanks. miguel -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Combo box selected value...
Hi ppl... I got the followin code to generate a combo box... ++ function comb_alfabeto( $resultado, $nome, $letra) { global $error; $quant = mysql_num_rows($resultado); If ($quant == 0) { $error-erro(); } Else { // Início da combbox $cont=0; echo(' select name='.$nome.' size=1'); echo(\n); while ($cont $quant) { echo(\n); echo(' option value='.mysql_result($resultado, $cont,$letra).''.mysql_result($resultado, $cont,$letra).'/option'); $cont++; } echo(\n /selected); } } +++ But, how can i return the selected item value into a variable $var ??? thnx in advance... Alexandra
Re: [PHP] Combo box selected value...
select name='.$nome.' size=1'); echo(\n); while ($cont $quant) { echo(\n); if ($blah == $bleh) { echo(' option value='.mysql_result($resultado, $cont,$letra).' selected'.mysql_result($resultado, $cont,$letra).'/option'); } else { echo(' option value='.mysql_result($resultado, $cont,$letra).''.mysql_result($resultado, $cont,$letra).'/option'); } $cont++; } echo(\n /selected); } } +++ But, how can i return the selected item value into a variable $var ??? That's normally how I do it... I'm not to sure on which values you need to do the comparison... It depends on what data you are returning from mysql I think -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Combo box selected value...
the value is returned in whatever is stored in $nome. So, if $nome=var, then $var will contain the selected value. - Original Message - From: Alexandra Aguiar [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Friday, January 04, 1980 12:56 PM Subject: [PHP] Combo box selected value... Hi ppl... I got the followin code to generate a combo box... ++ function comb_alfabeto( $resultado, $nome, $letra) { global $error; $quant = mysql_num_rows($resultado); If ($quant == 0) { $error-erro(); } Else { // Início da combbox $cont=0; echo(' select name='.$nome.' size=1'); echo(\n); while ($cont $quant) { echo(\n); echo(' option value='.mysql_result($resultado, $cont,$letra).''.mysql_result($resultado, $cont,$letra).'/option'); $cont++; } echo(\n /selected); } } +++ But, how can i return the selected item value into a variable $var ??? thnx in advance... Alexandra
Re: [PHP] Combo box selected value...
The value is returned in whatever is stored in $nome. So, if $nome=var, then $var will contain the selected value. Second, this could not possibly operate the way you want it to, because the mysql_result() is called TWICE with each line. You want it called only ONCE to retrieve the value for the VALUE parameter and the value displayed. - Original Message - From: Alexandra Aguiar [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Friday, January 04, 1980 12:56 PM Subject: [PHP] Combo box selected value... Hi ppl... I got the followin code to generate a combo box... ++ function comb_alfabeto( $resultado, $nome, $letra) { global $error; $quant = mysql_num_rows($resultado); If ($quant == 0) { $error-erro(); } Else { // Início da combbox $cont=0; echo(' select name='.$nome.' size=1'); echo(\n); while ($cont $quant) { echo(\n); echo(' option value='.mysql_result($resultado, $cont,$letra).''.mysql_result($resultado, $cont,$letra).'/option'); $cont++; } echo(\n /selected); } } +++ But, how can i return the selected item value into a variable $var ??? thnx in advance... Alexandra
Re: [PHP] Combo box selected value...
On Fri, 4 Jan 1980, Alexandra Aguiar wrote: I got the followin code to generate a combo box... Your clock is off by about 20 years. Is it possible to fix it before posting to the list? Thanks. miguel -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Combo Box containing field
Hi, Does anyone know how I can create a combo box in my php file that reads the options in from a database field? I can create combo boxes fine containing values that I enter, but I want it to read the values from the database into the drop down box for the user to select. Thanks, Michael.
Re: [PHP] Combo Box containing field
Hi Michael, Yes I do! Take a look at the code snippet below: echo "select name=something"; $level2 = $db-execute("select typename from types"); do { $value=$level2-fields[0]; echo "option value=$value$value/option"; $level2-nextRow(); } while (!$level2-EOF); $level2-close(); echo "/select"; Just change the query in the 2nd line of the code to the desired query. You'll see the result ;-) Best of luck, Ahmad Anvari da Code Guru - Original Message - From: RealGM To: [EMAIL PROTECTED] Sent: Saturday, March 10, 2001 4:21 PM Subject: [PHP] Combo Box containing field Hi, Does anyone know how I can create a combo box in my php file that reads the options in from a database field? I can create combo boxes fine containing values that I enter, but I want it to read the values from the database into the drop down box for the user to select. Thanks, Michael.
RE: [PHP] Combo Box containing field
On 10-Mar-01 RealGM wrote: Hi, Does anyone know how I can create a combo box in my php file that reads the options in from a database field? I can create combo boxes fine containing values that I enter, but I want it to read the values from the database into the drop down box for the user to select. Thanks, Michael. function selectoption($k, $v, $comp) { printf("OPTION VALUE=\"%s\" %s%s/OPTION\n", $k, $comp == $k ? "SELECTED" :"", $v); } $qry="select id,name) from country order by name"; $dbres = @mysql_query($qry); if ($dbres) { echo 'SELECT NAME=country SIZE="5"'; while ( $row = mysql_fetch_object($dbres)) { selectoption($row-id, $row-name, $usercountry); } echo "/SELECT\n"; } Regards, -- Don Read [EMAIL PROTECTED] -- If you are going to sin, sin against God, not the bureaucracy. God will forgive you but the bureaucrats won't. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]