Search Results

Search found 6805 results on 273 pages for 'variables'.

Page 11/273 | < Previous Page | 7 8 9 10 11 12 13 14 15 16 17 18  | Next Page >

  • Can't access variables from dynamically loaded javascript

    - by Menno
    I'm using a fairly simple system to load javascript dynamically: include = function (url) { var e = document.createElement("script"); e.src = url; e.type="text/javascript"; document.getElementsByTagName("head")[0].appendChild(e); }; Let's say I have a file test.js which has the following contents: var foo = 4; Now, in my original script, I want to use include(test.js); console.log(foo); However, I get a 'foo has not been defined' error on this. I'm guessing it has to do with the dynamic script being included as the last child of the <head> tag. How can I get this to work?

    Read the article

  • problem in variables in jquery

    - by Alvin
    Hi, I don't understand why I'm not getting the message as "username already exits" if type the username which is already in database. If the username in a server, then it is returning the value as "1" otherwise empty, and despite of successfully getting the value from the server based on username is present or not, and assigning the value to variable "x", I'm unable to get message when I pass already exist username. May I know? $(document).ready(pageInit); function pageInit() { $('#1').bind('blur',go); } function go() { var value = $('#1').val(); var x = 0; $.post('just.do',{username:value},function(data){ x = data; } ); if(x) { $('#para').show(); $('#para').html("Username already exits"); return false; } else { $('#para').hide(); return true; } }; EDIT: This is what I'm doing in post request in servlets: String user1 = request.getParameter("username"); if(user != null) { String query = "Select * from users where user_name="+"\""+user+"\""; b = db.doExecuteQuery(stmt,query); if(b) { out.write("1"); } }

    Read the article

  • session variables in an ASP.NET

    - by Beep
    hi guy i am trying to place my session in to a drop down, any help would be great. at the moment it puts the data in to a label, i wish to put it into a dropdown with it adding a new string every time i click button without getting rid of the last default page protected void Button1_Click1(object sender, EventArgs e) { Session["Fruitname"] = TbxName.Text; // my session i have made } output page protected void Page_Load(object sender, EventArgs e) { var fruitname = Session["Fruitname"] as String; // my session ive made fruit.Text = fruitname; // session used in lable } Have Tried var myFruits = Session["Fruitname"] as List<string>; myFruits.Add(listbox1.Text); but i get error when i try to run the program Broken glass thanks for your help, it is still not doing what i need but its getting there. var fruitname = Session["Fruitname"] as String; // my session ive made fruit.Text = string.Join(",", fruitname); // session used in lable this is what is working. i need a dropdown to display all the strings put into TbxName.Text; to output into fruit

    Read the article

  • Substituting variables in a loop?

    - by jksl
    I am trying to write a loop in R but I think the nomenclature is not correct as it does not create the new objects, here is a simplified example of what I am trying to do: for i in (1:8) { List_i <-List colsToGrab_i <-grep(predefinedRegex_i, colnames(List_i$table)) List_i$table <- List_i$table[,predefinedRegex_i] } I have created 'predefinedRegex'es 1:8 which the grep should use to search The loop creates an object called "List_i" and then fails to find "predefinedRegex_i". I have tried putting quotes around the "i" and $ in front of the i but these do not work. Any help much appreciated. Thank you.

    Read the article

  • Using variables in Tasker

    - by Waza_Be
    I am trying to create a Tasker plugin. Everything is fine, and works pretty well. I can configure a String to be sent in my app by using EditActivity and this code, following the examples: resultIntent.putExtra(com.twofortyfouram.locale.Intent.EXTRA_BUNDLE,PluginBundleManager.generateBundle(getApplicationContext(),message)); resultIntent.putExtra(com.twofortyfouram.locale.Intent.EXTRA_STRING_BLURB,generateBlurb(getApplicationContext(), message)); setResult(RESULT_OK, resultIntent); The problem comes when I want to use this code to get the battery level for instance, so I added: resultIntent.putExtra("net.dinglisch.android.tasker.extras.VARIABLE_REPLACE_KEYS",com.twofortyfouram.locale.Intent.EXTRA_STRING_BLURB); but the app is not working and I get a string %BATT as the result, the variable is not replaced... As I haven't found any example, I would be pleased to get some help to make it work.

    Read the article

  • Android: How to declare global variables?

    - by niko
    Hi, I am creating an application which requires login. I created the main and the login activity. In the main activity onCreate method I added the following condition: public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); ... loadSettings(); if(strSessionString == null) { login(); } ... } The onActivityResult method which is executed when the login form terminates looks like this: @Override public void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); switch(requestCode) { case(SHOW_SUBACTICITY_LOGIN): { if(resultCode == Activity.RESULT_OK) { strSessionString = data.getStringExtra(Login.SESSIONSTRING); connectionAvailable = true; strUsername = data.getStringExtra(Login.USERNAME); } } } The problem is the login form sometimes appears twice (the login() method is called twice) and also when the phone keyboard slides the login form appears again and I guess the problem is the variable strSessionString. Does anyone know how to set the variable global in order to avoid login form appearing after the user already successfully authenticates? Thanks!

    Read the article

  • Using variables within Attributes in C#

    - by tehp
    We have some Well-Attributed DB code, like so: [Display(Name = "Phone Number")] public string Phone { get; set; } Since it is quite generic we'd like to use it again, but with a different string in the Name part of the attribute. Since it's an attribute it seems to want things to be const, so we tried: const string AddressType = "Student "; [Display(Name = AddressType + "Phone Number")] public string Phone { get; set; } This seems to work alright, except that having a const string means we can't overwrite it in any base classes, thereby removing the functionality that we originally were intending to add, and exposing my question: Is there a way to use some sort of variable inside of an attribute so that we can inherit and keep the attribute decorations?

    Read the article

  • Declare global variables for a batch of execution statements - sql server 2005

    - by Shrewd Demon
    hi, i have an SQL statement wherein i am trying to update the table on the client's machine. the sql statement is as follows: BEGIN TRANSACTION DECLARE @CreatedBy INT SELECT @CreatedBy = [User_Id] FROM Users WHERE UserName = 'Administrator' --//////////////////////////////////////////////////////////////////// --//////////////////////////////////////////////////////////////////// PRINT @CreatedBy --(Works fine here and shows me the output) PRINT N'Rebuilding [dbo].[Some_Master]' ALTER TABLE [dbo].[Some_Master] ADD [CreatedBy] [BIGINT] NULL, [Reason] [VARCHAR](200) NULL GO PRINT @CreatedBy --(does not work here and throws me an error) PRINT N'Updating data in [Some_Master] table' UPDATE Some_Master SET CreatedBy = @CreatedBy COMMIT TRANSACTION but i am getting the following error: Must declare the scalar variable "@CreatedBy". Now i have observed if i write the Print statement above the alter command it works fine and shows me its value, but if i try to print the value after the Alter command it throws me the error i specified above. I dont know why ?? please help! Thank you

    Read the article

  • ExpandEnvironmentStrings Not Expanding My Variables

    - by Adam Driscoll
    I have a process under the Run key in the registry. It is trying to access an environment variable that I have defined in a previous session. I'm using ExpandEnvironmentStrings to expand the variable within a path. The environment variable is a user profile variable. When I run my process on the command line it does not expand as well. If I call 'set' I can see the variable. Some code... CString strPath = "\\\\server\\%share%" TCHAR cOutputPath[32000]; DWORD result = ExpandEnvironmentStrings((LPSTR)&strPath, (LPSTR)&cOutputPath, _tcslen(strPath) + 1); if ( !result ) { int lastError = GetLastError(); pLog->Log(_T( "Failed to expand environment strings. GetLastError=%d"),1, lastError); } When debugging Output path is exactly the same as Path. No error code is returned. What is goin on?

    Read the article

  • global variables doesn't change value in Javascript

    - by user1856906
    My project is composed by 2 html pages: 1)index.html, wich contains the login and the registration form. 2)user_logged.html, wich contains all the features of a logged user. Now, what I want to do is a control if the user is really logged, to avoid the case where a user paste a url in the browser and can see the pages of another user. hours as now, if a user paste this url in the browser: www.user_loggato.html?user=x#profile is as if logged in as user x and this is not nice. My html pages both use js files that contains scripts. I decided to create a global variable called logged inizialized to false and change the variable to true when the login is succesfull. The problem is that the variable, remains false. here is the code: var logged=false; (write in the file a.js) while in the file b.js I have: function login() { //if succesfull logged=true; window.location.href = "user_loggato.html?user="+ JSON.parse(str).username + #profilo"; Now with some alerts I found that my variable logged is always false. Why? if I have not explained well or if there is not some information in order to respond to my question let me know.

    Read the article

  • Accessing Variables in Javascript using .length

    - by CoV
    Hey all, I'm pretty new to Javascript, so forgive me if this is a simple question. I'm trying to access the length of a set of checkboxes in a form using Javascript. However, I need to be able to change the "name" field of the checkboxes to check several different sets of them. Right now, my sample code looks like: var set = "set" + x; totalLength = optionBoxes.set.length; The variable x is being incremented by a for loop that wraps the whole thing and the name of the checkbox sets that I'm trying to access are set0, set1, set2, etc. Thanks. Edit: small typo fixes

    Read the article

  • Javascript variables

    - by Uli
    I'm learning Javascript right now. Can anybody tell me why the second code block traces a empty path for -launch(this)- but using the first code block it gives me the right path? "<form action='"+launchwebsite+"/subsite/' method='post' target='_blank' onsubmit='launch(this)'>" and this not: "<a onclick='launch(this)' title='launch' class='iblack' /></a></div>" Best Uli

    Read the article

  • Django - Weird behaviour of sessions variables with Apache

    - by Étienne Loks
    In a Menu class with Section children, each Section has an available attribute. This attribute is initialized during the instance creation. The process of getting the availability is not trivial, so I stock a Menu instance for each user in a session variable. With the Django embedded webserver this works well. But when I deploy the application on an Apache webserver I can observe a very weird behavior. Once authentified, a click on a link or a refreshment of the page and the availability of each Section seems to be forgotten (empty menu but in the log file I can see that all Sections are here) then a new refresh on the page the availability is back, a new refresh the menu disappears once again, etc. There is no cache activated on the web server. The menu is initialized in a context processor. def get_base_context(request): if 'MENU' not in request.session or \ not request.session['MENU'].childs or\ request.session['MENU'].user != request.user: _menu = Menu(request.user) _menu.init() request.session['MENU'] = _menu (...) I have no idea what could cause such a behavior. Any clue?

    Read the article

  • Java variables across methods

    - by NardCake
    I'm making a basic text editor, and I have 2 methods the first one is triggered when a user click 'Open' and it prompts the user to pick a file and it opens the file fine. I just want to access the same file path which is in a variable in the method that is triggered when the user clicks save. My methods are public, Iv'e tried accessing it through a class, still no. Please help! Code: public void open(){ try{ //Open file JFileChooser fc = new JFileChooser(); fc.showOpenDialog(null); File file = fc.getSelectedFile(); String haha = file.getPath(); BufferedReader br = new BufferedReader(new FileReader(file.getPath())); String line; while((line = br.readLine()) != null){ text.append(line + "\n"); } } catch (FileNotFoundException e){ e.printStackTrace(); }catch (IOException e){ } } public void save(){ try { BufferedWriter bw = new BufferedWriter(new FileWriter(file.filePath)); bw.write(text.getText()); bw.close(); } catch (IOException e) { e.printStackTrace(); } }

    Read the article

  • Best way to carry & modify a variable through various instances and functions?

    - by bobsoap
    I'm looking for the "best practice" way to achieve a message / notification system. I'm using an OOP-based approach for the script and would like to do something along the lines of this: if(!$something) $messages->add('Something doesn\'t exist!'); The add() method in the messages class looks somewhat like this: class messages { public function add($new) { $messages = $THIS_IS_WHAT_IM_LOOKING_FOR; //array $messages[] = $new; $THIS_IS_WHAT_IM_LOOKING_FOR = $messages; } } In the end, there is a method in which reads out $messages and returns every message as nicely formatted HTML. So the questions is - what type of variable should I be using for $THIS_IS_WHAT_IM_LOOKING_FOR? I don't want to make this use the database. Querying the db every time just for some messages that occur at runtime and disappear after 5 seconds just seems like overkill. Using global constants for this is apparently worst practice, since constants are not meant to be variables that change over time. I don't even know if it would work. I don't want to always pass in and return the existing $messages array through the method every time I want to add a new message. I even tried using a session var for this, but that is obviously not suited for this purpose at all (it will always be 1 pageload too late). Any suggestions? Thanks!

    Read the article

  • Batch file reads in text file and replaces quotes with variables into new file?

    - by John
    I have customer Pizza lists that i have saved into 5 seperate txt files from my database in this format: Filename = 25Percent.TXT "555-1211" "555-1212" "555-1223" ... ect Each list is a phone number in quotes and each list varies in length. Part 1: I have two sets of variables that i would like to replace with each quote in the 5 text files. The two variables would be like: Var A = < Discount Pizza price for phone number is " Var B = " 25 % So i would like to run a batch file that reads each line in the text file and writes into another text file the following, replacing the quotes with the variables: New Filename = 25Percentfinished.TXT < Discount Pizza price for phone number is "555-1211" 25 % < Discount Pizza price for phone number is "555-1212" 25 % < Discount Pizza price for phone number is "555-1223" 25 % Then I would repeat for 30percent.txt, then 35percent.txt, 40percent.txt, and then finally 50percent.txt file. Part II: I would also like to append the 5 new files together, with the append command? I am assuming that the SET Var command would also be used? Not sure what to do here.

    Read the article

  • How can I write classes that don't rely on "global" variables?

    - by Joel
    When I took my first programming course in university, we were taught that global variables were evil & should be avoided at all cost (since you can quickly develop confusing and unmaintainable code). The following year, we were taught object oriented programming, and how to create modular code using classes. I find that whenever I work with OOP, I use my classes' private variables as global variables, i.e., they can be (and are) read and modified by any function within the class. This isn't really sitting right with me, as it seems to introduce the same problems global variables had in languages like C. So I guess my question is, how do I stop writing classes with "global" variables? Would it make more sense to pretend I'm writing in a functional language? By this I mean having all functions take parameters & return values instead of directly modifying class variables. If I need to set any fields, I can just take the output of the function and assign it instead of having the function do it directly. This seems like it might make more maintainable code, at least for larger classes. What's common practice? Thanks!

    Read the article

  • Can not find the "variables.tcl" file in Varnish Security

    - by Vladimir
    Varnish Security main.vcl contains # clear all internal variables include "/etc/varnish/security/build/variables.vcl"; and # fallthrough: clear all internal variables on security.vcl_recv exit include "/etc/varnish/security/build/variables.vcl"; but /etc/varnish/security/build/variables.vcl is not included into the git. I commented it out, and it is working fine but where can I get that file?

    Read the article

  • Why do we need private variables?

    - by rak
    Why do we need private variables in classes in the context of programming? Every book on programming I've read says this is a private variable, this is how you define it but stops there. The wording of these explanations always seemed to me like we really have a crisis of trust in our profession. The explanations always sounded like other programmers are out to mess up our code. Yet, there are many programming languages that do not have private variables. What do private variables help prevent? How do you decide if a particular of properties should be private or not? If by default every field SHOULD be private then why are there public data members in a class? Under what circumstances should a variable be made public?

    Read the article

  • How build a global function to have the recent background-Positions for continue animation after cha

    - by andi
    Try to find a global function, to get and to put the backgroundPosition-values, but I feel a bit confused. Here is the function: function global_backgroundPosition_Menu(num){ $('#Navigation_1') .css({ backgroundPosition: num + "px 0" }) } /////////////////// An here I want to call and put the function: if ($('#Navigation_1 li.leistungen.active').length != 0){ global_backgroundPosition_Menu(); $('#Navigation_1') .css({ backgroundImage: "url(images/background/menu_highlight_hg.png)", backgroundRepeat: "no-repeat", }) .animate({ backgroundPosition: "30px 0" }) global_backgroundPosition_Menu(30) };

    Read the article

< Previous Page | 7 8 9 10 11 12 13 14 15 16 17 18  | Next Page >