Documentation

InputType

string
InputType(
 string type,
 string name,
 string value,
 mixed Cmp,
 bool print_value = false,
 string Print = "",
 string add_to_tag = "",
 string Id=""
);

The function returns the HTML code of <input type="checkbox"> tags (selector with multiple reply options), or <input type="radio"> (selector with single reply option).

Function parameters

ParameterDescription Available from version
type Tag type:
<input type="type" ... >

Possible values:
  • checkbox - selector with multiple reply options
  • radio - selector with single reply option
name Tag name:
<input name="name" ... >
value Tag value:
<input value="value" ... >
Cmp This parameter value will be compared with the value parameter: if they match - the selector action will be "checked":
<input checked ... >
print_value If "true", the value of the "true" parameter wil be printed to the right of the tag.
Optional parameter. By default the value is false.
Print If the print_value parameter is not equals true and the title parameter has a specified value, it will be printed on the right of the tag.
Optional parameter. By default the default value is "".
field1 Arbitrary HTML code that will be added to the tag:
<input add_to_tag ... >
Optional parameter. By default value is "".
Id Optional parameter. By default value is "".

Examples of use

<?
// Multiple selection

echo "Selection result:<pre>"; print_r($check); echo "</pre>";
echo "Select the desired options:<br>";
?>
<form action="" method="GET">
<?
echo "1:".InputType("checkbox", "check[]", "1", $check)."<br>";
echo "2:".InputType("checkbox", "check[]", "2", $check)."<br>";
echo "3:".InputType("checkbox", "check[]", "3", $check)."<br>";
?>
<br><input type="submit" value="OK">
</form>
<?
// Single selection

echo "Selection result: ".$radio."<br><br>";
echo "Select one of the following options:<br>";
?>
<form action="" method="GET">
<?
echo "1: ".InputType("radio", "radio", "1", $radio)."<br>";
echo "2: ".InputType("radio", "radio", "2", $radio)."<br>";
echo "3: ".InputType("radio", "radio", "3", $radio)."<br>";
echo "4: ".InputType("radio", "radio", "4", $radio)."<br>";
?>
<br><input type="submit" value="OK">
</form>


© «Bitrix24», 2001-2022
Up