dimanche 12 juin 2016

Converting text box value to int

I have been trying to apply solutions I found on both Google and Stackoverflow, but they don't seem to be working.

What exactly is going wrong here? The checkbox is insignificant here and I can take it out, but it makes no difference.

<div class="form-group">
    <label for="tbid" class="col-lg-3 control-label">Results per page </label>
        <div class="col-lg-3">
            <input type="checkbox" class="checkbox" display="inline-block" name="checkbox_results" onclick="checkbox_results_click();">
            <input type="text" id="results" class="form-control" name="results" placeholder="results">
        </div>
</div>

Then in the js portion, I am trying to convert results into an int.

<script type="text/javascript">
    int results = null;
    var x=document.getElementById("results").value;

    results = parseInt(x);
    if(results==null)
        results=10;

    var pager = new Pager(results);

</script>

EDIT: I should also add that if I just put a int parameter when calling pager, like 25, for example, it actually works. So something is going wrong with results.

Aucun commentaire:

Enregistrer un commentaire