JavaScript - Possible To Merge These Commands?
Is it possible to merge the following?
Code: document.getElementById("dimensionstext").style.color = "silver"; document.getElementById("dimensionstext").style.cursor = "pointer"; So, perhaps something like: Code: document.getElementById("dimensionstext").style.color = "silver"; style.cursor = "pointer"; Similar Tutorialsnot sure I understand the concept behind merging two arrays together. I know that I have to make a deep copy of each array before applying the function. I know that I have to create a temp value to store the information in the arrays while I insert, but not sure how to keep in numeric order. array 1 = [3, 7, 12, 15, 22, 45, 56] and array 2 = [1, 2, 5, 17, 20] What simple code could I start with to create this.
Hi, I am trying to merge the values of 2 arrays. array 1 = 1, 2, 3, 4, 5 array 2 = a, b, c, d, e Resulting in: array 3 = 1-a, 2-b, 3-c, 4-d, 5-e etc both arrays that will be used originally will always of the same length. Both arrays will contain numbers Can you please help? Thanks what is the best way to count the seconds between each onkeyup to "autosave" without sending an ajax command after each key? id like my script to update after 2 seconds of no typing.... (yes, jquery is in use on the page) Code: function microtime (get_as_float) { var now = new Date().getTime() / 1000; var s = parseInt(now, 10); return (get_as_float) ? now : (Math.round((now - s) * 1000) / 1000) + ' ' + s; } var lastKeyUp=0; function saveChange(id,field,value){ thismicrotime=microtime(true); if(lastKeyUp == 0 || (thismicrotime-lastKeyUp) >= 2000000){ $.get("saveChange.php", { 'field': field, 'value': value, 'id': id }, function(data){ lastKeyUp=thismicrotime; }, 'xml' ); } } Code: <input type="text" name="field1" onkeyup="saveChange('2','field1',this.value);" /> i'd use onchange or onblur but that requires you to unfocus the field before it saves... Hello all, I have have been following this merge 'How to' he http://www.astral-consultancy.co.uk/...doco.cgi?11530 which works fine. However, whatever I put below the script also ends up being merged. What do I have to enter to stop it doing that? Code: <html> <head> <style> #Slideshow1 img {height:312px; width:1000px} </style> <script type="text/javascript" src="images/slideshowmerge.js"></script> </head> <body> <h1>Merging Slideshow</h1> <script> var imgArray = new Array(); imgArray[0] = "images/image1.jpg"; imgArray[1] = "images/image2.jpg"; imgArray[2] = "images/image3.jpg"; slideshowMerge('Slideshow1','',imgArray,20,5000); </script> <br><br> <h1>WHY DOES THIS TEXT BECOMES PART OF THE MERGE?<h1> </body> </html> This is my second post in codingforums.com I found help from many members that make me very happy and I take the code from Amphiluke Thanks for all Now I need another help to make two things First I want to merge 2 forms in 1, so instead of following forms: Code: <form action="#" onsubmit="location.href='http://www.mysite.com/article/'+this.indx.value; return false;"> <input name="indx" type="text" size="3" /> <input name="btn" type="submit" value="Go" /> </form> <form action="#" onsubmit="location.href='http://www.mysite.com/news/'+this.indx1.value; return false;"> <input name="indx1" type="text" size="3" /> <input name="btn" type="submit" value="Go" /> </form> I need to make it one with two radio buttons to choose which URL you want to open (Article or News) Second I need this form to be in space size 160x57 so the result will be nearly as this pictu Your help will be highly appreciated I have been using Perl code for about 15 years and I develop/support Perl code used by engineers who run this code in Linux terminals. The code uses Tk as the user interface, which in turn executes Perl scripts. We are looking into the possibility of putting the user interface in a web browser, which would (somehow) still run the same scripts on a Linux box. I can write a Perl script that, given a Linux machine name, user name and password, can open a connection to that machine and execute anything on that machine. My question: Can this sort of thing be done via a web page? This is posted in the JS forum because JS seems like it would provide the tools to create the type of interactive user interface I require. (I don't know a thing about JS, at the moment I'm trying to decide which language to use to implement my s/w, but first I need to determine if the language can do what I need.) I'm trying to built a simple Javascript page that will serve the purpose of merging the values inputted into a form, and then using concatenation to merge these values in with other text to form several lines of commands that would be entered into a router to perform some task. So in other words, it's just a "Merge" script. I should mention that I'm just starting to learn Javascript. I actually haven't been finding Javascript as easy as I thought it would be to learn, and I think it's because there are several ways to do the same thing and I wouldn't be surprised if my problem is I'm using two different methods here...or just using the completely wrong method.... I've seen examples of using 'for' loops and arrays in forms, and I still can't get my head around that. If possible for now I just wish to call in the values and concatenate them, but maybe I do need a loop I don't know Anyway, at this point, my only wish is to be able to get the script to concatenate the values, and then later I'll add the rest of the text it will merge in with and have it write to the page instead of the console. So here is what I have right now. It only partially works (I'm only writing to the console in FireFox at the moment to debug while I test, so that is why you see console.log instead of document.write or whatever. There are 4 fields in the form, and for example, if I enter in each field one word: This is a test The ONLY result I get when submitting the form is the word "This". Then the form is cleared out of all values that were entered. I'd like it to grab all the values at once but that isn't happening. Also, you'll notice I have some 'var' statements commented out. I was trying to use them so that I can later shortcut my script by concatenating using a shorter variable. (ie - using the variable 'cluster' instead of 'document.forms.myForm.cluster.value' when I'm writing the rest of the script). However something isn't right as no matter where I try putting the var statements I get errors that those variables are undefined. I even tried defining them at some point first with some random value but that didn't help either), so that's why I commented them out for now. anyway, here is my feeble attempt at writing this script, any help or guidance would be much appreciated. Code: <!DOCTYPE html PUBLIC "-//WC3//DTD XHTML 1.0 Transitional//EN"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>Router Subnet Commands</title> </head> <body bgcolor="#FFFFFF"> <script language="Javascript" type="text/javascript"> //var cluster = document.forms.myForm.cluster.value; //var subnetip = document.forms.myForm.subnetip.value; //var routerip = document.forms.myForm.routerip.value; //var cidr = document.forms.myForm.cidr.value; function merge() { console.log(document.forms.myForm.cluster.value) + console.log(document.forms.myForm.subnet.value) + console.log(document.forms.myForm.router.value) + console.log(document.forms.myForm.cidr.value); } </script> <form id="myForm"> <input name="cluster" id="cluster"/> cluster number <p> <input name="subnetip" id="subnetip"/> subnet IP address <p> <input name="routerip" id="routerip"/> router IP address<p> <input name="cidr" id="cidr"/> CIDR <p> <input type="submit" value="Get Commands" onclick="merge()" /> </form> </body> </html> Any advice would be much appreciated. Thanks Nat I have a form that was created in Adobe Professional. I have hidden the toolbars on initial view of the form, however, the people using the form have discovered how to un-hide them. Is there any Java Script that I can add to the document that will disable certain menu commands (i.e. "Attach to E-mail")?
I'm trying to setup a mail merge using a gmail docs script from http://www.labnol.org/software/mail-...h-gmail/13289/. So far, it works pretty well, but I want to edit it to include the following: 1) The script should start with "Dear Noah" as opposed to "Dear Noah_Kaplan" 2) I want to add my canned response to the script so that it always appears at the bottom of the e-mail. 3) Lastly, I want the outgoing mail to be saved as individual drafts in my drafts folder in gmail before it's sent out. That way, I can decide if I want to add a sentence or two to personalize each individual email draft. Thanks in advance for your awesome help. Best, Noah By the way, here's the script I want to edit: function onOpen() { var mySheet = SpreadsheetApp.getActiveSpreadsheet(); var menuEntries = [ {name: "Step 1: Import Gmail Contacts", functionName: "importContacts"}, {name: "Step 2: Start Mail Merge", functionName: "sendEmail"}, {name: "Help / About", functionName: "showHelp"}]; mySheet.addMenu("Mail Merge", menuEntries); } function importContacts() { var groupName = Browser.inputBox("Enter the name of your Gmail Contacts group he "); var mySheet = SpreadsheetApp.getActiveSpreadsheet().getActiveSheet(); var myContacts = ContactsApp.findContactGroup(groupName).getContacts(); for (i=0; i < myContacts.length; i++) { var myContact = [[myContacts[i].getFullName(), myContacts[i].getPrimaryEmail(), "Pending"]]; mySheet.getRange(i+2, 1,1,3).setValues(myContact); } Browser.msgBox("You have successfully imported " + myContacts.length + " contacts from Gmail. Please proceed to Step 3."); } function sendEmail() { var mySheet = SpreadsheetApp.getActiveSpreadsheet().getActiveSheet(); var newLine = "<br><br>"; var emailSubject = mySheet.getRange("F2").getValue(); var emailSalutation = mySheet.getRange("F3").getValue(); var emailLine1 = mySheet.getRange("F4").getValue() + newLine; var emailLine2 = mySheet.getRange("F5").getValue()? mySheet.getRange("F5").getValue() + newLine : ""; var emailLine3 = mySheet.getRange("F6").getValue()? mySheet.getRange("F6").getValue() + newLine : ""; var emailLine4 = mySheet.getRange("F7").getValue()? mySheet.getRange("F7").getValue() + newLine : ""; var emailLine5 = mySheet.getRange("F8").getValue()? mySheet.getRange("F8").getValue() + newLine : ""; var emailBody = emailLine1 + emailLine2 + emailLine3 + emailLine4 + emailLine5; var emailSignature = mySheet.getRange("F9").getValue() + newLine; var emailYourName = mySheet.getRange("F10").getValue(); emailBody = emailBody + emailSignature + emailYourName + "<br>"; var emailReplyTo = mySheet.getRange("F11").getValue(); var myContacts = mySheet.getDataRange(); var myContact = myContacts.getValues(); for (i=1; i < myContact.length; i++) { var person = myContact[i]; if (person[1] != "" && person[2] != "OK") { var emailMsg = emailSalutation + " " + person[0] + "," + newLine + emailBody; var advancedArgs = {htmlBody:emailMsg, name:emailYourName, replyTo:emailReplyTo}; MailApp.sendEmail(person[1], emailSubject, emailMsg , advancedArgs); mySheet.getRange(i+1,3).setValue("OK"); } } SpreadsheetApp.flush(); } function showHelp() { Browser.msgBox("With Mail Merge, you can send personalized email messages to your Gmail contacts in two easy steps. For help, visit http://labnol.org/?p=13289 or send me a tweet @labnol."); } I am trying to create a simple auto-calculate function for a webpage. What should be happening: The 'onchange' command should pass the 'price' of the item to the function, the function should then cycle through all the dropdowns (or checkboxes or fields) and calculate the total. What is happening: It is only picking up the last checkbox. It seems that the 'for' loop only remembers the last item in the array. What am I doing wrong? How can I get the code to remember all the items? thanks, Code: <script language="JavaScript" type="text/javascript"> function calculateTotal(price) { var total = 0; var cList = ['sel1','sel2','sel3']; for (i=0;i<2;i++); var select = GetE(cList[i]); total+= price * (select.options[select.selectedIndex].value); GetE("totalShow").innerHTML = total.toFixed(2); } function GetE(id) {return document.getElementById(id); } </script> <html> <head></head><body> <form id="form1" name="form1" method="post" action=""> <select name="sel1" id="sel1" onchange="calculateTotal(100)"> <option value="0">0</option> <option value="1">1</option> <option value="2">2</option> <option value="3">3</option> </select><br><br> <select name="sel2" id="sel2" onchange="calculateTotal(200)"> <option value="0">0</option> <option value="1">1</option> <option value="2">2</option> <option value="3">3</option> </select><br><br> <select name="sel3" id="sel3" onchange="calculateTotal(300)"> <option value="0">0</option> <option value="1">1</option> <option value="2">2</option> <option value="3">3</option> </select><br><br> </form> <br>total <span id="totalShow">0.00</span> </body></html> |