I have a family tree website and want to show all events in our family on the current date (Month and Day). So, if today's April 3rd, I want to show all events in our family that occurred on April 3rd.
I've played with creating a table and hiding rows, etc. but the table's too big and it's taking too long. So, I've decided to create a separate .htm file for each day of the year (i.e., todayinhistory-0101.htm, todayinhistory-0102.htm, etc.).
I have a button which, when clicked, is to get the current date in MMDD format and then open the correct file.
I have the script to get the correct filename using the current date in MMDD format, but I can't figure out how to call it and make it work.
Right now, my button looks like this:
<button onclick="location='GetTodayInHistoryFilename()'">
GetTodayInHistoryFilename() is a function I know works. I just can't get the button format right to call it.
Obviously, I'm a novice and would appreciate anyone's help.
In case you're interested, here's GetTodayInHistoryFilename() - which is loaded in the page's header section:
<script type='text/javascript'>
function GetTodayInHistoryFilename()
{
var Today = new Date();
var TodayMonth = Today.getMonth()+1;
var TodayDay = Today.getDate();
if (TodayMonth < 10) { TodayMonth = '0' + String(TodayMonth); } else { TodayMonth = String(TodayMonth); }
if (TodayDay < 10) { TodayDay = '0' + String(TodayDay); } else { TodayDay = String(TodayDay); }
return 'todayinhistory-' + TodayMonth + TodayDay + '.htm';
}
</script>
Thanks in advance.
I'm not 100% sure this is what you're trying to do but I think you want the button click to navigate to another HTML page in which case - you're not far off:
<button onclick="window.location=GetTodayInHistoryFilename()">
Explanation: You're setting the location property of the window object (your browser's top level frame, in this case) to (a new url). You've defined this using your function which is fine. The only mistake you made was to include the function in quotes. This meant that function name was treated as a literal text string rather than an executable function.
You may or may not need to specify window. (the global object) in window.location. I wasn't sure myself but it's nicely answered here: window.location versus just location
Related
I'm trying to use extension for Qlikview 11SR2.
I've tried to access data with this.Data.Rows, but this object is empty even though the data is not empty and I can display the data in a table.
The code I have used is:
var obj = this.Data;
for(var prop in obj) {
var div = document.createElement("div");
div.innerHTML = "" + prop + "" + obj[prop];
this.Element.appendChild(div);
}
I have no access to the internet - I work offline.
How can i make this.Data.Rows contain the data (it is undefined)?
Based on your feedback, I would say it might be worth trying a slightly different way of accessing your data as the this.Data.Rows object contains a collection of row objects which in turn contain one or more objects, which relate to the dimensions and measures passed to the script (and are defined in definition.xml).
For example, say that I have an extension that features a dimension and a measure (in that order). I can access each value of these in a loop as follows:
for (var rowIx = 0; rowIx < this.Data.Rows.length; rowIx++) {
var row = this.Data.Rows[rowIx];
myDimensionValue = row[0].text;
myMeasureValue = row[1].text;
}
I can then add code to output each value of myDimension and myMeasureValue to the loop, such as in your case adding a new div for each set of values.
I found the "QVConsole" extension invaluable when writing extensions, as it allows you to have a JavaScript console in your QlikView document, so you may then use statements like console.log(myDimensionValue) etc. to help you debug your extension. You can download it from https://github.com/thomasfriebel/QvConsole.
In you extension object in the webview, set the dimension and a valid expression. Let me know whether it works!
Since Titanium doesn't allow you to manually change the hintText colour of a textfield, I have to set hintText manually. Because of this, I have to dynamically change the passwordMask setting on one of fields I'm using.
However, I'm getting weird behaviour and I can't tell if I'm doing something wrong, or if it's a bug in Titanium.
So, here's my markup:
<TextField id="password" onFocus="passwordFocusEvent" onReturn="passwordReturnEvent" onBlur="passwordBlurEvent" value="password"></TextField>
And some of my controller code:
function passwordFocusEvent(e) {
slideViewUp();
if (e.value === 'password') {
e.source.setPasswordMask(true);
e.source.value = '';
}
}
function passwordBlurEvent(e) {
if (!e.value) {
e.source.setPasswordMask(false);
e.source.value = 'password';
}
}
function passwordReturnEvent(e) {
slideViewDown();
passwordBlurEvent(e);
}
What happens is bizarre. When I focus on the password field, it remains plain text. I enter some text, then click off to another field, stays as plain text.
I click back to the password field, it's STILL plain text.
Now here's the weirdness. Up to this point, I would just assume it's not working. However, when I click off this second time, the passwordMask is set.
Major WTF.
I even tried targeting the field directly using $.password.passwordMask = true; but same thing.
Unfortunately, you cant do this. According to the docs on Ti.UI.TextField in the fine print;
Note: on iOS, passwordMask must be specified when this text field is created.
Its not all bad news though, there are a couple ways you can approach this, one option is to make the password mask yourself, by listening to the change event:
var theStoredPassword = '';
$.password.addEventListener('change', function(e) {
var newpass = e.source.value;
if(newpass.length < theStoredPassword.length) {
// Character deleted from end
theStoredPassword = theStoredPassword.substring(0, theStoredPassword.length-1);
} else {
// Character added to end
theStoredPassword += newpass.substring(newpass.length-1);
}
// Mask the text with unicode ● BLACK CIRCLE, 25CF
$.password.value = new Array(newpass.length + 1).join('●');
});
Another option, would be to have two text fields and swap them out whenever the user focuses the password field, the top one would have the custom hinttext, the bottom one would be passwordMasked. In fact thats probably way easier than what I just coded up. :-)
Here's my problem: in my application I have a Dojo EnhancedGrid, backed up by an ItemFileReadStore. The page flow looks like this:
The user selects a value from a selection list.
The item from the list is posted on a server and then the grid is updated with data from the server (don't ask why, this is how it's supposed to work)
The new item is highlighted in the grid.
Now, the first two steps work like a charm; however, the third step gave me some headaches. After the data is successfully POSTed to the server (via dojo.xhrPost() ) the following code runs:
myGrid.store.close();
myGrid._refresh();
myGrid.store.fetch({
onComplete : function(items) {
for ( var i = 0; i < items.length; i++) {
if (items[i].documentType[0].id == documentTypeId) {
var newItemIndex = myGrid.getItemIndex(items[i]);
exportMappingGrid.selection.deselectAll();
exportMappingGrid.selection.addToSelection(newItemIndex);
}
}
}
});
Now, the selection of the grid is updated (i.e. the selection object has a selectedIndex > 0), but visually there's no response, unless I hover the mouse over the "selected" row. If I remove the .deselectAll() line (which I suspected as the culprit) then I sometimes end up with two items selected at once, although the grid selectionMode attribute is set to single.
Any thoughts on this one?
Thanks a lot.
You need to use setSelected(), like so
exportMappingGrid.selection.setSelected(newItemIndex, true);
The second parameter is true to select the row, false to unselect it.
This is what works for me:
grid.selection.clear();
grid.selection.addToSelection(newItemIndex);
grid.selection.getFirstSelected();
Jon
I have a little project to do in flash and I am new with action script. I am using actionscript 2.0 and I just want to make a alarm app which can ring a sound when the time comes :P.
So I have 2 inputtext's one called alarm_hour and another alarm_min.
So the user enters the hour and the minute when it wants the alarm to ring. I am using Date class to pick the hour and the minute and my checkAlarm function it looks like this:
var my_date:Date = new Date();
var h:Number = my_date.getHours();
var m:Number = my_date.getMinutes();
var mi:String = alarma_minute;
var ora:String = alarma_hour;
if (((ora == h) && (mi == m))){
_root.sunet.start(0, 99);
_root.stare = 'start';
}
sunet its the sound file..
So the problem is that the if statement never activates but I don't know why because I have made a dinamic text and tested the values from ora and hour and mi and m and all are equals... what am I doing wrong?
Thank you!
I have managed to solve the problem by accessing the inputtext variables in this form: "variablename.text" and to do that I've had to change the inputtext instance name to "variablename" and now it works fine :D
I have created an image map with flash, I have separate button functions that display rollover and onpress functions for each region ie -
nw_btn.onRollOver = function() {
areaName_txt.text = "This Site (NWPHO)";
}
nw_btn.onPress = function() {
displayOverlay(areaName_txt.text);
}
This is repeated 15 times to cover each area button - I wondered whether there was a way to apply the same function call (displayOverlay) and apply area name text on rollover via one piece of code rather than repeating for each button?
I guess there must be a mistake with your tag, because what you describe look more like an AS2 structure.
But if you really are in AS3, here is what you can do : connect everything to a same function with addEventListener. In this function, test which button is at the source of the event, then put the code to be executed for each button.