HTML field not updated
Hi
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");}
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");}
1. To make a variable global you can assign it to the global object, which is, in case of browsers, window:
2. You are setting the 'value' attribute of the input element, not the content of the box. Try this:
Code: Select all
var myvar = "my variable";
window.myvar = myvar;
Code: Select all
$('#TaskId').val('fant');
if (document.getElementById("TaskId").value=="fant") {
alert("fant");
} else {
alert("fant ikke");
}
-
- Information
-
Who is online
Users browsing this forum: No registered users and 13 guests