Re: [PHP] form handling

2011-08-12 Thread Ashley Sheridan


Chris Stinemetz chrisstinem...@gmail.com wrote:


 I would bet it's the quotes screwing up the js. Can / are you
escaping that variable when ajaxing it back?

 Bastien Koert
 905-904-0334


I found a way to make the ajax work with one form. I removed the table
and the ajax worked just fine. Aparently you can't embed div
containers within a table without affecting the whole table. At least
that is what I found out tonight. Please correct me if I am wrong.

Chris

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Without seeing your code, its hard to figure out what is happening. Post it 
onto pastebin or something (large code excerpts are very hard to read on this 
mailing list). Often, running the code through validator.w3.org will find 
issues that are affecting your layout.
Thanks,
Ash
http://www.ashleysheridan.co.uk
--
Sent from my Android phone with K-9 Mail. Please excuse my brevity.

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] form handling

2011-08-12 Thread jean-baptiste verrey
it's (pretty) easy to send two forms at once with jquery nowadays, you just
get all the input of the 2 forms and post them!

function submit2Forms(form1DomId,form2DomId){
$datas={};
$(form1DomId).find(':input').each(function(){
if(($(this).attr('name') 
$(this).attr('type')!='checkbox') || ($(this).attr('type')=='checkbox' 
$(this).is(':checked')))
$datas[$(this).attr('name')]=$(this).val();
});
$(form2DomId).find(':input').each(function(){
if(($(this).attr('name') 
$(this).attr('type')!='checkbox') || ($(this).attr('type')=='checkbox' 
$(this).is(':checked')))
$datas[$(this).attr('name')]=$(this).val();
});
$.post(URL,function(html) {


  $('body').html(html);

})
return false;
});

it's just a small example so you can see how you can do it!


On 12 August 2011 08:48, Ashley Sheridan a...@ashleysheridan.co.uk wrote:



 Chris Stinemetz chrisstinem...@gmail.com wrote:

 
  I would bet it's the quotes screwing up the js. Can / are you
 escaping that variable when ajaxing it back?
 
  Bastien Koert
  905-904-0334
 
 
 I found a way to make the ajax work with one form. I removed the table
 and the ajax worked just fine. Aparently you can't embed div
 containers within a table without affecting the whole table. At least
 that is what I found out tonight. Please correct me if I am wrong.
 
 Chris
 
 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php

 Without seeing your code, its hard to figure out what is happening. Post it
 onto pastebin or something (large code excerpts are very hard to read on
 this mailing list). Often, running the code through validator.w3.org will
 find issues that are affecting your layout.
 Thanks,
 Ash
 http://www.ashleysheridan.co.uk
 --
 Sent from my Android phone with K-9 Mail. Please excuse my brevity.

 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php




[PHP] form validation

2011-08-12 Thread Chris Stinemetz
I have a select menu created by a foreach loop. I am trying to
validate that there was a selection made before it is submitted to the
database. But I am not doing something correctly.

select name=market class=ajax
onchange=javascript:get(this.parentNode);
option value=Choose.../option
?php   
foreach($market_prefix as $key = $value)
{
$selected = '';
if($value == $market)
{
$selected = 'selected';
}
echo 'option value=', htmlspecialchars($value), ' ', $selected,
'', htmlspecialchars($market_name[$key]), '/option';
}
?
/select

I am using the folling on the posted page.

if (! array_key_exists($_POST['market'], $market_name))
{
echo You did not select a market.;
}

Thank you,

Chris

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] form validation

2011-08-12 Thread Daniel P. Brown
On Fri, Aug 12, 2011 at 11:42, Chris Stinemetz chrisstinem...@gmail.com wrote:
 I have a select menu created by a foreach loop. I am trying to
 validate that there was a selection made before it is submitted to the
 database. But I am not doing something correctly.

Try using a combination of isset, empty, and is_null() instead:

?php

if (!isset($_POST['market']) || empty($_POST['market']) ||
is_null($_POST['market'])) {
// Wasn't set
}

?


-- 
/Daniel P. Brown
Dedicated Servers, Cloud and Cloud Hybrid Solutions, VPS, Hosting
(866-) 725-4321
http://www.parasane.net/

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] form validation

2011-08-12 Thread Richard Quadling
On 12 August 2011 16:42, Chris Stinemetz chrisstinem...@gmail.com wrote:
 I have a select menu created by a foreach loop. I am trying to
 validate that there was a selection made before it is submitted to the
 database. But I am not doing something correctly.

 select name=market class=ajax
 onchange=javascript:get(this.parentNode);
 option value=Choose.../option
 ?php
    foreach($market_prefix as $key = $value)
        {
        $selected = '';
        if($value == $market)
        {
        $selected = 'selected';
        }
        echo 'option value=', htmlspecialchars($value), ' ', $selected,
 '', htmlspecialchars($market_name[$key]), '/option';
        }
        ?
 /select

 I am using the folling on the posted page.

 if (! array_key_exists($_POST['market'], $market_name))
 {
    echo You did not select a market.;
 }

 Thank you,

 Chris

$_POST['market'] won't exist if you haven't chosen one.

Turn on your error reporting and you should see something appropriate.

At a bare minimum, adding ...

isset($_POST['market'])

as the first thing to test (before seeing if the value is in
$market_name (though I would have thought $market_names would have
been a better name for the variable - implies more than 1 market).


-- 
Richard Quadling
Twitter : EE : Zend : PHPDoc
@RQuadling : e-e.com/M_248814.html : bit.ly/9O8vFY : bit.ly/lFnVea

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php