0

View: Form content

{{Form::label('dipno', 'No')}}

{{Form::radio('diploma','No',['id'=>'dip','onclick'=>'hasNoDip();'])}}
{{Form::number('diplomamarks','',['class' => 'form-control','max'=>'100','step'=>'0.01','id'=>'abc'])}}

JavaScript

This is the JavaScript code

<script>
        function hasNoDiploma() {
            document.getElementById('abc').disabled=false;
            return true;
        }
</script>

I have added the script tag below in the form blade. (I have tried adding it in the separate JS file and then linked it in my blade template still it was not working)

But the onclick function is not working. Is there another method to achieve this, or have I done something wrong?

What I want to achieve by this code is when I select the radio button a form field in the bottom should be hidden and vice versa.

halfer
  • 19,824
  • 17
  • 99
  • 186
Curious Coder
  • 33
  • 1
  • 6

1 Answers1

1

What i see is you are calling a javascript function that doesn't exist hasNoDip() the function you defined is hasNoDiploma()

and you are missing the form builder selected property so the line will be

{{Form::radio('diploma','No', false, ['id'=>'dip','onclick'=>'hasNoDiploma();'])}}
mmabdelgawad
  • 2,385
  • 2
  • 7
  • 15