HTML field not updated


Posted by Helge - Mar 2 ’16 at 10:34


I am creating a HTML script but can't find a way to define a global variable that works in and outside of my procedures, any suggestions?

Second question, since I can't manage to define a global variable I tought that I could use a html text field named "TaskId" as a workaround.

using the logic below, but altough the field is updated the IF function does not work before i enter the script again - its not updated while I am "in" the script?


$('#TaskId').attr('value', 'fant');

if (document.getElementById("TaskId").value=="fant") {alert("fant");} else {alert("fant ikke");}

  • rostislav
    Member for: 6 years 11 days
    #1 by rostislav Mar 3 ’16 at 05:55

    1. To make a variable global you can assign it to the global object, which is, in case of browsers, window:

    var myvar = "my variable";
    window.myvar = myvar; 

    2. You are setting the 'value' attribute of the input element, not the content of the box. Try this:

    if (document.getElementById("TaskId").value=="fant") {
    } else {
     alert("fant ikke");
Displaying 1 to 1 of 1 messages