[FX.php List] FMP Checkbox

Gjermund Gusland Thorsen ggt667 at gmail.com
Thu Nov 1 10:38:05 MDT 2007


First of all your code is very hard to read "" in only needed for
escaped characters

I tried changing your code a little bit.

foreach( $ans01 as $value => $label) {
	$checked = $dJP['answer01'][0] == $value ? 'checked="checked"' : '';
	echo '<input name="answer01" type="radio" value="' . $value . '"' .
$checked . '>' . $label . "\n";
}

ggt667

On 11/1/07, Michael Layne <fx at 9degrees.com> wrote:
> It's been a while, but this is what I do for radio buttons...
>
>  foreach($ans01 as $value => $label) {
>  $checked = $dJP['answer01'][0] == $value ? "checked=\"checked\"" : "";
>  echo "<input name=\"answer01\" type=\"radio\" value=\"" . $value . "\"
> $checked />" . $label . "\n";
>  }
>
> then this is how I post back into the database:
>
> // type == 1 is if I'm modifying the record as opposed to creating it - I
> use the same form/page for both with a variable...
> isset($_POST['answer01']) ? ($type[1] == '1' ? $answer01 = implode (",
> ",$_POST['answer01']) : $answer01 = $_POST['answer01']) : $answer01 = '';
>
>
> for checkboxes:
>
>  foreach($ansLanguage as $value => $label) {
>  $checked = ( eregi($value,$dJP['language'][0])) ?
> "checked=\"checked\"" : "";
>  echo "<input name=\"language[]\" type=\"checkbox\" value=\"" . $value . "\"
> $checked />" . $label . "\n";
>  }
>
> then posting to the database:
>
> isset($_POST['language']) ? $language = implode (", ",$_POST['language']) :
> $language = '';
>
> so in FileMaker, the data looks like "Yes, No, Maybe, Sort Of" or "English,
> German, Dutch, French"
>
>
>
> HTH.  Need more details, let me know...
>
> Michael
>
> Michael Layne  |  9 degrees development  |  www.9degrees.com  |
> 404.226.7835 [m]  |   Skype: LayneBay
>
>
>
> On Nov 1, 2007, at 5:35 AM, Roger Price wrote:
>
> Thank you all for your various suggestions. Using '\n' rather than
> ''chr(10)' seems to have worked fine but only if I do the concatenation the
> 'tedious' way!
>
> Passing the checkbox values in an array seems very neat and works exactly as
> suggested. However when I implode the array with '\n' as the separator the
> resultant variable gives me:
>
> 'value1\nvalue1\nvalue3'  which of course does not give the desired result
> in FMP.
>
> Why shoumd this be - am I missing something?
>
> BTW Gjermund when do you expect the FX.php update that includes a checkbox
> feature to be released?
>
> kindest regards
>
> Roger
>
> ----- Original Message -----
> From: "Gjermund Gusland Thorsen" <ggt667 at gmail.com>
> To: "FX.php Discussion List" <fx.php_list at mail.iviking.org>
> Sent: Thursday, November 01, 2007 12:31 AM
> Subject: Re: [FX.php List] FMP Checkbox
>
>
>
> Never mess with the array cowboys ;-) They Rock!
>
> arrays and foreach are really one of the most beautiful combinations
> in php AFAIK.
>
> and heredoc to let your brains focus on anything but quotes ;-)
>
> On 11/1/07, Tim 'Webko' Booth <tim at nicheit.com.au> wrote:
> At 10:16 PM 31/10/2007, you wrote:
> BTW did you ever consider using arrays?
>
> <input type=checkbox name="name[]" value="<<$recid>>"
>
> As a note - this method rocks compared to anything else I've tried.
>
> Concatenation for large checkbox sets is tedious, and you can still
> end up with nothing but a heap of returns - the above creates a
> lovely array to play with :-0
>
> Webko
>
>
> _______________________________________________
> FX.php_List mailing list
> FX.php_List at mail.iviking.org
> http://www.iviking.org/mailman/listinfo/fx.php_list
>
>
> _______________________________________________
> FX.php_List mailing list
> FX.php_List at mail.iviking.org
> http://www.iviking.org/mailman/listinfo/fx.php_list
>
>
>
> _______________________________________________
> FX.php_List mailing list
> FX.php_List at mail.iviking.org
> http://www.iviking.org/mailman/listinfo/fx.php_list
>
>
>
> _______________________________________________
> FX.php_List mailing list
> FX.php_List at mail.iviking.org
> http://www.iviking.org/mailman/listinfo/fx.php_list
>
>


More information about the FX.php_List mailing list