Question: This is my `employeeshift.js` code and I can't figure out how to do a PHP code in a JavaScript file

This is my code inside the `employeeshift.js` but my `var inorno` is null

```
$(document).ready(function(){

var inorno= "<?php echo json_encode($inOrOut ); ?>";

if(inorno=="0"){

 $('.Sales1').hide();
 }else{
$('.Sales1').show();
} 

});

```

Answer: 
You can use `Form-helper`, but it doesn't come out of the box with Laravel. You should install it manually. [Please read the docs.](http://laravelcollective.com/docs/5.0/html)

**WITH FORM-HELPER**

**1. Blade**

```
{!! Form::radio('geckoHatchling', '1', (Input::old('geckoHatchling') == '1'), array('id'=>'geckoHatchlingYes', 'class'=>'radio')) !!}
{!! Form::radio('geckoHatchling', '0', (Input::old('geckoHatchling') == '0'), array('id'=>'geckoHatchlingNo', 'class'=>'radio')) !!}

```

**2. PHP**

```
echo Form::radio('geckoHatchling', '1', (Input::old('geckoHatchling') == '1'), array('id'=>'geckoHatchlingYes', 'class'=>'radio'));
echo Form::radio('geckoHatchling', '0', (Input::old('geckoHatchling') == '0'), array('id'=>'geckoHatchlingNo', 'class'=>'radio'));

```

**WITHOUT FORM-HELPER**

**1. Blade**

```
<input type="radio" name="geckoHatchling" id="geckoHatchlingYes" value="1" @if(Input::old('geckoHatchling')) checked @endif>
<input type="radio" name="geckoHatchling" id="geckoHatchlingNo" value="0" @if(!Input::old('geckoHatchling')) checked @endif>

```

**2. PHP**

```
<input type="radio" name="geckoHatchling" value="1" class="radio" id="geckoHatchlingYes" <?php if(Input::old('geckoHatchling')== "1") { echo 'checked'; } ?> >
<input type="radio" name="geckoHatchling" value="0" class="radio" id="geckoHatchlingNo" <?php if(Input::old('geckoHatchling')== "0") { echo 'checked'; } ?> >

```
I have stumbled across what I believe will be to be a more accurate and comprehensive answer to this question. The problem with the main answer provided is the last radio button will always be selected moving forward. However, I have provided a code example below to show how to resolve this issue. (PS - this works in Laravel 8, and, I'm only assuming it will work for previous versions)

```
<div> <input type="radio" name="role" value="teacher" @if(old('role') == 'teacher') checked @endif> </div>

<div> <input type="radio" name="role" value="student" @if(old('role') == 'student') checked @endif> </div>

<div> <input type="radio" name="role" value="assistant" @if(old('role') == 'assistant') checked @endif> </div>

```

Just using:

```
@if(old('role') checked @endif

```

will always result in your last radio button being selected if you have multiple radio buttons.