|
Well after much diagnosing and more optimizing, the function I posted has nothing to due with the slowness.
Other dropdownlist are doing the same thing as well, even on other pages. Maybe I just need to reboot my computer an clean things up
|
|
|
|
|
I'm having trouble using each on this json. Normally I use
for ( i=0; i<=states_array_Len-1; i++) {
var stateName = states_array(i).states_Name
}
but in this case, each state name is different and I need the state code as well.
I'm thinking maybe I need a double $(each), I'm not sure.
On this sample, I get 0 in the dropdown list
my json
{
"exit_Code": 2,
"states_Count": 58,
"states_Array": [
{
"Choose State": "--",
"Alabama": "AL",
"Alaska": "AK",
"Arizona": "AZ",
my jquery
var objB = jQuery.parseJSON(responseText.d);
exitCode = objB.exit_Code;
var states_Count = objB.states_Count;
var states_Array = objB.states_Array;
var states_Array_Len = objB.states_Array.length;
if (exitCode == 0) {
$('[id*="_ddl_Modal_StateCode_Field"]').empty();
$.each(states_Array, function (key, value) {
$('[id*="_ddl_Modal_StateCode_Field"]').append($("<option ></option>").html(key).attr("value", value));
});
}
|
|
|
|
|
JavaScript's for loop does what you want:
for(var stateName in states_Array){
var stateShortCode = states_Array[statesName];
}
It seems like you have that dictionary backwards, the short code should be the key and the long name the value.
Also, in your sample, exit_Code is non-zero so the inner code won't ever run. That's probably all that's needed to make it run, as I imagine jQuery.each uses a for loop already.
|
|
|
|
|
I didn't think of your example.
I thought of this last night while bowling, and it worked. I'm kind of surprised it works, but it makes sense. I just had to get into the array object before using $(each). Must be that double $(each) I was thinking of yesterday, in which the first $(each) is the array, and the 2nd $(each) is the pair value.
for (i = 0; i <= states_Array_Len - 1; i++) {
$.each(states_Array[i], function (key, value) {
$('[id*="_ddl_Modal_StateCode_Field"]').append($("<option ></option>").html(key).attr("value", value));
});
}
|
|
|
|
|
I want to calculate the difference between two dates in Year, Month and Days Format. It should check the Leap Year also.
Eg: 01/02/2012 - 29/02/2012 should get result as 1 Month
01/02/2012 - 30/03/2012 - Result should be 1 Month and 30 Days.
|
|
|
|
|
|
my date is 29/02/2012 and i want to add 1 day to this date the answer should be 01/03/2012. how it is possible.I tried the following way, but not working.
var Dte="29/02/2012"
var today=new Date(Dte.substring(6,10),Dte.substring(3,5),Dte.substring(0,2));
today.setDate(today.getDate()+1);
|
|
|
|
|
As you are trying to create the date from a specific string, you should realise that the problem is actually at the point that you parse the date. Basically the to indexes in your substrings are out by one.
Try:
var today = new Date(Dte.substring(6,9), Dte.substring(3,4), Dte.substring(0,1));
|
|
|
|
|
Hi All,
I want to develop a dynamic slider in jquery for that i need that jquery must get all images file names from the folder dynamically not static can any one help me out???????
|
|
|
|
|
Hi,
I'm planning to use bidichecker and integrate into my site in order to test RTL languages ..
Any tips and ideas to start working using bidichecker?
Thanks,
n.s
nada2006
|
|
|
|
|
I'm stumped.
I'm trying to load some thumbnails across in a row.
Each thumbnail has a div container that is white, 60x60, and a 3px margin.
This version loads the thumbnails across, but the 60x60 container is missing, and is not white. Just the image.
Maybe another set of eyes can see my mistake in the div element
var tr_tContainer_Row1 = table_tContainer.insertRow(-1);
var td_tContainer_Row1 = document.createElement("td");
td_tContainer_Row1.style.height = "119px";
td_tContainer_Row1.style.width = "auto";
td_tContainer_Row1.style.textAlign = "left";
td_tContainer_Row1.style.paddingLeft = "5px";
td_tContainer_Row1.style.overflow = "hidden";
td_tContainer_Row1.style.verticalAlign = "top";
td_tContainer_Row1.style.paddingTop = "5px";
tr_tContainer_Row1.appendChild(td_tContainer_Row1);
for (i = 0; i <= objT.length - 1; i++) {
var image_Name = objT[i].image_Name;
var image_Url = objT[i].image_Thumbnail;
var image_Date = objT[i].image_PostDate;
var div_ImagePreview = document.createElement("div");
div_ImagePreview.style.position = "relative";
div_ImagePreview.style.display = "inline";
div_ImagePreview.style.cssFloat = "left";
div_ImagePreview.style.clear = "left";
div_ImagePreview.style.height = "60px";
div_ImagePreview.style.width = "60px";
div_ImagePreview.style.backgroundColor = "rgb(255,255,255)";
div_ImagePreview.style.verticalAlign = "middle";
div_ImagePreview.style.textAlign = "center";
div_ImagePreview.style.margin = "6px";
td_tContainer_Row1.appendChild(div_ImagePreview);
var img_ImagePreview = document.createElement("img");
img_ImagePreview.style.cssFloat = "left";
img_ImagePreview.verticalAlign = "middle";
img_ImagePreview.src = objT[i].image_Thumbnail;
div_ImagePreview.appendChild(img_ImagePreview);
}
$('[id*="_panel_Gallery_Thumbnails"]').append(table_tContainer);
|
|
|
|
|
maybe it can't be done, so this will do for now
var div_ImagePreview = document.createElement("div");
div_ImagePreview.style.position = "relative";
div_ImagePreview.style.display = "inline";
div_ImagePreview.style.cssFloat = "left";
div_ImagePreview.style.clear = "none";
div_ImagePreview.style.textAlign = "center";
div_ImagePreview.style.margin = "2px";
div_ImagePreview.style.cursor = "pointer";
div_ImagePreview.style.cursor = "hand";
td_tContainer_Row1.appendChild(div_ImagePreview);
var img_ImagePreview = document.createElement("img");
img_ImagePreview.style.padding = "4px";
img_ImagePreview.style.border = "solid 1px rgb(220,220,220)";
img_ImagePreview.style.backgroundColor = "rgb(255,255,255)";
img_ImagePreview.src = objT[i].image_Thumbnail;
img_ImagePreview.alt = objT[i].image_Name;
div_ImagePreview.appendChild(img_ImagePreview);
|
|
|
|
|
Margins are outside the element, and not painted in the background colour. Try padding instead.
|
|
|
|
|
HI,
My query is:
I have excel which contains time in Column A and Name in Coulmn B.
I have javscript which reads systems current time and display what are the next 5 times in my excel from current time.
For Ex: now time is 10:30(system time), it displays 11:00, 11:20,12:00, 12:10, 1:00 like that
Now my question is: with these values, it should also display previous 5 times from my excel.
For Ex: Output should be like this
Current time: 10:30
8:00
8:40
9:00
9:30
10:00
11:00
11:20
12:00
12:10
1:00
Kindly help me.
|
|
|
|
|
Hi All,
Have a code which sends an Outlook mail using Javascript by creating an instance of ActiveX object.
I need the functionality to be such, when the user executes this code his default signature should also be added in the mail...Have tried it but to no avail..Any help would be highly appreciated...
The code goes as follows for the reference:
function mailWindowOpen(mailBody) {
outlookApp = new ActiveXObject("Outlook.Application");
var nameSpace = outlookApp.getNameSpace("MAPI");
mailFolder = nameSpace.getDefaultFolder(6);
mailItem = mailFolder.Items.add('IPM.Note.FormA');
mailItem.Subject = "Hi There!!!";
mailItem.HTMLBody = mailBody;
mailItem.display(0);
}
mailBody is passed as a parameter from an aspx page, which has the Page.ClientScript.RegisterStartScript command to call this Javascript function...
-Anurag
|
|
|
|
|
There is a suggestion that calling GetInspector() on the mailItem will populate the signature. I've never tried it in JavaScript, but it may work for you.
I found more details in this[^] blog posting.
|
|
|
|
|
This isn't really a JS question. You need to look at Outlook's API documentation, I think.
|
|
|
|
|
mere lea free webset banao
|
|
|
|
|
Please post in the proper forum[^].
One of these days I'm going to think of a really clever signature.
|
|
|
|
|
wrong forum, no question at all, poorly framed sentence and not a good thing to ask on public forums.
Every now and then say, "What the Elephant." "What the Elephant" gives you freedom. Freedom brings opportunity. Opportunity makes your future.
|
|
|
|
|
Are you kidding man?
You told, "Why don't you guys make free website for me?"
This is a spam message. Need immediate action.
|
|
|
|
|
This is all Javscript, some Jquery,
I created a blank list with an empty container. you fill out the container, and click to add another. You can make as many as you need, or delete the ones you don't want.
----------------------
name: textbox |
code: textbox |
----------------------
So let's say I have 5 of them
I can get the count which is 5, and make an element array of all the containers
Now I want to loop through each container, and get the name and code.
I thought this would work, but it bombed huge. perhaps I jumped the gun, and should make another array of the textboxes inside the loop, or maybe I'm using the $elements[i] incorrectly.
I'm clueless here, and information on this is slim. This is my first time on this.
var iCount = dynamicCart_Element1.idx;
var jCount = parseInt($("._element1").length);
var $elements = $("._element1");
for (i = 0; i <= jCount - 1; i++) {
var name = $elements[i].find("_name_Field").val(); <-Bombs here
var code = $elements[i].find("_code_Field").val(); <- and here
alert(name);
}
The dynamicCart_Element1 is a global on the page, I thought I could use it to build an array of all the values, then convert it to JSON for storage, and send it to the server to write out the XML file for it.
|
|
|
|
|
Well I ended up with this
Guess you have to create a true array, and iterate the elements using each, and then loop through the values
var iCount = dynamicCart_Element1.idx;
var panelCount = parseInt($("._element1").length);
var nameCount = parseInt($("._name_Field").length);
var codeCount = parseInt($("._code_Field").length);
var nameArray = [];
$("._name_Field").each(function () { nameArray.push($(this).val()) });
var codeArray = [];
$("._code_Field").each(function () { nameArray.push($(this).val()) });
for (i=0; i<=nameCount - 1; i++) {
var name = nameArray[i];
var code = codeArray[i];
alert(name + ", " + code);
}
|
|
|
|
|
Yeah, it's a good idea when you have a lot of elements of the same type (textboxes, comboboxes, etc) to give them the same class and iterate using jQuery.each . Iterating through them by ID is way overkill (as those IDs are dynamically generated I assume, you have to save the pattern, and then re-compose it back to get the array of IDs, or simply save the IDs in an array, both of which are more complicated than simply iterating by class).
Now, I don't know how fast this is (usually searching by class is slower than searching by ID), but I think it's the cleanest way to do it.
Also, have a 5 for figuring it by yourself AND posting the solution back.
Full-fledged Java/.NET lover, full-fledged PHP hater.
Full-fledged Google/Microsoft lover, full-fledged Apple hater.
Full-fledged Skype lover, full-fledged YM hater.
|
|
|
|
|
Yeah that was a mind bender. I wanted to use ID, but it was hard to compose in jquery, and then I wanted to use my original array, and tossed that out the window as well.
Finding help on the subject only led to simple basic information.
Ended up with this, including the new array, so I can package the data to send to a web service, and create the xml for it on the server. Can't give myself a 5, but thanks for verifying my code. I appreciate you critiquing my save function.
var elements = [];
var nameCount = parseInt($("._name_Field").length);
var codeCount = parseInt($("._code_Field").length);
var nameArray = [];
$("._name_Field").each(function () { nameArray.push($(this).val()) });
var codeArray = [];
$("._code_Field").each(function () { codeArray.push($(this).val()) });
var jdx = 0
for (i = 0; i <= nameCount - 1; i++) {
if ((nameArray[i] != "") && (codeArray[i] != "")) {
elements[jdx] = [];
elements[jdx]["name"] = nameArray[i];
elements[jdx]["code"] = codeArray[i].toUpperCase();
jdx++;
}
}
|
|
|
|
|