Event tracking label to equal input field value - google-maps

I have a website with an embedded google map on it, similar to https://developers.google.com/maps/documentation/javascript/examples/places-autocomplete but with our offices displayed.
I'm trying to set up event tracking with google analytics and would like to track users using the map. I would like the label to be the value entered in the search field e.g.
<input type=”submit” onClick=”_gaq.push([‘_trackEvent('Search-form', 'Submit', 'London', 10]);” />
but 'London' = whatever the user has entered.
Is this possible?

Yes it is possible. You just need to add some code to grab the value entered for that particular field and populate that into the label parameter. If your city input field has a specific ID, then you could do something like
_gaq.push(["_trackEvent", "category", "action", $("#city").val(), 10]);

Related

How do I build a simple HTML form to construct a link from two form fields?

At work, one of the systems I use outputs voyage schedules. The URL for each voyage is constructed as the form address followed by ?voyageCode= followed by the voyage number, which is a two-letter route prefix and a three-digit voyage number.
Rather than use the standard form, which has a whole bunch of fields I never need to use, I want to build a simple page where I can just select the route and enter a voyage number.
In practical terms, I'm trying to build a form with the following:
A drop-down menu or set of radio buttons to select the two-letter route code;
A text field to enter the three-digit route code;
A button or link to combine those inputs into a link in the format [LINK]?voyageCode=[ROUTE CODE][VOYAGE NUMBER]
My HTML knowledge is pretty outdated, and I've never worked much with forms. Can anyone advise on how I can construct this?
Why don't you use a select tag for the dropdown and a classic input text for the route coude ?
Then for the link part, you should capture the click event on your button through onClick and then call a small function that'll basically do that :
function concatRouteCode(){
var select= document.getElementById("routeCodeLetters");
var routeCodeLetters = select.options[select.selectedIndex].value;
var routeCodeNumber = document.getElementById('routeCode').value;
return routeCodeLettres+routeCodeNumber;
}
If you really want to combine the codes into a single query parameter, you'll have to use Javascript to fetch the values of the two fields and change the location. You don't need Javascript if you put the values into separate parameters, as in ?routeCode=xx&voyageNumber=123. In that case you would just give the select element the attribute name=routeCode and the input field the attribute name=voyageNumber.
In case you want to go with the first approach, you'd have something like
document.getElementById("idOfSubmitButton").addEventListener("load", function() {
const routeCode = document.getElementById("idOfSelectElement").value;
const voyageNumber = document.getElementById("idOfInputField").value;
location.href = "base URL here" + "?voyageCode=" + routeCode + voyageNumber;
});

copy value entered in unbound textbox to label after pressing button

I have an unbound text box on my form which the admin can enter a date of when records were last updated. I want this date to be copied to a label after pushing a button so that it holds the date instead of it do disappear after closing the form.
does anyone know if this is possible and how it is possible?
For creating a variable that can be used AFTER the form is closed:
Create a new module (in code window, click 'Insert | Module'
Insert the variable name(s) and types you want available everywhere. i.e.
Global dtLastUpdated As Date
Global strSaveSomeName As String
Save the module as mdl_Globals
Add code wherever needed to set the variable, then can reference anywhere.
If for use during the form, use the following: where 'lblForUnbound' is the Label field and 'txtUnbound' is your unbound text box
Me.lblForUnbound.Caption = Me.txtUnbound.Text

datapicker write something different in date field

I want to use Zebra datapicker... but if I attach it to the input, I can't write somethig different from data which is picked in calendar... so how I can choose what I can write into textbox...
P.S I am using only one textbox in my page
Whilst I'm not familiar with the date picker you mention, it ought to have some means of specifying a callback function that acts as an intermediary between the selected value and what, ultimately, gets put in the text field.
I wrote a date picker some years ago which does this - see the callback_func param.
Without a callback, it inserts the selected date into the field. With a callback, it passes the selected date to the callback and uses the function's return value to decide the new value for the field.
var cal = new Calendar({
callback_field: '#myField',
focusElements: '#myField',
callback_func: function(d, m, y, date) { return 'hijack!'; }
});
You need to use a plugin that validates your keyup event on the text field.
Here's a small piece of code I wrote that does just that:
https://github.com/cassilup/jquery.keyup.validator
Unfortunately, it does not have code for date, but you tweak it freely to suit your needs.
Alternatively, you could assign the text field as readonly and let the datepicker do the date input.

Use table field description on form

I would like to display a field's description on a form. How would I accomplish this? For example, table name is tblbureau, field name is Counsel with a description 'General Counsel for the Defense', form name is frmCounsel. I'd like to use a control (textbox?) that displays the full description instead of using the default label for the field name. Thanks.
If you have used the form wizards to create the form, any descriptive text is added to the StatusBarText propery. This is even true when you create a blank form and drag fields from the field list to the form. You can refer to this property for your message box, or just refer the user to the statusbar. You can also update the ControlTipText property with the StatusBarText property.
MsgBox Me.ATextBox.StatusBarText
Using the above will save coding to get the description:
Currentdb.TableDefs("atablename").Fields("afieldname").Properties("Description")
Note that the description property is not available for fields when you have not added a descrition, so the above would cause an error.

DropDown TypeMOde on select value Change from Database

I have a drop down list called is as TypeMode,in that drop down list i have 1)In 2)out 3)Internal
in the jsp page i have From texbox followed by a search button and other text box fields.
when i type an ID in the Search box and click search the other text box fields should be fetched frm database.
i have one more TO texbox followed by Search button and other text box fields,when i type an iD in the search box and press the search button ,other values shuld be fetched form database .
Now the the problem is ,as i said that i have DropDown list called TypeMode.
when i select any they as In or Out....From texbox and and To Textbox search depends on that.
for Example i have selected "In" as the TYpeMode,
when i type an Id in the From Text box search ,only spefic value should fetch from database,
but in To search box search all the values should come.
For example on Select "Out "as typeMode,
From texbox search should fetch all the values ,and TO search box should search only specifc values .
Sir you can do it just by doing post back to that form
** if you dont want the page to refresh put the other text boxes in a updatePanel (dont forget to include the "script manager" )
** or you can easily to make your page more systematic you can use PM or jQuery ajax and send them the values of DDL and the ID