|
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++;
}
}
|
|
|
|
|
Now, I'm no JavaScript guru, but...
if ((nameArray[i] != "") && (codeArray[i] != ""))
Here I would also add a jQuery.trim() on nameArray[i] . You may have values that are simply spaces, and checking for empty string will return false
Also, in the for you could dump nameCount and codeCount . Maybe you didn't post the full function, but nameCount is used only for upper bound limit (which could be replaced with parseInt($("._name_Field").length) ), and codeCount isn't used at all.
Other than that, seems to be fine. Also, it's good that you are commenting your code. I've been through some situations in my (relatively short) career when I banged my hand on a wall for not commenting my code a few months earlier.
And if it works for you the way you want it, it's all good. I may get burned for this, but I have a saying:
Make it work. Then do it better
Wrapping it all up, the final function would be:
var elements = [];
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 <= parseInt($("._name_Field").length) - 1; i++) {
if ($.trim(nameArray[i]) != ""
&& $.trim(codeArray[i]) != "") {
elements[jdx] = [];
elements[jdx]["name"] = nameArray[i];
elements[jdx]["code"] = codeArray[i].toUpperCase();
jdx++;
}
}
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.
|
|
|
|
|
Your right, you have to tighten up the code to allow for input errors, been bit by the space before.
Just like in c++, you have to conserve resources, so I dumped the namecount, I thought about it, just didn't do it.
Glad the code is readable, know anything about consuming the eArray in a Web Service?, I posted it in the asp.net disscussion
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 <= parseInt($("._name_Field").length) - 1; i++) {
if ((nameArray[i].trim() != "") && (codeArray[i].trim() != "")) {
elements[jdx] = [];
elements[jdx]["name"] = nameArray[i].trim();
elements[jdx]["code"] = codeArray[i].trim().toUpperCase();
jdx++;
}
}
var eArray = "";
for (e = 0; e <= elements.length - 1; e++) {
eArray = eArray + "{\"name\" : \"" + elements[e].name + "\", \"code\" : \"" + elements[e].code + "\"}";
if (e <= elements.length - 2) { eArray = eArray + "," };
}
var send_Data =
"{" +
"\"template_Name\" : \"" + template_Name + "\", " +
"\"template_Array\" : [" + eArray + "]" +
"}";
alert(send_Data);
$.ajax({
type: "POST",
contentType: "application/json; charset=utf-8",
url: "productEditor.asmx/create_DynamicCart_Template",
data: send_Data,
dataType: "json",
error: function (xhr, status, error) {
exitCode = 2;
alert(xhr.responseText);
},
success: function (responseText) {
try {
eval('(' + responseText.d + ')');
}
catch (err) {
}
alert(responseText.d);
var objB = jQuery.parseJSON(responseText.d);
exitCode = objB.template_ExitCode;
}
});
});
|
|
|
|
|
jkirkerx wrote: know anything about consuming the eArray in a Web Service?,
I don't have that much experience with json in .NET, as my development work in it has been mostly desktop and DB.
For the few occasions I've needed json, I've used JSON.NET[^] and was ok with it, did its job well. Now, if other members know of better libraries than this, I believe all suggestions are welcome.
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.
|
|
|
|
|
Your other solution worked. You could also have done $($elements[i]).find("_name_Field").val() because the jquery indexer returns the dom element not the jquery wrapper to the dom element.
|
|
|
|
|
Oh this is getting exciting now!
var name = $elements[i].find("_name_Field").val(); <-Bombs here
So the first one worked?, yes I know it was working, I just couldn't figure out how to access the name. And I couldn't find any information on it that night, and just wanted to move forward.
I tried many different ways using alert as a test, thought name[i].val() would do the trick. I have no clue what the structure of name looks like. I sure would like know, I thought my first post was clean and simple.
Oh, I saw the hammer next to your name, and knew you were one of the big guns here on the CJ.
Any of the wisdom you choose to share with me would be appreciated. Thanks for reading my post!
|
|
|
|
|
You were close, but not quite there.
var name = $($elements[i]).find("_name_Field").val();
Notice the extra $() around the element you are accessing. That's because $elements[i] is a raw DOM object not a jQuery object and doesn't have a find method.
jkirkerx wrote: Oh, I saw the hammer next to your name, and knew you were one of the big guns here on the CJ.
Thanks for the flattery, but I just did a favor for Chris about 10 years ago to get that little icon, nothing really special there.
|
|
|
|
|
Oh I get it now. I was thinking about the wrapping it again, but was more focused on the name.
Thanks, That was still big gun help there!
|
|
|
|
|
Well I'm getting bolder here with Javascript.
This eludes me, I can create a element and set the value no problem, I can get the value via Jquery no problem if the element is pre-dom, but if I create an element with createElement, I was thinking since my element is new in the DOM, it would be easy to retrieve the value via function. I'm missing something really basic here in principal, and this is the first time I have created a textbox this way.
It's written to be compatible with IE and Firefox browsers at the same time, in a single version.
I keep getting 'undefined' as the value of the code textbox. The function works, I just can't the appendCode from the textbox.
I've tried 3 versions so far. Just thought I'd ask, tomorrow I will have a fresh hat on to think with.
The Element
var txt_Element_L1_Code_Field = document.createElement("input");
txt_Element_L1_Code_Field.id = "_txt_Element_L1_Code_Field_" + dynamicCart_Element1.idx;
txt_Element_L1_Code_Field.type = "text";
txt_Element_L1_Code_Field.style.paddingLeft = "5px";
txt_Element_L1_Code_Field.style.width = "90%";
txt_Element_L1_Code_Field.style.backgroundColor = "rgb(255,255,255)";
td_Element_L1_Code_Field.appendChild(txt_Element_L1_Code_Field);
Version 1 function that is binded
txt_Element_L1_Code_Field.onkeydown = function () {
var appendCode;
if (txt_Element_L1_Code_Field.innerText != "") {
appendCode = txt_Element_L1_Code_Field.value;
}
span_Element_L1_CPN_Field.innerText = appendCode;
span_Element_L1_CPN_Field.innerHTML = appendCode;
};
Version 2: function that is binded
txt_Element_L1_Code_Field.onkeydown = function () {
var appendCode;
if (txt_Element_L1_Code_Field.innerText != "") {
appendCode = txt_Element_L1_Code_Field.innerText;
}
else if (txt_Element_L1_Code_Field.innerHTML != "") {
appendCode = txt_Element_L1_Code_Field.innerHTML;
}
span_Element_L1_CPN_Field.innerText = appendCode;
span_Element_L1_CPN_Field.innerHTML = appendCode;
};
Version 3:
I lost it, gone
|
|
|
|
|
Just use textBox.value. innerText and innerHTML will typically be empty for an <input>, for obvious reasons if you think about the markup.
|
|
|
|
|
It took a while to test, but ended up very simplistic using .value
Thanks for the extra eyes, been awhile since I've used pure Javascript to get values.
|
|
|
|
|