JavaScript - Can't Start It, Please Help
I'm a student and i missed first Javascript. Could someone please just put me into the right way to make it work, I can't honestly find an answer anywhere.
E.g. I have following declaration in the head section of html: <script language="javascript" type="text/javascript" src="java1.js" </script> My aim is to initialize a string variable firstname in java.js to be displayed on a page. I declare it in java.js as: var firstname="Tom"; I put document.write statement to the head of html section as: <script language="javascript" type="text/javascript" src="java1.js"> document.write; </script> ....but it doesn't work. Could someone just point me into the right direction, I tried w3c and others but unsuccessfully, it looks like everyone just seamlessly go straight to the coding. Similar TutorialsHere is the code I am working with, been at it for 3 days now. I am at a loss....cant see why it shouldnt work. window.onload = defineMarquee; var timeID; var marqueeTxt = new Array(); var marqueeOff = true; function defineMarquee(){ var topValue = 0; var allElems = document.getElementsByTagName("*"); for (var i=0; i < allElems.length; i++){ if (allElems[i].className =="marqueTxt") marqueeTxt.push(allElems[i]); } for (i = 0; i < marqueeTxt.length; i++) { if (marqueeTxt[i].getComputedStyle) { topValue = marqueeTxt[i].getPropertyValue("top"); } else if (marqueeTxt[i].currentStyle) { topValue = marqueeTxt[i].currentStyle("top"); } } document.getElementById("startMarquee").onclick = startMarquee; document.getElementById("stopMarquee").onclick = stopMarquee; } function startMarquee(){ if (marqueeOff == true) { timeID = setInterval("moveMarquee()", 50); marqueeOff = false; } } function stopMarquee(){ clearInterval(timeID); marqueeOff = true; } function moveMarquee(){ var topPos = 0; for (i=0; i < marqueeTxt.length; i++){ if (marqueeTxt[i].getComputedStyle) { topPos = parseInt(marqueeTxt[i].getPropertyValue("top")); } else if (marqueeTxt[i].currentStyle) { topPos = parseInt(marqueeTxt[i].currentStyle("top")); } if (topPos < -110) { topPos = 700; } else { topPos -= 1; } marqueeTxt[i].style.top = topPos + "px"; } } Ok so i want to code something like this http://i45.tinypic.com/29y10s1.png I want it to where the user just clicks on one of the buttons and it changes to the thing. But then i want to be where if the user doesn't click anything then it just changes by itself. so like on a timer. Can anyone give me some references that might help me get started with coding this. I have no clue where tos tart. Hey all, I am very new to javascript. I have been using this stacks menu I am sure you may have seen elsewhe http://net.tutsplus.com/tutorials/ja...ck-navigation/ I have modified it a bit though as I will want to use my own graphics and change a little bit how it works. I managed to make it so that the images become transparent when the stack is put back in place and then non transparent when they come back out. The problem I have is that I need the images to be transparent initially when they are in the stack. You can see the problem he http://bit.ly/cdelJu Here is the javascript for this: Code: $(function () { // Stack initialize var openspeed = 300; var closespeed = 300; $('.stack2>img').toggle(function(){ var vertical = 0; var horizontal = 90; var $el=$(this); $el.next().children().each(function(){ $(this).animate({top: vertical + 'px', left: horizontal + 'px', opacity: '10'}, openspeed); vertical = vertical + 40; horizontal = (horizontal+.75)*1.15; }); $el.next().animate({top: '40px', left: '10px'}, openspeed).addClass('openStack') .find('li a>img').animate({width: '50px', marginLeft: '9px'}, openspeed); $el.animate({paddingBottom: '0'}); }, function(){ //reverse above var $el=$(this); $el.next().removeClass('openStack').children('li').animate({top: '-33px', left: '-10px', opacity: '0'}, closespeed); $el.next().find('li a>img').animate({width: '79px', marginLeft: '0'}, closespeed); $el.animate({paddingBottom: '35px'}); }); // Stacks additional animation $('.stack2 li a').hover(function(){ $("img",this).animate({width: '56px'}, 100); $("span",this).animate({marginRight: '30px'}); },function(){ $("img",this).animate({width: '50px'}, 100); $("span",this).animate({marginRight: '0'}); }); }); and here is the css: Code: /* ================ STACK #2 ================ */ .stack2 { position: fixed; top: 28px; left: 90px;} .stack2 > img { position: relative; cursor: pointer; padding-bottom: 35px; z-index: 2; } .stack2 ul { list-style: none; position: absolute; top: 7px; cursor: pointer; z-index: 1; } .stack2 ul li { position: absolute; } .stack2 ul li img { border: 0; } .stack2 ul li span { display: none; } .stack2 .openStack li span { font-family: "Lucida Grande", Lucida, Verdana, sans-serif; display:block; height: 14px; position:absolute; top: 17px; right:60px; line-height: 14px; border: 0; background-color:#000; padding: 3px 10px; border-radius: 10px; -webkit-border-radius: 10px; -moz-border-radius: 10px; color: #fcfcfc; text-align: center; text-shadow: #000 1px 1px 1px; opacity: .85; filter: alpha(opacity = 85); } #dock { top: 0; left: 100px; } a.dock-item { position: relative; float: left; margin-right: 10px; } .dock-item span { display: block; } .stack { top: 0; } .stack ul li { position: relative; } /* IE Fixes */ .stack2 { _position: absolute; } .stack2 ul { _z-index:-1; _top:-15px; } .stack2 ul li { *right:5px; } annd the html: Code: <div class="stack2"> <img src="images/stacks/stack-down.png" alt="stack"/> <ul id="stack2"> <li><a href=""><span>Aperture</span><img src="images/stacks/aperture.png" alt="Aperature" /></a></li> <li><a href="#"><span>All Examples</span><img src="images/stacks/photoshop.png" alt="Photoshop" /></a></li> <li><a href="example3.html"><span>Example 3</span><img src="images/stacks/safari.png" alt="Safari" /></a></li> <li><a href="example2.html"><span>Example 2</span><img src="images/stacks/coda.png" alt="Coda" /></a></li> <li><a href="index.html"><span>Example 1</span><img src="images/stacks/finder.png" alt="Finder" /></a></li> </ul> </div> Any help is greatly appreciated! Hi guys I'm new to the forums here. I want to learn how to use Javascript and AJAX along with jquery or prototype to develop a dynamic website. For example, I like how www.dropbox.com works. Everything has a transition, and you can drag and drop things around which is what I like. Ultimately I hope to be able to develop a dynamic website with social networking elements. I know my goals are lofty, but where should I get started and what should I learn. I have some cursory programming experience with visual basic, fortran and html. Any particular books that would help me learn. Ideally a book would have some programming "challenges" or small projects that would give me some experience. Thanks hi every one i;m new here and i love to know programming languages and some friends adviced me to start with java script then php , and i guess i'm at the right place can you please tell how to start and where to begain i'm really don't know anything about programming
I've just started to learn Javascript at college, and I made a little code that traps people in a dialogue box loop. var escape = 0 for(escape === 0; escape <= 1 confirm("Going somewhere?") I want to know if there is a site, or a possibility I can start this code, simple by sending friends a URL they can click on. For completely innocent purposes, of course. Thanks! This forum give luck, I get the solution myself regards. Hi everyone. I'm trying to figure out how to make it so that when someone enters a number in the first textbox to start counting from and then they enter a second number where to stop counting. then the user must enter a number to step up/down by when counting.. there are 3 textboxes, one for start, one for end and one for the step up/down. When the user pushes the button the page clears and then the numbers will show.. If they use the same starting and ending number they have to be alerted that it is not valid. The user can enter a starting number bigger than the ending number. Take into account that a user might enter a positive or negative step value any tips or guidance for this is very appreciated Hi, Using this script Code: <script language="javascript" type="text/javascript"> function compareDate() { var start = document.beginDate.startdate.value; var end = document.termDate.enddate.value; var stDate = new Date(start); var enDate = new Date(end); var compDate = enDate - stDate; if(compDate >= 0) return true; else { alert("Please correct-end date is before begin date."); return false; } } </script> Have two input boxes for Start Date and End Date. Both boxes have JQuery linked code for datepicker calendar. Want to ensure that end date is >= to start date. Want dates validated on losing focus from end date input (text) box - like this - I guess. Code: <input style="width: 70px" type="text" id="enddate" onblur="function compareDate();" /> The reason I am here is that, of course, what I have is not working. Appreciate your help. Thanks - John Maybe somone can help me out he I am trying to validate two dates, to make sure one comes before another. This is the code I have: Code: function validate_time(fielda, fieldb) { if (fielda < fieldb ) { ErrFields.push("The start date must be before the end date"); return false; } else { return true; } } and it is called using: Code: validate_time(startdate, enddate); This code dosen't work at all, so I guess I am way off. If anyone knows what may be the problem or any suggestions I would apprecate it. Thanks. Hey helpful people. I'm looking for a better solution to refreshing a page of mine, which currently single page (no frames) using meta refresh. To convert it something where it (using frames) would either: a. keep trying to refresh untill a var is recieved from the content, or b. present the browser with a button to refresh and a message that loading failed. But honestly i am a noob at javascript, to an extend i dont have much idea where to start on such a project. but learned this is not possible with regular html that is widely supported anyways. i suspect the:.. window.xx.location='url' ..is useful in this regard, but other than that i am blank on where to start. Any help is appresiated. Thanks in advance Jilli I run a christian ministry that mentors kids. One aspect of this is tracking their chores. All of the online sticker charts we have used over the yrs have vanished. Currently we are using one that only puts checkmarks in the squares and the kids are bored with it. So I want to create a clickable table that puts an icon in the cells on click. I know a little html and ive designed websites with a visual editor. If someone could please point me in the right direction where I would even begin to learn how to create the script I described it would be greatly appreciated. In case it is not clear what I would like to create this video shows the most recent site we used.( hopefully including the link is not advertising since the site shown in the video is gone. If it is I apologize) It is no longer up. Hence my wanting to create a similar script that can be added to our church's website. thanks again for any guidance. a bit of an aside please don't just suggest we use an app. I know there are apps out that do what I described and more but, an online version is preferable because the kids don't live with their mentors. Also some of them only have computer access at the library. so it is unreasonable to expect them to have a smart phone or tablet. Reply With Quote 01-10-2015, 10:42 PM #2 Old Pedant View Profile View Forum Posts Supreme Master coder! Join Date Feb 2009 Posts 28,311 Thanks 82 Thanked 4,754 Times in 4,716 Posts Well, just to start with, you are going to need "baqkend" code. That is, you will need a database where all the information can be recorded and server-side code to maintain and access that information. The most likely candidate for this would be a MySQL database and PHP code to interface to it and to produce the web pages. You really have no choice but to do it this way: If the child used the exact same computer *AND* had an account on that computer, then you could do it by saving the information on that computer. But with a library-based computer, (a) accounts are anonymous, not assigned [typically] and (b) the child may not be able to use the exact same computer on subsequent days. By doing the bulk of the work on a server, you ensure that any computer (or pad or phone) can access the same information and present the same interface (or perhaps a modified interface for smaller screens). This is *NOT* a trivial task. Never mind the pretty graphics: Just the code behind the scenes is enough that nobody is going to do it in a few days (or at least is not going to get it right in a few days). You have to locate a host ($$ per month/year), get a domain name ($$ per year), create a database, create the tables in that database, write the PHP code to modify the database, write the PHP code to access the database, write the PHP code to create the HTML pages, create the icons and other graphics for the pages, and so on. my problem is when the page loads, the javascript slideshow starts to play even if the image has not yet finished loading... in effect the first image is not displayed since the image is still loading.. what i hopefully want is to start the slide show when all the images has loaded so that the slideshow will run smooth.. Code: <div id="slideshow"> <img src="Image/image1.jpg" alt="Slideshow Image 1" class="active" /> <img src="Image/image2.jpg" alt="Slideshow Image 2" /> <img src="Image/image3.jpg" alt="Slideshow Image 3" /> <img src="Image/image4.jpg" alt="Slideshow Image 4" /> </div> javascript Code: function slideSwitch() { var $active = $('#slideshow IMG.active'); if ( $active.length == 0 ) $active = $('#slideshow IMG:last'); // use this to pull the images in the order they appear in the markup var $next = $active.next().length ? $active.next() : $('#slideshow IMG:first'); // uncomment the 3 lines below to pull the images in random order // var $sibs = $active.siblings(); // var rndNum = Math.floor(Math.random() * $sibs.length ); // var $next = $( $sibs[ rndNum ] ); $active.addClass('last-active'); $next.css({opacity: 0.0}) .addClass('active') .animate({opacity: 1.0}, 1000, function() { $active.removeClass('active last-active'); }); } $(function() { setInterval( "slideSwitch()", 4000 );//speed of changing image }); I basically want a random image to show up on my webpage and start scrolling through more images i've set to that list. Here's what I have thus far. However, It'll always start by bringing up the same image and then change to an error image: Code: <html> <head> <script type="text/javascript" language="javascript"> <!-- Hide script from old browsers adImages = new Array("http://i155.photobucket.com/albums/s298/Connorconway/Office_Season_6_Blu-Ray.jpg","http://i155.photobucket.com/albums/s298/Connorconway/Halloween_Blu_Ray.jpg") imgCt = adImages.length firstTime = true function rotate() { if (document.images) { if (firstTime) { thisAd = Math.floor((Math.random * imgCt)) firstTime = false } else { thisAd++ if (thisAd == imgCt) { thisAd = 0 } } document.myPicture.src=adImages [thisAd] setTimeout("rotate()", 3 * 1000) } } //--> End hiding script from old browsers </script> </head> <body onload="rotate()"> <img src="http://i155.photobucket.com/albums/s298/Connorconway/Office_Season_6_Blu-Ray.jpg" width="400" height="300" name="myPicture" alt="Ad Banner" /> </body> </html> Here's the Website I'm having problems on (So you can visually see what I mean - Under "TV ManiaX Home Page sub-heading): http://tvmaniax.myfastforum.org/index.html Thank you for any help you can give _________________ Code: /* Assignment * Change Request #7 Requestor: Ninfa Pendleton - Rapid City, SD Write the program in Java (with a graphical user interface) and have it calculate and display the mortgage payment amount from user input of the amount of the mortgage and the user's selection from a menu of available mortgage loans: - 7 years at 5.35% - 15 years at 5.5% - 30 years at 5.75% Use an array for the mortgage data for the different loans. Read the interest rates to fill the array from a sequential file. Display the mortgage payment amount followed by the loan balance and interest paid for each payment over the term of the loan. Add graphics in the form of a chart. Allow the user to loop back and enter a new amount and make a new selection or quit. Please insert comments in the program to document the program. *///////////////////////////////////////////////// // Java utilities import javax.swing.*; import java.awt.event.*; import java.lang.Math.*; import java.text.NumberFormat; import javax.swing.ButtonGroup; import java.awt.Graphics; public class MortgageCR7 extends JFrame { public static void main(String[] args) { new MortgageCalculator5(); } // Declare buttons, text fields, and labels private JButton calculate; private JButton exit; private JButton calc; private JTextField enterAmount; private JTextField enterInterest; private JTextField enterMonth; private JLabel loan; private JLabel interest; private JLabel mRate; private JLabel blankspace; private JLabel data; private JLabel data1; private JLabel data2; private JRadioButton term7; private JRadioButton term15; private JRadioButton term30; public MortgageCR7() { // set the size of the frame this.setSize(350, 350); // what the "exit" button will do when clicked. this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); // Title of frame this.setTitle("Mortgage Calculator"); // Create the layout JPanel mainpanel = new JPanel(); // panel1 JPanel panel1 = new JPanel(); data = new JLabel("Please fill out the amount of the loan."); panel1.add(data); mainpanel.add(panel1); // panel2 JPanel panel2 = new JPanel(); loan = new JLabel("Amount of Loan"); enterAmount = new JTextField(8); panel2.add(loan); panel2.add(enterAmount); mainpanel.add(panel2); // panel3 JPanel panel3 = new JPanel(); data1 = new JLabel("Choose between rate & term"); panel3.add(data1); mainpanel.add(panel3); // panel4 JPanel panel4 = new JPanel(); ButtonGroup choice = new ButtonGroup(); term7 = new JRadioButton("30 Years @ 5.75%"); term15 = new JRadioButton("15 Years @ 5.5%"); term30 = new JRadioButton("7 Years @ 5.35%"); panel4.add(term7); choice.add(term7); panel4.add(term15); choice.add(term15); panel4.add(term30); choice.add(term30); mainpanel.add(panel4); // panel5 JPanel panel5 = new JPanel(); calc = new JButton("Calculate Choice"); panel5.add(calc); mainpanel.add(panel5); // panel6 JPanel panel6 = new JPanel(); data2 = new JLabel("Or fill in yourself."); panel6.add(data2); mainpanel.add(panel6); //panel7 JPanel panel7 = new JPanel(); interest = new JLabel("Interest Rate"); enterInterest = new JTextField(8); panel7.add(interest); panel7.add(enterInterest); mainpanel.add(panel7); // panel8 JPanel panel8 = new JPanel(); mRate = new JLabel("Term of Loan"); enterMonth = new JTextField(8); panel8.add(mRate); panel8.add(enterMonth); mainpanel.add(panel8); // panel9 JPanel panel9 = new JPanel(); blankspace = new JLabel(" "); panel9.add(blankspace); mainpanel.add(panel9); // panel10 JPanel panel10 = new JPanel(); calculate = new JButton("Calculate"); exit = new JButton("Exit"); panel10.add(calculate); panel10.add(exit); mainpanel.add(panel10); // Creating the event listener ClickListener click = new ClickListener(); // Create Action Listeners calculate.addActionListener(click); exit.addActionListener(click); calc.addActionListener(click); // adds all 10 panels together this.add(mainpanel); // set see the frame this.setVisible(true); } public void paint(Graphics g) { double width = 900.00; int height= 400; double x=1.0; double y=0.0; int counter = 0; double xincrement = (width/(dblLoanDuration*12)); double yincrement = height/dblLoanAmount; g.drawString("Payments", 65, 10); while (counter <= 10) { x = x + xincrement; g.drawString(Integer.toString((int)((((dblLoanDuration*12)/10)*counter))), (int)((width/10)*counter)+55, 20); counter++; drawn = true; } double amount=dblLoanAmount; double payment=amount/12; g.drawString("Amount", 0, 20); while (y < height) { y = y + (height/12); g.drawString(paymentFormat.format(amount), 0, (int)y); amount = amount-payment; } // begin the events // Create Action Listeners calculate.addActionListener(click); public void actionPerformed(ActionEvent p) { if (p.getSource() == calc) // if user clicks the calculate button { try { // convert text entry into numbers double receiveAmount = Double.parseDouble(enterAmount.getText()); // create the arrays for the three different loans int Terms[] = {7, 15, 30}; // loan in years double InterestArray[] = {5.35, 5.5, 5.75}; // interest as a percent // Array 1 if (term7.isSelected()) { double receiveInterest = InterestArray[0]; double receiveTerms = Terms[0]; double interest1 = (receiveInterest / (12 * 100)); double term1 = (receiveTerms * 12); double term2 = (1 + interest1); double pay1 = Math.pow(term2, -term1); double payment = ((receiveAmount * interest1) / (1 - pay1)); double interestpay; double remainBal = receiveAmount; // create the number format NumberFormat fixdecimal = NumberFormat.getNumberInstance(); fixdecimal.setMinimumFractionDigits(2); fixdecimal.setMaximumFractionDigits(2); // Create counter for (int x = 1; x <= term1; x++) { interestpay = (remainBal * interest1); double interestout = 0; remainBal = (remainBal - (payment - interestpay)); interestout = (interestout + interestpay); // The output based on amount input and loan selection. JOptionPane.showMessageDialog(null, "Original Balance = $" + receiveAmount + "\nPayment #" + x + "\nMonthly Payment $" + fixdecimal.format(payment) + "\nRemaining Balance $" + fixdecimal.format(remainBal) + "\nInterest Paid $" + fixdecimal.format(interestpay), "Payment History", JOptionPane.PLAIN_MESSAGE); } // Exit or enter option. int finalanswer = JOptionPane.showConfirmDialog(null, "Would you like to input a new amount?" + "\n\n(chose Yes to continue or No to Exit)", "Continue", JOptionPane.YES_NO_OPTION); if (finalanswer == JOptionPane.NO_OPTION) { System.exit(0); } else if (finalanswer == JOptionPane.YES_OPTION) { // if the user chooses 'yes' the amount field will blank out enterAmount.setText(null); } // Array 2 } else if (term15.isSelected()) { double receiveInterest = InterestArray[1]; double receiveTerms = Terms[1]; double interest1 = (receiveInterest / (12 * 100)); double term1 = (receiveTerms * 12); double term2 = (1 + interest1); double pay1 = Math.pow(term2, -term1); double payment = ((receiveAmount * interest1) / (1 - pay1)); double interestpay; double remainBal = receiveAmount; // create the number format NumberFormat fixdecimal = NumberFormat.getNumberInstance(); fixdecimal.setMinimumFractionDigits(2); fixdecimal.setMaximumFractionDigits(2); // Create counter for (int x = 1; x <= term1; x++) { interestpay = (remainBal * interest1); double interestout = 0; remainBal = (remainBal - (payment - interestpay)); interestout = (interestout + interestpay); // The output based on amount input and loan selection. JOptionPane.showMessageDialog(null, "Original Balance = $" + receiveAmount + "\nPayment #" + x + "\nMonthly Payment $" + fixdecimal.format(payment) + "\nRemaining Balance $" + fixdecimal.format(remainBal) + "\nInterest Paid $" + fixdecimal.format(interestpay), "Payment History", JOptionPane.PLAIN_MESSAGE); } // Exit or enter option. int finalanswer = JOptionPane.showConfirmDialog(null, "Would you like to enter a new amount?" + "\n\n(chose Yes to continue or No to Exit)", "Continue", JOptionPane.YES_NO_OPTION); if (finalanswer == JOptionPane.NO_OPTION) { System.exit(0); // If the user chooses 'yes' the amount field will blank out } else if (finalanswer == JOptionPane.YES_OPTION) { enterAmount.setText(null); } // Array 3 } else if (term30.isSelected()) { double receiveInterest = InterestArray[2]; double receiveTerms = Terms[2]; double interest1 = (receiveInterest / (12 * 100)); double term1 = (receiveTerms * 12); double term2 = (1 + interest1); double pay1 = Math.pow(term2, -term1); double payment = ((receiveAmount * interest1) / (1 - pay1)); double interestpay; double remainBal = receiveAmount; // create the number format NumberFormat fixdecimal = NumberFormat.getNumberInstance(); fixdecimal.setMinimumFractionDigits(2); fixdecimal.setMaximumFractionDigits(2); // Create counter for (int x = 1; x <= term1; x++) { interestpay = (remainBal * interest1); double interestout = 0; remainBal = (remainBal - (payment - interestpay)); interestout = (interestout + interestpay); // The output based on amount input and loan selection. JOptionPane.showMessageDialog(null, "Original Balance = $" + receiveAmount + "\nPayment #" + x + "\nMonthly Payment $" + fixdecimal.format(payment) + "\nRemaining Balance $" + fixdecimal.format(remainBal) + "\nInterest Paid $" + fixdecimal.format(interestout), "Payment History", JOptionPane.PLAIN_MESSAGE); } // Exit or enter option. int finalanswer = JOptionPane.showConfirmDialog(null, "Would you like to enter a new amount?" + "\n\n(chose Yes to continue or No to Exit)", "Continue", JOptionPane.YES_NO_OPTION); if (finalanswer == JOptionPane.NO_OPTION) { System.exit(0); // If the user chooses 'yes' the amount field will blank out } else if (finalanswer == JOptionPane.YES_OPTION) { enterAmount.setText(null); } } } catch (NumberFormatException e) { } } // Create a new event if (p.getSource() == calculate) { try { // turn text entries into numbers double receiveAmount = Double.parseDouble(enterAmount.getText()); double receivePerc = Double.parseDouble(enterInterest.getText()); double receiveTerm = Double.parseDouble(enterMonth.getText()); double receiveInterest = receivePerc; double receiveTerms = receiveTerm; double interest1 = (receiveInterest / (12 * 100)); double term1 = (receiveTerms * 12); double term2 = (1 + interest1); double pay1 = Math.pow(term2, -term1); double payment = ((receiveAmount * interest1) / (1 - pay1)); double interestpay; double remainBal = receiveAmount; // create the number format NumberFormat fixdecimal = NumberFormat.getNumberInstance(); fixdecimal.setMinimumFractionDigits(2); fixdecimal.setMaximumFractionDigits(2); // Create counter for (int x = 1; x <= term1; x++) { interestpay = (remainBal * interest1); double interestout = 0; remainBal = (remainBal - (payment - interestpay)); interestout = (interestout + interestpay); // The output based on amount input and loan selection. JOptionPane.showMessageDialog(null, "Original Balance = $" + receiveAmount + "\nPayment #" + x + "\nMonthly Payment $" + fixdecimal.format(payment) + "\nRemaining Balance $" + fixdecimal.format(remainBal) + "\nInterest Paid $" + fixdecimal.format(interestout), "Payment History", JOptionPane.PLAIN_MESSAGE); } // Exit or enter option. int finalanswer = JOptionPane.showConfirmDialog(null, "Would you like to enter a new amount?" + "\n\n(chose Yes to continue or No to Exit)", "Continue", JOptionPane.YES_NO_OPTION); if (finalanswer == JOptionPane.NO_OPTION) { System.exit(0); // if the user chooses 'yes' the amount field will blank out } else if (finalanswer == JOptionPane.YES_OPTION) { // resets the entry fields enterAmount.setText(null); enterInterest.setText(null); enterMonth.setText(null); } } catch (NumberFormatException e) { } } // Event Exit button if (p.getSource() == exit) { System.exit(0); } } } } Hi all, I am trying to wrap a text selection with BBCode. I have it working, but there is one final part I need help with. First, here's the code I'm using: Code: var range = ed.selection.getRng(true); var s = ed.dom.create('span', {}, ''); range.surroundContents(s); s.innerHTML = open + s.innerHTML + close; ed.selection.select(s); This is an explanation of each line: get the user's selection as a W3C compatible range create an empty <span> element surround the selection range with the span convert the selection from "selection" to "[bbcode]selection[/bbcode]" by using innerHTML select the new <span> element Of course, selecting the span ALSO selects the BBCode open and close tag... like in this pictu So, the last thing I need to do (the whole point of this post)... how do I MOVE the range start and end points so that only the selection is selected and NOT the whole thing? I will greatly appreciate if someone can tell me how to move those selection start and end points... Thanks! -- Roger Hello, I am arranging a validation form checking a start date (DepartureDate) against today's date to verify that it must be later than today's date, I am a newbie on javascript and I have tried various ways, unfortunately I have hit the wall and I need help. [CODE] <SCRIPT LANGUAGE="JAVASCRIPT" SCRIPT TYPE="TEXT/JAVASCRIPT"> function checkForm() { DepartureDate= /^(0[1-9]|[12][0-9]|3[01])[\/](0[1-9]|1[012])[\/](20)\d\d$/ //check if DepartueDate is valid entry var depdate=myform.DepartureDate.value; // get date from keyed text box var prsDepdate= Date.parse(depdate); // convert to date parse var currentDate = new Date();// today's date var now=Date.parse(currentDate);//parsed todays date if (!DepartureDate.test(depdate)) { alert("Departure Date must be entered in numbers in the following format dd/mm/yyyy with the first two year digits being 20yy"); return false; } //validation if departure Date is entered correctly if (prsDepdate<=currentDate) { alert("Departure Date must be later than Today's date!")//comparison if Departure Date is less than today return false; } } </SCRIPT> [CODE] Thanks a lot Hi. I am trying to learn how to make a Javascript menu for my webpage. I have made the menu and it works. I can collapse a submenu when I click on the menu header. I wan't it to start collapsed and then open a menu item when you click on it. I have figured out that it have something to do with the function Closeall(). But can't figure out what. Perhaps someone in here can help me or perhaps help me make a better menu. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta content="text/html; charset=utf-8" http-equiv="Content-Type" /> <title>IT-Menu</title> <script type="text/javascript" language="javascript1.3"> function closeall() { var divs=document.getElementsByTagName('div') for(var i=0; i<divs.length; i++) divs.style.display='none'; } function clicked(element) { var div=document.getElementById(element) if(div.style.display=='none') div.style.display='block'; else div.style.display='none'; return; } </script> </head> <body> <a href="#" onclick="clicked('MENU1')">MENU1</a><div id="MENU1"> <a href="#">SUBMENU1</a> <br /> <a href="#">SUBMENU2</a> </div> <br /> <a href="#" onclick="clicked('MENU2')">MENU2</a><div id="MENU2"> <a href="#">SUBMENU1</a> <br /> <a href="#">SUBMENU2</a> </div> </body> Hi guys, I've been using bumpbox (lightbox alternative) script for a while and decided I want to start it on page load. Don't know how to do it though, authors website has disappeared from the web (not a good sign is it) ..... anyway, here is the script activating line: Code: <script type="text/javascript"> doBump( '.bump',475, 500, '000', '130023', '0.95', 5, 1 ,'333', 15,'000', 3, Fx.Transitions.Bounce.EaseOut, Fx.Transitions.Bounce.EaseOut); </script> The problem is that it only appears when you click the link that has class bump assigned to it. how do i get it to appear on page load ? here is the full script if needed: |