1

I've got a form that calculates how many times a person has chosen a value. Each question has 3 answers with a value of either "self", "others", or "social". Whichever has the MOST gets returned as the result.

Ultimately, I need a custom post field hidden from the user, populated with this result. Currently it's being display after form submission with:

return $confirmation

I've got http://pastie.org/3312298 pasted in the bottom of my functions.php file.

I'm not quite sure how to get the result into the box before the form gets submitted to us as an entry.

www.webdesignsalemoregon.com/surveytest

is where it's lying right now

colithium
  • 10,269
  • 5
  • 42
  • 57
Xhynk
  • 13,513
  • 8
  • 32
  • 69

1 Answers1

1

You're taking a way complicated route of doing this.

give each radio button for 'self' <input name='self'>, and do the same for the rest

$self_answers = count($_POST['self']);
$others_answers = count($_POST['others']);
$social_answers = count($_POST['social']);

$max = max($self_answers, $others_answers, $social_answers) ; 

if($max == $self_answers) {
    $greatest = "self";
} else if($max == $others_answers) {
    $greatest = "others";
} else {
    $greatest = "social";
}
dvicino
  • 1,469
  • 1
  • 11
  • 19
phpguy
  • 11
  • 1
  • The code I've got in there was given to me by a Gravity Forms developer, and it works (convoluted or not). I just need to get the calculated value to prepopulate a custom field before the form gets submitted to us – Xhynk Feb 04 '12 at 00:12