HTML field not updated

Discussions about Forms Designer for SharePoint 2010.
Locked
Helge
Posts: 4
Joined: Tue Mar 01, 2016

02 Mar 2016

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");}

User avatar
rostislav
Moderator
Posts: 364
Joined: Mon Oct 19, 2015

03 Mar 2016

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

Code: Select all

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:

Code: Select all

$('#TaskId').val('fant');

if (document.getElementById("TaskId").value=="fant") {

 alert("fant");

} else {

 alert("fant ikke");
 }

Locked
  • Information
  • Who is online

    Users browsing this forum: No registered users and 13 guests