components icon indicating copy to clipboard operation
components copied to clipboard

how get values of input radio inside alert()

Open Chevelle102 opened this issue 4 years ago • 0 comments

I can't get value of input because jquery not have access to interaction with alert..... this is example that using...

var selected = $("input[name='user']:checked").val(); console.log(selected); //undefined

<body class="padding">
  <button class="purple full radius margin-bottom" onclick="alertForm()">Finish process</button>

  <div class="hidden" id="template-alert-custom">
    <div class="list">
      <div class="item">
        <input type="text" placeholder="Add an comment about process..." autofocus>
      </div>
      <label class="item">
        <div class="left">
            <input type="radio" name="user" class="purple">
        </div>
        <h2>The process was well executed</h2>
      </label>
      <label class="item">
        <div class="left">
          <input type="radio" name="user" class="purple">
        </div>
        <h2>The process was run in error</h2>
      </label>
      <label class="item">
        <div class="left">
          <input type="radio" name="user" class="purple">
        </div>
        <h2>The process was not executed</h2>
      </label>
    </div>
  </div>

  <script>
    function alertForm(){
      alert({
        title:'Finish process',
        message:'Fill in the options to finalize the process',
        template: 'template-alert-custom',
        width:'90%',
        buttons:[
          {
            label: 'Finish'
          },
          {
            label:'Cancel'
          }
        ]
      });
    }
  </script>
</body>

Chevelle102 avatar May 20 '20 00:05 Chevelle102