JavaScript - How To Use Javacript To Modify Ie Print Setting?
hi,
I need to modify IE print settings(paper size, print orientation) automatically, by javascript and can not use ActiveX control or reduce IE security setting. Can any one tell me how to implement this function,Thanks. Similar TutorialsHello, I have stack of images arrange one behind another, when ever i click on them current image should flip down, image is flipping down but its parent container is staying at same position. Due to that i am not able to perform action on other images. i have chosen the option of providing lesser z index value to parent element so that it will not cause problem to perform event on other images. But still it is not working. I am able to add z index value but when running the code both flipping and adding z index to parent is executing at one time. Due to that animation is not coming in a right way. i want to know, How i can execute code one after another, example when flipping image is completed then only i want to add z index value to parent element (f1_container) SO that it will not cause problem for other images. Please help <div id="f1_container" class="f1_container"> <div id="f1_card" class="shadow"> <div class="front face"> <img src="img/8.jpg"/> </div> <div class="back face center"> <img src="img/1.jpg"/> </div> </div> </div> var flipImage=document.querySelectorAll('.shadow'); for(j=0; j<flipImage.length; j++){ var currentFlipImage=flipImage[j]; currentFlipImage.addEventListener('click', function(event){ var currentElement=event.currentTarget; //this should be executed first currentElement.style.webkitTransform='rotateX(-120deg)'; and this one should execute after flipping is completely done this.parentNode.style.zIndex=-100; },false); } Okay, on my website I have some javascript code I'm using to make the user input required text. If they don't enter info in all the required fields an alert box appears (nothing new).. The issue is, when you click okay, it redirects to a page and just says "false." It only does this in IE9.. Chrome has no issues.. Any idea? or resolutions? website issue he https://pcexpresstechs.com/get_started.html here is the code: Code: function verify() { var themessage = "You are required to complete the following fields: \n"; if (document.input.first.value=="") { themessage = themessage + " - First Name"; } if (document.input.last.value=="") { themessage = themessage + " - Last Name"; } if (document.input.email.value=="") { themessage = themessage + " - Email Address"; } if (document.input.phone.value=="") { themessage = themessage + " - Phone"; } //alert if fields are empty and cancel form submit if (themessage == "You are required to complete the following fields: \n") { document.input.submit(); } else { alert(themessage); return false; } } Hi. I have a bunch of textboxes that I need to run some JS on with onclick. However, no matter what I do, I cannot get it to work. I have this JS in an external file: Code: <script language="javascript" type="text/javascript"> function ClearDefault () { if (document.this.value==document.this.defaultValue) { document.this.value=''; document.this.style.color='black' } } </script> and am using onfocus="ClearDefault()" Help please. Thanks. :-) Hi need help with a loan calculator script, i know the moderator frowns on such requests but i just have to, im willing 2 buy a cup of coffee if it works, i want the code below to display the total loan repayment amount instead of the monthly payment payment = principle * monthly interest/(1 - (1/(1+MonthlyInterest)*Months)) , eg if if l0an is 20$ payment is in 4 months, intrest rate is 15% display = amount to be repaid. thanks Code: <script language="JavaScript"> <!-- function showpay() { if ((document.calc.loan.value == null || document.calc.loan.value.length == 0) || (document.calc.months.value == null || document.calc.months.value.length == 0) || (document.calc.rate.value == null || document.calc.rate.value.length == 0)) { document.calc.pay.value = "Incomplete data"; } else { var princ = document.calc.loan.value; var term = document.calc.months.value; var intr = document.calc.rate.value / 1200; document.calc.pay.value = princ * intr / (1 - (Math.pow(1/(1 + intr), term))); } // payment = principle * monthly interest/(1 - (1/(1+MonthlyInterest)*Months)) } // --> </script> The results of this loan payment calculator are for comparison purposes only. They will be a close approximation of actual loan repayments if available at the terms entered, from a financial institution. This is being provided for you to plan your next loan application. To use, enter values for the Loan Amount, Number of Months for Loan, and the Interest Rate (e.g. 7.25), and click the Calculate button. Clicking the Reset button will clear entered values. <p> <center> <form name=calc method=POST> <table width=60% border=0> <tr><th bgcolor="#aaaaaa" width=50%><font color=blue>Description</font></th> <th bgcolor="#aaaaaa" width=50%><font color=blue>Data Entry</font></th></tr> <tr><td bgcolor="#eeeee">Loan Amount</td><td bgcolor="#aaeeaa" align=right><input type=text name=loan size=10></td></tr> <tr><td bgcolor="#eeeee">Loan Length in Months</td><td bgcolor="#aaeeaa" align=right><input type=text name=months size=10></td></tr> <tr><td bgcolor="#eeeee">Interest Rate</td><td bgcolor="#aaeeaa" align=right><input type=text name=rate size=10></td></tr> <tr><td bgcolor="#eeeee">Monthly Payment</td><td bgcolor="#eeaaaa" align=right><em>Calculated</em> <input type=text name=pay size=10></td></tr> <tr><td bgcolor="#aaeeaa"align=center><input type=button onClick='showpay()' value=Calculate></td><td bgcolor="#eeeeaa" align=center><input type=reset value=Reset></td></tr> </table> </form> <font size=1>Enter only numeric values (no commas), using decimal points where needed.<br> Non-numeric values will cause errors.</font> </center> <p align="center"><font face="arial" size="-2">This free script provided by</font><br> <font face="arial, helvetica" size="-2"><a href="http://javascriptkit.com">JavaScript Kit</a></font></p> I'm trying to create a form where the user enters data in a field and is redirected to a URL based on that entry - example: user enters 1234 and he is directed to mypage.com/1234/index.htm - if that folder does not exist it would give a 'try again' error. Any help would be greatly appreciated Thanks in advance Cyber-guys I need help making it possible for the prefixes to be available when the post is being Modify? The user have to go back and change their prefixes to ended after they get the result for the outcome of the buy, sell, trade. When I hit Modify the prefix box was no longer available. It is on the subject line when I hit modify: Example. I have a thread title "Testing" and I chose Buy prefix when I started the thread. When I hit Modify, the prefix box is no longer available but the subject does say Buy:Testing. I would have to go and delete the Buy from the subject and manually type Ended. And also each prefixes a specific color if that's possible (i.e., Buy , Sell , Trade , Ended ) The prefix box now is below the subject line. I would love for it to be next to the subject line like in this forum. THANKS! <script type='text/javascript'> /* Add prefixes to posts*/ var prefixes = ['Buy:','Sell:','Trade:','Ended:']; if( new RegExp('post$','i').test( this.location.href )) { document.postForm.nextaction.nextSibling.disabled = true; var Tab = document.postForm.subject.parentNode.parentNode.parentNode; var iRow = Tab.insertRow(2); var iCell; iCell = iRow.insertCell(0); iCell.className = 'windowbg'; var Font = document.createElement('font'); Font.size = 2; Font.appendChild( document.createTextNode('Prefixes:') ); iCell.appendChild( Font ); iCell = iRow.insertCell(1); iCell.className = 'windowbg'; var Select = document.createElement('select'); Select.id = 'preprepre'; Select.options[0] = new Option('Choose prefix'); for( var s = 0 ; s < prefixes.length ; s ++ ) Select.options[s+1] = new Option(prefixes[s]); iCell.appendChild( Select ); function checkpre(event) { if( document.getElementById('preprepre').selectedIndex == 0 ) document.postForm.nextaction.nextSibling.disabled = true; else document.postForm.nextaction.nextSibling.disabled = false; } function addpre(event) { document.postForm.subject.value = document.getElementById('preprepre').options[ document.getElementById('preprepre').selectedIndex ].innerHTML+document.postForm.subject.value; } if(document.addEventListener) { document.getElementById('preprepre').addEventListener('change',checkpre,false) document.postForm.addEventListener('submit',addpre,false); }else{ document.getElementById('preprepre').attachEvent('onchange',checkpre); document.postForm.attachEvent('onsubmit',addpre); } } </script> hello, I got this javascript code to avoid bots to fill out with trash the forms I have in my website: <script type="text/javascript"> var a = Math.ceil(Math.random() * 10); var b = Math.ceil(Math.random() * 10); var c = a + b function DrawBotBoot() { document.write("Cuanto es "+ a + " + " + b +"? "); document.write("<input id='BotBootInput' type='text' maxlength='2' size='2'/>"); } function ValidBotBoot(){ var d = document.getElementById('BotBootInput').value; if (d == c) return true; return false; } </script> <P>Are you human?<br /> <script type="text/javascript">DrawBotBoot()</script> <P> <INPUT id="Button1" name="SUBMIT" TYPE="SUBMIT" VALUE="ENVIAR" onclick="alert(ValidBotBoot());"/> <INPUT name="RESET" TYPE="RESET" VALUE="BORRAR"> My problem is that the form sends itself even if you dont type the correct answer, I would like to Validate first and then allow me to send the form after validation. You can see the form he http://www.futuros.com/mercados_calientes.html feel free to play with it, i know is the only way to actually see what i'm trying to accomplish. Thanks, Alan Hi My html document contain many images which has the attribute src of img tag as the flowing : PHP Code: http://images.mysite.com/a/p/ap.eba553af4b719.ec03.jpg?x=210&y=83&q=85&sig=Tua1ukyUEVKTPSsz7xGPsg-- All those images has the common source folder http://images.mysite.com/a/p This is an example : PHP Code: <img src = "http://images.mysite.com/a/p/ap.eba553af4b719.ec03.jpg?x=210&y=83&q=85&sig=Tua1ukyUEVKTPSsz7xGPsg--" width = "105" height = "73" > I tried during many days to find the solution using RegExp but I didn't arrives. What I want to do is I - change for all image from the seem folder the src attribute to match the exact url of the image without special characters, for this example : PHP Code: http://images.mysite.com/a/p/ap.eba553af4b719.ec03.jpg?x=210&y=83&q=85&sig=Tua1ukyUEVKTPSsz7xGPsg-- Became : PHP Code: http://images.mysite.com/a/p/ap.eba553af4b719.ec03.jpg II - Control the width and height of the image by changing its height and width attributes resp. from two javascript variables : PHP Code: var v_width = 320 // Just for example var v_height = 250 // Just for example This is an example of try didn't work for me, for the first issue : PHP Code: var element = document.getElementsByTagName("img"); for(var i=0;i<element.length;) { var myString = new String(); var myRegExp = new RegExp("http:\/\/d\.images\.mysite\.com\/a\/p[^\?]*(jpg|png|gif)","i"); var myRegExp0 = new RegExp("\?.*","i"); myString = element[i].getAttribute("src"); if(myRegExp.test(myString)) { var newString = myString.replace(myRegExp0,""); element[i].setAttribute("src",newString); } } Help me please Think you Edit: Problem solved.
Hi I am a new user to JS, and I have a problem he I have some JS code to work on a data set with file name "data.txt" in the header section of an HTML page. Code: <script type="text/javascript" src="data.txt"></script> What I am trying to do is to ask a user to input a different file name, then update the file name in the <script> tag, for example, to Code: <script type="text/javascript" src="new_data.txt"></script> But I don't know how to update the file name. Any help will be appreciated. Can someone help me to modify this JS to close if user is no longer hovering over child link after 5 seconds? Code: $(document).ready(function () { $('#menuHolder ul li a').mouseover(function (event) { if (this == event.target) { $(this).parent().toggleClass('clicked'); if ($(this).parent().attr('class').indexOf('clicked') != -1) { $(this).siblings('ul').animate({"top": "35px"}, {queue:false,duration:(500)}, "swing"); } else { $(this).siblings('ul').animate({"top": "0px"}, {queue:false,duration:(500)}, "swing"); } $(this).parent().siblings().removeClass('clicked').find('ul').animate({"top": "0px"}, {queue:false,duration:(500)}, "swing"); } }) $('#menuHolder ul li:not(:has(ul)) a').mouseout(function (event) { if (this == event.target) { $(this).parent().toggleClass('clicked'); $(this).parent().siblings().removeClass('clicked').find('ul').animate({"top": "0px"}, {queue:false,duration:(500)}, "swing"); } }); }); </script> Is this possible? Code: String.prototype.trim = function(){ return this.replace(/^\s+|\s+$/g, ""); } var myStr = " Hi what's up? "; myStr.trim(); alert("{" + myStr + "}"); //will result in the original string, not the trimmed version It's possible with numbers: Code: var myNum = 10; myNum++; alert(myNum); //11 I am using the simple password script from http://www.allwebco-templates.com/su...ect_simple.htm where the password is contained in the header script. I need to change the password, e.g. from Jan to Feb to Mar to Apr etc. How could I modify the script to contain the list of passwords, and have it automatically utilise/apply the correct password for the current month? To a non-javascript person like me this seems like it should be simple..... Can anyone please suggest a solution? Thanks muchly in advance. I have a page that open two frames. Second frame, most of the page, is empty. First frame contains a form that retrieves user input, when you click the button, it send that input back to the original parent html, which detects the GET parameters, and builds a custom URL. I want to then load that custom URL in the 2nd empty frame. I figure I need to modify the src atttribute of the 2nd frame in the frameset, but I can't make it work. Code: <frameset id='parent' rows='10%,90%'> <frame id='frm1' src='./form.html' /> <frame id='frm2' src='' /> </frameset> <script>modFrmSrc();</script> where modFrmSrc() checks for the GET values, builds the URL, and then tries to load the URL in frm2. Is there a way to get this done? I need educating please. I have a javscript page (fred.js) that contains some variables and some code. I want to be able to change the variables (in particular an array) within fred.js on the server and store the new version of fred.js back on the server. I can write a php routine that stores the array in a MySQL table. Now I want to know how to write some code (and in what language) to read the MySQL table and update fred.js and store it back onto the Server. Can someone please tell me what language I should be using to do this (Ajax??) so that I can do some reading please. I could of course simply write some php code to read the table and pass the parameters to a js page and build the array as each person accesses the web page but this would be slow. Hence I would prefer to have the ability to update the js page and store it back onto the server. Hello, I've made a JS code that declare events based on year, month and days. Each date represents an event. The code works well but I'd like to improve the declaration when several days with the same description are following to reduce declaration lines. Here's the actual working code: var events = [ >> {year: '2011', month: '11',day: '1',description: "test description",url: '',newpage: false,mark_as_event: false}, >> {year: '2011', month: '11',day: '2',description: "test description",url: '',newpage: false,mark_as_event: false}, >> {year: '2011', month: '11',day: '3',description: "test description",url: '',newpage: false,mark_as_event: false}, >> {year: '2011', month: '11',day: '4',description: "test description",url: '',newpage: false,mark_as_event: false}, //I would like replace the 4 lines here above by something like this: >>>>> {year: '2011', month: '11',(day: '1','2','3'),description: "test description",url: '',newpage: false,mark_as_event: false}, {year: '2011', month: '11',day: '11',description: "11 november",url: '',newpage: false,mark_as_event: false}, {year: '2012', month: '4',day: '30',description: "easter",url: '',newpage: false,mark_as_event: false}, {year: '2012', month: '5',day: '1',description: "1 mai",url: '',newpage: false,mark_as_event: false}, {year: '', month: '',day: '',description: "",url: '',newpage: true,mark_as_event: true} ]; var temp_date=new Array(); //init current month data var temp_url=new Array(); var temp_newpage=new Array(); var temp_mark_as_event=new Array(); for (var i = 0; i < events.length; i++) { //Current month data are used here if (events[i].year==cal_year && events[i].month==(cal_month + 1)){ temp_date[events[i].day]=events[i].description; temp_url[events[i].day]=events[i].url; temp_newpage[events[i].day]=events[i].newpage; temp_mark_as_event[events[i].day]=events[i].mark_as_event; } } Is it possible and how ? Thank you very much Gino Hey guys, wondering if anyone can help me. My JS knowledge is pretty non-existent. Basically I am currently using this code for a day countdown: Code: <script> //change the text below to reflect your own, var before="" var current="" var montharray=new Array("Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec") function countdown(yr,m,d){ var today=new Date() var todayy=today.getYear() if (todayy < 1000) todayy+=1900 var todaym=today.getMonth() var todayd=today.getDate() var todaystring=montharray[todaym]+" "+todayd+", "+todayy var futurestring=montharray[m-1]+" "+d+", "+yr var difference=(Math.round((Date.parse(futurestring)-Date.parse(todaystring))/(24*60*60*1000))*1) var dstring=difference.toString() if (difference==0) document.write(current) else if (difference>0){ document.write("") for (i=0;i<=dstring.length-1;i++) document.write('<img src="/c'+dstring.charAt(i)+'.png">') document.write('<img src="/days.png">'+before) } } //enter the count down date using the format year/month/day countdown(2011,08,17) </script> I like this script because it outputs in images. As you can see in my site at: http://www.bigbrothersite.co.uk/ (in the header) My question is, can that script above be adapted so it also works as a count up script. For example, from the 17th of august, can i somehow adapt it so i can use it to count up the days? Any help please. Thanks! Hi, I came across this thread and I've decided to use jmrker's code. Code: <html> <head> <title>Clock Example</title> <script type="text/javascript"> function startTime() { var d=(new Date); var str = d.toLocaleTimeString().toLowerCase().replace(' ',''); var tmp = d.toLocaleDateString().split(' '); var dm = d.getDate(); switch (dm) { case 1: case 21: case 31: dm += 'st'; break; case 2: case 22: dm += 'nd'; break; case 3: case 23: dm += 'rd'; break; default: dm += 'th'; break; } str += ' '+tmp[0].substr(0,3)+', '+tmp[1].substr(0,3)+' '+dm+', '+tmp[3]; startTime.out.innerHTML = str; } onload = function(){ startTime.out=document.getElementById("time"); setInterval(startTime, 1000); }; </script> <body> <div id="time"></div> </body> </html> However, I would like to modify some elements. Right now the date and time are displayed in this format: Quote: 9:58:45am Sat, Feb 26th, 2011 I would like to know how to change it to look like this: Quote: SAT 09:58:45 AM (for example) Could someone please break down the code and let me know what I need to change to get this to work? Or, if it's less trouble, just change the code for me? Thanks, I appreciate your time. I trying to modify that username password script so that only a password is needed,and if entered correctly, it takes you to a certain webpage but the script seems to break when I take out the username variables..is there any way I can do this? Heres the script, its from the resources on javascriptkit. How would I do this? Any help would be appreciated! Heres the script I found. <script type = "text/javascript"> var count = 2; function validate() { var un = document.myform.username.value; var pw = document.myform.pword.value; var valid = false; var unArray = ["Philip", "George", "Sarah", "Michael"]; // as many as you like - no comma after final entry var pwArray = ["Password1", "Password2", "Password3", "Password4"]; // the corresponding passwords; for (var i=0; i <unArray.length; i++) { if ((un == unArray[i]) && (pw == pwArray[i])) { valid = true; break; } } if (valid) { alert ("Login was successful"); window.location = "http://www.google.com"; return false; } var t = " tries"; if (count == 1) {t = " try"} if (count >= 1) { alert ("Invalid username and/or password. You have " + count + t + " left."); document.myform.username.value = ""; document.myform.pword.value = ""; setTimeout("document.myform.username.focus()", 25); setTimeout("document.myform.username.select()", 25); count --; } else { alert ("Still incorrect! You have no more tries left!"); document.myform.username.value = "No more tries allowed!"; document.myform.pword.value = ""; document.myform.username.disabled = true; document.myform.pword.disabled = true; return false; } } </script> <form name = "myform"> <p>ENTER USER NAME <input type="text" name="username"> ENTER PASSWORD <input type="password" name="pword"> <input type="button" value="Check In" name="Submit" onclick= "validate()"> </p> </form> Hello, I am currently working on my school's website. The site is laid out with a DIV on the left set up as a menu (called "leftmenu") and a DIV to the right to display the content (called "maincontent"). Clicking a link in leftmenu calls a script which changes the content of "maincontent". The script currently works as it should except for one small error. The appropriate heading, text and image load for each link, but the formatting between the image and the paragraph is lost. When the page originally loads, the image is set to "float:left" and the paragraph wraps around it to the right. However, when the script runs and changes the contents, the paragraph no longer wraps around the image, but is written below it. Javascript function: Code: var nov12="News for November 12"; var nov11="News for November 11"; var nov10="News for November 10"; function writeNews(title,image,txt) { document.getElementById("newsTitle").innerHTML=title; document.getElementById("newsImage").src=image; document.getElementById("newsText").innerHTML=txt; } HTML for the links calling the function and maincontent: Code: <div class="leftmenu"> <h3>News</h3> <ul class="leftmenu"> <li class="leftmenu"><a class="leftmenu" href="javascript:writeNews('November 12','img1.jpg',nov12)">Nov 12</a></li> <li class="leftmenu"><a class="leftmenu" href="javascript:writeNews('November 11','img2.jpg',nov11)">Nov 11</a></li> <li class="leftmenu"><a class="leftmenu" href="javascript:writeNews('November 10','img3.jpg',nov10)">Nov 10</a></li> </ul> </div> <div class="maincontent"> <h3 id="newsTitle">School News</h3> <img id="newsImage" class="newsimagestyle" src="img1.jpg" /> <p id="newsText"><img id="newsImage" class="newsimagestyle" src="" />Select the date from the menu on the left for news posted on that day.</p> </div> I have also attached the "before.jpg" and "after.jpg" screen captures from the relevant section of the website so you can see what changes are happening to the formatting. BEFO AFTER: Any help to keep the formatting in the same would be greatly appreciated. Thanks. Phil |