0

I have a problem with getting value from a radio from a sweet alert. I want to give value from a radio to my HTML page.

addTags is a button, radioV is from <p id="radioV"></p> in html.

Any ideas?

$scope.addToTags = function() {
  var inputOptions = new Promise(function(resolve) {
    setTimeout(function() {
      resolve({
        'n': 'nouns',
        'a': 'adjectives',
        'v': 'verbs',
        'o': 'others',
        'i': 'idioms',
        'a': 'all'
      })
    }, 1000)
  })
  swal({
      title: 'Select only one:',
      input: 'radio',
      inputOptions: inputOptions,
      inputValidator: function(result) {
        return new Promise(function(resolve, reject) {
          if (result) {
            resolve()
          } else {
            reject('You need to select something!')
          }
        })
      }
    })
    .then(function(result) {
      swal({
        type: 'success',
        html: 'You selected: ' + result
      })
    })
    .then(function(result) {
      $('#radioV').attr(result).val();
    })
};
mplungjan
  • 169,008
  • 28
  • 173
  • 236
Djn
  • 9
  • 3
  • Please update the snippet I made fo you with relevant HTML and external resources from CDNs in a [mcve] – mplungjan May 22 '17 at 09:31
  • P's do not have values - neither do their attributes - also if they did you need to show it somewhere: `console.log($('#radioV').attr(result));` – mplungjan May 22 '17 at 09:32

0 Answers0