Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie
Hi there,
There is an issue with role permissions that is being worked on at the moment.
If you are having trouble with access or permissions on regional forums please post here to get access: https://www.boards.ie/discussion/2058365403/you-do-not-have-permission-for-that#latest

javascript won't populate text field when called

  • 02-07-2014 5:28pm
    #1
    Registered Users, Registered Users 2 Posts: 4,468 ✭✭✭


    Hi,

    i hav this javascript which reads information, strips it down and i want it to repopulate the field on keyup.

    i know its being called as i can get it to write the data to a span but not to a text box value:

    [HTML]$("#voter_ID").keyup(function (e) {

    //removes spaces from voter_ID field
    $(this).val($(this).val().replace(/\s/g, ''));

    var voter_ID = $(this).val();

    if(voter_ID.substring(0, 1) == "%" && voter_ID.length >= 4) {
    var cardnumber = voter_ID.substring(voter_ID.lastIndexOf(";")+1,voter_ID.lastIndexOf(";")+19);
    //var cardnumber = voter_ID.split("?")[0];
    $("#swipe-result").html('<br />' && cardnumber);

    $("tester").val(cardnumber);

    //$("#voter_ID").val(cardnumber);
    }

    //if the number doesn't match a certain length ignore it.
    //if(voter_ID.length != 4 || voter_ID.length != 16 || voter_ID.length != 32) {
    //$.post('useridfail.php',{'voter_ID':voter_ID},function(data) {
    //$("#user-result").html('<img src="imgs/not-available.png"><br /><span class="error-text">Invalid Clubcard or till receipt</span>');
    //});
    //}
    $("#user-result").html('<img src="imgs/ajax-loader.gif" style="margin-bottom:4px;" />');
    delay(function() {

    if(voter_ID.length != 4 || voter_ID.length != 16 || voter_ID.length != 18 || voter_ID.length != 32) {
    $("#user-result").html('<img src="imgs/not-available.png" style="margin-bottom:4px;" onload="timedRefresh(5000)" /><br /><span class="error-text">Invalid Clubcard or till receipt</span>' && '');
    }


    if(voter_ID.length == 4 || voter_ID.length == 16 || voter_ID.length == 18 || voter_ID.length == 32){

    $.post('check_username.php', {'voter_ID':voter_ID}, function(data) {
    $("#user-result").html(data);
    });
    }

    }, 1200);





    });
    });
    [/HTML]

    I'm trying to get it to write the card number variable back to the voter_ID or tester text box.

    any help much appreciated.

    thanks


Advertisement