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: 
I have tried the accepted answer's solution, it doesn't work for me, 

I had to use this `{{}}` curly braces (which is blade template's echo) in order to use the conditional statement.

```
<input type="radio" name="geckoHatchling" id="geckoHatchlingYes" value="1" {{(old('geckoHatchling') == '1') ? '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.