Jump to content
View in the app

A better way to browse. Learn more.

FMForums.com

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

I have created an event registration site using FM server advanced 9 and the php site assistant. I am now styling the registration page and have probably a silly question.

How do I get the 'Yes' from my checkboxes to not appear on the web? I am having registrants use checkboxes to list their employment interests and experience.

Thanks.

  • 6 months later...

I'm having the same problem except my checkboxes have a "1" after each one of them (my value list consists of only the "1" value).

I suspect it has everything to do with this function, found in fmview.php:

function getInputChoices($type, $valuelist, $fieldvalue, $fieldName) {

	$selected = "";

	$fieldValueArray = explode(" ", str_replace("n"," ", $fieldvalue));

	

	foreach ($valuelist as $eachvalue) {

		if (in_array(trim($eachvalue), $fieldValueArray)){

			$selected = " checked";

		}else{

			$selected = "";

		}

		if ($type == "checkbox"){

			echo "$eachvalue";

		}else{

			echo "$eachvalue";

		}

	}

}

Well, I guess the easiest way to do it would be to modify the function (which is seriously messed up by the way)...


function getInputChoices($type, $valuelist, $fieldvalue, $fieldName, $echoValue=true) {

	$selected = "";

	$valuedisplay="";

	$fieldValueArray = explode(" ", str_replace("n"," ", $fieldvalue));

	

	foreach ($valuelist as $eachvalue) {

		if (in_array(trim($eachvalue), $fieldValueArray)) $selected = " checked";

		else $selected = "";



		if( $echoValue ) $valuedisplay = $eachValue;

		if ($type == "checkbox"){

			echo "$valuedisplay";

		}else{

			echo "$valuedisplay";

		}

	}

}

Then, wherever you see a call to getInputChoices function after the last parameter that's in there by default, add: ,false e.g.

getInputChoices("checkbox", "somelist", "somevalue", "someFieldName", false);

Ahh, thanks for the tip Genx, but I tried that function and got a error saying "Undefined variable: eachValue". I think I fixed that by just including the line

$eachValue = "";

directly after the other variables being set as blank, and it almost works, except that now my checkbox looks like a regular text field (pre-populated with a "1").

So, I think I figured out a better way to get rid of the value lists… this method would just require you to designate this:

getInputChoices("checkbox_no_label", "somelist", "somevalue", "someFieldName");

instead of this:

getInputChoices("checkbox", "somelist", "somevalue", "someFieldName");

As you can see from the code below (compared to my original post above), I had to change the echoed html code to actually spell out 'checkbox' instead of simply calling '$type'.

function getInputChoices($type, $valuelist, $fieldvalue, $fieldName) {

	$selected = "";

	$fieldValueArray = explode(" ", str_replace("n"," ", $fieldvalue));

	

	foreach ($valuelist as $eachvalue) {

		if (in_array(trim($eachvalue), $fieldValueArray)){

			$selected = " checked";

		}else{

			$selected = "";

		}

		if ($type == "checkbox_no_label"){

			echo "";

		}else if ($type == "checkbox"){

			echo "$eachvalue";

		}else{

			echo "$eachvalue";

		}

	}

}

Sorry typo:


function getInputChoices($type, $valuelist, $fieldvalue, $fieldName, $echoValue=true) {

	$selected = "";

	$valuedisplay="";

	$fieldValueArray = explode(" ", str_replace("n"," ", $fieldvalue));

	

	foreach ($valuelist as $eachvalue) {

		if (in_array(trim($eachvalue), $fieldValueArray)) $selected = " checked";

		else $selected = "";



		if( $echoValue ) $valuedisplay = $eachvalue;

		if ($type == "checkbox"){

			echo "$valuedisplay";

		}else{

			echo "$valuedisplay";

		}

	}

}





  • 8 years later...

If you are using booleans, e.g. Yes/No,  since 

1. Code is processed sequentially

2. Only the last 'checked' answer is used. 

Therefore put the 'non' answer first but hide it and leave it always checked. The positive answer comes second. 

<?php $fieldName = 'Privacy_Agreement';?>
<?php $fieldValue = $record->getField($fieldName, 0) ; ?>
<input type='hidden' name='<?php echo (getFieldFormName($fieldName, 0, $record, true, 'EDITTEXT', 'number')) ;?>' value='No' checked>
<input type='checkbox' name='<?php echo (getFieldFormName($fieldName, 0, $record, true, 'EDITTEXT', 'number')-1) ;?>' value='Yes'  <?php if ($fieldValue == 'Yes'){ echo 'checked'; } ?>>

 You can insert whatever text before or after.  This works for me- I was searching for how to make a single checkbox work.

Create an account or sign in to comment

Important Information

By using this site, you agree to our Terms of Use.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.