473,379 Members | 1,270 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,379 software developers and data experts.

Setting variable value (mosync native ui)

228 100+
I had asked the mosync community but there seems to be an inactive community. The question is more javascript as well.

I have a widget editBox defined as

Expand|Select|Wrap|Line Numbers
  1. <div data-widgetType="EditBox"
  2.                         id="searchword"
  3.                         data-width="FILL_AVAILABLE_SPACE"
  4. data-text=""data-fontSize="26">
  5.                     </div>
  6.  
on top of my page is my javascript files (i.e. warmhole.js) and a custom function defined as follows

Expand|Select|Wrap|Line Numbers
  1. function getEntry(){
  2. var word2="";
  3.  var searchtextctrl=document.getNativeElementById("searchword");
  4. //read its text property now then save it to word2 var
  5.                 searchtextctrl.getProperty("text",
  6.                 function(property,value)
  7.                  { 
  8.             word2=value;
  9.                 },
  10.                 function()
  11.                 {
  12.             word2="";
  13.                 }
  14.                 );
  15.  
  16.  
  17. }
  18. //if (!word2) { //tried as well (word=="")
  19. //no entry
  20. }
  21.  
The problem is word2 is blank. the line word2=value is working fine as its output is ok. But after it gets out of the getproperty function, word2 seems to be reset to blank. What am i missing?
Mar 4 '15 #1
1 1478
gits
5,390 Expert Mod 4TB
i aligned your code properly to understand what you were asking by looking at the code:

Expand|Select|Wrap|Line Numbers
  1. function getEntry() {
  2.     var word2 = "";
  3.     var searchtextctrl = document.getNativeElementById("searchword");
  4.  
  5.     //read its text property now then save it to word2 var
  6.     searchtextctrl.getProperty("text", function(property, value) { 
  7.             word2 = value;
  8.         },
  9.         function() {
  10.             word2 = "";
  11.         }
  12.     );
  13. }
  14.  
  15.  
  16. if (!word2) { //tried as well (word=="")
  17.     //no entry
  18. }
  19.  
when you have a close look at it - you define the variable word2 locally in the scope of your getEntry-function, thus you cannot access its value outside of it.
Mar 13 '15 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: skeeterbug | last post by:
i have a program that will display a number of diffferent results depending on the situation. one example of the code looks like <?php if(isset($_SESSION)) { print 'You entered: ' ....
21
by: | last post by:
Hi, I am setting the NumericUpDown .Value property and the ValueChanged event is NOT being fired. Does this ONLY get fired when I change it on the UI and not programatically? Thanks
12
by: harishg2 | last post by:
Hi, How to store a variable value for more than one executions. Ex: main() { int i=0; i++; printf("%d",i);
1
by: Varadha | last post by:
Hi, I am declaring a variable static char Version_No = '1' in header file header.h In a application "app.exe", i am changing the value of the variable in to '2' In the same application i am...
3
by: Helpseeker | last post by:
Hi all, I have written a small code in which i declare a static int variable and increment its value by one each time i click on a button. actually i use the int variable value in a particular URL...
1
by: swarnap | last post by:
I have a control on me screen of type <FILE>. I want to set some value to that object from the database. I tried the following code using html. <html > <head> <script type="text/javascript"> ...
5
by: aamirghanchi | last post by:
Hi, I need to know if anyone else came across this. The Session variable value I set in a sortCommand event handler of a datagrid does not hold on till the next sortcommand event handler and...
2
by: comerica1 | last post by:
I have the basic structure as follows: 2 drop downs A & B. A is populated using (datasource methods - from database). B is poulated using A's selected value as input and retrieve the list...
0
by: tharika_c | last post by:
Hi, We have a simple ASP.NET web application where one of the Session variables, called Session("SSO_ID") gets created and assigned a value (equal to the HTTP_HRID request variable value),...
7
by: Brad Pears | last post by:
I have something strange going on - pretty sure it used to work before - and now it does not... Why does the following code not clear a combo box? Me.cboLocation.Text = String.Empty OR ...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.