Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. JavaScript
  4. Problems to obtain value "0" or "1" from a div

Problems to obtain value "0" or "1" from a div

Scheduled Pinned Locked Moved JavaScript
javascripthtmldatabasequestion
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    serenimus
    wrote on last edited by
    #1

    Hi!! so, I have this Ajax function vinculated to a change Jquery event:

                   $("#nif").change(function(){
    

    $.ajax({
    async:true,
    type:"POST",
    data:N,
    url:"basePath("alta/nuevouser/vernifduplicadoajax")?>",
    success:function(datos){
    $("#res").html(datos);

    				 }
    				 });
    
                                  });
    

    The matter is...that the result is or "1" (double register at DB) or "0" (no repeat), the value always appear in the div, depending of this result, I want to activate another

    and show a message an other operations.. to evaluate this value I do the next

    if($("#res").length !==0){
    var warn=parseInt(document.getElementById("res").innerHTML);
    alert(warn);
    }

    but I always receive (using alert();)..isNan ...that is, "is not a Number".. I`d need to evaluate: if(warn==1){ //do this }else{ //do that } Thanks a lot in advance!! :)

    Z 1 Reply Last reply
    0
    • S serenimus

      Hi!! so, I have this Ajax function vinculated to a change Jquery event:

                     $("#nif").change(function(){
      

      $.ajax({
      async:true,
      type:"POST",
      data:N,
      url:"basePath("alta/nuevouser/vernifduplicadoajax")?>",
      success:function(datos){
      $("#res").html(datos);

      				 }
      				 });
      
                                    });
      

      The matter is...that the result is or "1" (double register at DB) or "0" (no repeat), the value always appear in the div, depending of this result, I want to activate another

      and show a message an other operations.. to evaluate this value I do the next

      if($("#res").length !==0){
      var warn=parseInt(document.getElementById("res").innerHTML);
      alert(warn);
      }

      but I always receive (using alert();)..isNan ...that is, "is not a Number".. I`d need to evaluate: if(warn==1){ //do this }else{ //do that } Thanks a lot in advance!! :)

      Z Offline
      Z Offline
      ZurdoDev
      wrote on last edited by
      #2

      All that means is that document.getElementById("res").innerHTML does not contain a number. All you have to do is put a breakpoint there, run the code, and see what the value is and you'll figure out what is going on.

      Everyone is born right handed. Only the strongest overcome it. Fight for left-handed rights and hand equality.

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups