AnsweredAssumed Answered

PHP Web: field submitted only if radio question checked with certain value

Question asked by carmean on Nov 12, 2016
Latest reply on Nov 13, 2016 by carmean

I have a two part online form (Filemaker 11 server, using custom web publishing PHP API)- the first asks for basic information (name, email, and whether graduate or undergraduate student).  The second ask more questions based on what they first answer.


In the first part if they answer that they are a graduate student I want a hidden field with all values of a value list submitted (this I have already coded).  If they are are not a graduate student I don't need the field to be submitted.  In the second part of the form graduate students will have the course_choices field pre-filled out with all the values checked, while all others have the form unchecked (I already have a simple javascript to check all choices, but for 'legal' reasons it needs to be checked on the initial submission for graduates.


I tried something simple with javascript but I have not figured out how to get the valuelist into it.

document.getElementById("hiddenfield").innerHTML = "<input type='text' name= '<?php echo getFieldFormName('course_choices', 0, $record, true, 'EDITTEXT', 'text');?>' value=''>";

****If I could define the variable $classvaluelist and put it into value='' it should work, but I was not able to get this to work...

$classvaluelist=(getInputChoices("nocheckbox", $layout->getValueListTwoFields('classlist', (isset($master_record)) ? $master_record->getRecordId() : $record->getRecordId()), 'text'));


I also was able to 'hide' the field with jquery but of course it still is submitted.


Here is the hidden field I want submitted with the valuelist inputted.

<input type="hidden" name= "<?php echo getFieldFormName('course_choices', 0, $record, true, 'EDITTEXT', 'text');?>" value="<?php getInputChoices("nocheckbox", $layout->getValueListTwoFields('classlist', (isset($master_record)) ? $master_record->getRecordId() : $record->getRecordId()), 'text');?>">


****I thought I could turn the valuelist into a variable

$classlistcheck=(getInputChoices("nocheckbox", $layout->getValueListTwoFields('classlist', (isset($master_record)) ? $master_record->getRecordId() : $record->getRecordId()), 'text'));


Here is the addition to fmview.php to put the valuelist into the value of the field:

if ($type == "nocheckbox"){

// turn some HTML with non-breaking spaces into a "normal" string

$myHTML = $encodedEachValue;

$converted = strtr($myHTML, array_flip(get_html_translation_table(HTML_ENTITIES, ENT_QUOTES)));

  echo (trim($converted,chr(0xC2).chr(0xA0)) ."\r ")  ;