JavaScript - Easy Question.....i Think :)
I don't know much about programming but I can't figure out how this works and I want to implement it on my site. I want to copy the code from this page
sdapc.com/billing/pay-online.html and implement something similar. I understand that the form uses post and then goes to form-action.php and the information is verified using the script.js, but how is the information sent anywhere. I mean, I don't see any reference to any script that compiles the data and sends it to the billing department. How do they get the info??? Thanks in advance. P.S. If anyone knows of similar scripts or methods out there of doing this I'm all ears (or eyes) This would just be temporary until full automation is developed. For now, I don't mind entering their info into PayPal myself. Similar TutorialsI am just learning javascript. I am playing around with different html elements and document.write. I have a HTML page with elements h1, h2, h3, and h4. I want to write something (in this example "found it") next to the elements. <head> <script type="text/javascript" language="javascript"> var headerList = getElementsByTagNames('h1,h2,h3,h4'); if (headerList) { document.write("Found it!"); } </script> </head> <body> <h1> </h1> <h2> </h2> <h3> </h3> <h4> </h4> </body> Why doesnt this work? I am assuming my logic is flawed? hey i just started javascript, i have a little syntax question: <HTML> <HEAD> <script type="text/javascript"> function ifPrime(input) { thesqrt = Math.sqrt(input) for(a = 2; a <= thesqrt; a++) { if(input % a == 0) return false; } return true; } function nthPrime(input) { for(i = 2; i <= input; i++) { if( ifPrime(i) ) { document.write(i); document.write("<br />"); } } } </script> </HEAD> <BODY> Enter how many primes <INPUT TYPE=TEXT NAME="userInput" SIZE=6> <INPUT TYPE=BUTTON VALUE="Do it" ONCLICK="value = userInput"> <br /> <br /> <script type="text/javascript"> nthPrime(value) </script> </BODY> </HTML> i would like it post 2 3 5 7 when i type in 10 and press the button. how do I do that? any other programing tips would be appreciated I'm very very new to javasctipt/html programming and have come upon a stump.Let me explain Code: <form name="for1"> <input type="radio" name="fr1"value="1" > 5 <br> <input type="radio" name="fr1"value="2" > Όσα τα pixels<br> <input type="radio" name="fr1"value="3" > Δεν υπάρχει όριο<br> </form> <input type="button" value="Εκχώρηση Απάντησης" onClick="temp=document.for1.fr1.value"> What i was hoping with this is to store the value of the selected radio in a variable.The variable is declared at the beginning (not shown here).I would appreciate greatly if i'm on the right track to please tell me how to make this work and if possible not create functions and other complicated procedures as it will take me out of my "learning curve".Thanks in advance Hey! Sorry if this is a very remedial question, but I'm trying to make a table, of even and odd numbers organized in two columns (with as many rows as it takes to get through the sequence) and I'm having an issue with my code, obviously - haha. I'm still slightly new.. here is my code Code: document.write('<table>'); for (i=1; i < 50; i++) { document.write("<tr>"); for (j = 0; j < 50; j++) { if (j % 2==0) { document.write('<td>' + j + '</td>'); } else { document.write('<td>' + i + '</td>'); } } } document.write("</tr>); document.write("</table>"); Any help would be greatly appreciated! hi guys, l am trying to learn javascript, although certain things seem to be easy to understand, l still have plenty of questions. so l was reading some articles on w3schools and l was an interesting table about operations. http://i1087.photobucket.com/albums/...kesnosense.png if you check above's table you will see at the increment section as well decrement , you will see that in some cases the x and y dont have the same value, now l was just wondering, what is the difference between x=++y and x=y++ ? This is javascript that turns your current url into a tinyurl. How would I go about getting this to open into a new tab instead of the same tab? Code: javascript:void(location.href='http://tinyurl.com/create.php?url='+encodeURIComponent(location.href)) I know it's possible to do this in php, but what would the javascript equivalent be? Code: var scripts = new Array(); scripts[] = "PHP"; scripts[] = "ASP"; scripts[] = "JavaScript"; scripts[] = "HTML"; But this obviously doesn't work. And just to clarify, I mean the ability to add an array whenever I want to in my page instead of having to name the array like... Code: var scripts = new Array(); scripts[0] = "PHP"; scripts[1] = "ASP"; scripts[2] = "JavaScript"; scripts[3] = "HTML"; I'm using it for such as in a form: Code: <input type="text" name="formarray[]"> <input type="text" name="formarray[]"> Thank you in advance. Hey guys, this should be a very easy fix for someone who knows Javascript (which I don't). The following code allows the class "ul.slideshow-nav li" to control the navigation of the slideshow, I want to adjust this script to allow "ul.slideshow-nav li" AND "ul.slideshow-nav2 li" to do this, possible? Code: $slideshow = { context: false, tabs: false, timeout: 8000, fx: 'scrollLeft', slideSpeed: 900, tabSpeed: 900, init: function() { this.context = $('#content-slideshow'); this.tabs = $('ul.slideshow-nav li', this.context); this.tabs.remove(); this.startSlideshow(); }, startSlideshow: function() { $('div.slideshow > ul', $slideshow.context).cycle({ fx: $slideshow.fx, pager: $('ul.slideshow-nav', $slideshow.context), pagerAnchorBuilder: $slideshow.startTabs, befo $slideshow.Tabactive, timeout: $slideshow.timeout, speed: $slideshow.slideSpeed, fastOnEvent: $slideshow.tabSpeed, pauseOnPagerHover: true, pause: true }); }, startTabs: function(i, slide) { return $slideshow.tabs.eq(i); }, Tabactive: function(currentSlide, nextSlide) { var activeTab = $('a[href="#' + nextSlide.id + '"]', $slideshow.context); if(activeTab.length) { $slideshow.tabs.removeClass('on'); activeTab.parent().addClass('on'); } } }; $(function() { $slideshow.init(); }); Help me anyone I am completely stuck. If you do this I shall build a shrine in your honour. In the following code the 'for' loop gets data from the relevant tags of an XML file, then puts them into the 'txt' variable. It then moves onto the next record in the XML file and does the same thing. However, I don't want the contents of txt to be overwritten each time the code loops through each record. Instead I want it to add to txt, then loop around and add the new contents of txt to the previous contents of txt. I tried txt = txt + artist + title + year; but this didn't work. Can anyone explain how to do this? Please note the contents of the variables are strings of text not numbers. Code: x=xmlDoc.getElementsByTagName("CD"); i=0; function displayCD() { for (var i=0;i<x.length;i++) { artist=(x[i].getElementsByTagName("ARTIST")[0].childNodes[0].nodeValue); title=(x[i].getElementsByTagName("TITLE")[0].childNodes[0].nodeValue); year=(x[i].getElementsByTagName("YEAR")[0].childNodes[0].nodeValue); txt= "Artist: " + artist + "<br />Title: " + title + "<br />Year: "+ year; } document.getElementById("showCD").innerHTML=txt; } hi guys, l am currently studying web technologies on a part time basis, and learning javascript. l got a very useful website, but still l dont understand certain things like this one: Quote: When a function has performed an assignment, it may provide a value that other functions would need, for any reason you judge necessary. When a function produces a value an makes it available to other functions, such a function is said to return a value. To define a function that returns a value, just before the closing curly bracket, type the return keyword followed by the value that the function returns. The value should be a valid and expected type. Because JavaScript is not a type-checking language, meaning it hardly checks anything you are doing, it is your responsibility to make sure that your function returns the right value. Here is a function that returns a value: function rectangleArea(length, height) { var area; area = length * height * 3.14159; return area; } Even if a function returns a value, it can still be called like any other function. If a function returns a value, its name can be assigned to a variable to give a value to, or change the value of, the variable. Here is an example: Code: <Script Language="JavaScript"> function rectangleArea(length, height) { var area; area = length * height * 3.14159; return area; } function displayArea() { var l, h, rectArea; l = 52.05; h = 46.55; rectArea = rectangleArea(l, h); document.write("The area of the is ", rectArea); } </Script> <Script Language="JavaScript"> displayArea(); </Script> what l understand from the code is, l have 2 functions, first function is a return function and has got a value, but where is this value going? l mean what's happing with it? l mean l cant see this return value in the second function, why? l ma also not understand why we need to have 2 functions, why not just 1 ?/?? can someone explain me one by one the lines maybe? thanks I need to change the source of an image but I can't seem to figure out how. I believe that I have the correct syntax, but it does not seem to be working. Maybe I am typing it in wrong or something. I try to test my javascript by typing the script: <strong>javascript:document.getElementById('img1').src='./images/image1.jpg';</strong> into the address bar. Nothing happens. I also try to test it out by putting this on the page, but once again, nothing happens. Code: <script type="text/javascript"><!-- document.getElementById('im1').src="./scripts/'.$upload_image.'"; //--></script> This is what my HTML code looks like: Code: <img src="./images/temp_wizard_picture.gif" alt="" style="padding:4px; background:#fff; border:1px #bbb solid;" id="img1" /> Can somebody please fill me in on what I am doing wrong. Thank you. Short version at bottom Need to add an array before an array to init thousands of arrays. Mostly worked out, just need to add an array before an array. ........Please check it out. Really want to finish this tonight or tomorrow. Alright, so two days later I finally have this portion working but its only because of the awesome people of this forum and unforunately these people thought I had some half decent grasp of javascript (which I don't) and so their answers were meant to solve my problem but each time I was left with no idea how to repeat what they did. So, I've learned a lot of extra stuff that I really could have done without in the effort to try and understand what they did. This is all well and good because I'm much farther than I am had I gone it alone (so thank you!) but please, anyone that posts an answer, could you try and explain a bit of how I might use your solution again. For example, today I was confused for about an hour because I didn't understand how [CODE]var newArray=[], a, i=0;CODE] worked but only after staring at it long enough and not finding anything on google related to "values inputed after array initialization" did I finally realized that these were not params of a new array but just new variables. Code: var alphabetArray =['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z','0','1','2','3','4','5','6','7','8','9','all1']; var a; var i=0; while(a=alphabetArray[i++]){ eval('var _img_'+a+' = []'); eval('var _h_'+a+' = []'); eval('var _r_'+a+' = []'); eval('var _m_'+a+' = []'); eval('var _yt_'+a+' = []'); } alert(_h_all1) and its working perfectly but I somehow I need to add Code: var pageNum = ['','p2_','p3_','p4_','p5_','p6_','p7_','p8_','p9_','p10_'] need to add pageNum to every alphabetArray so... _img_a = [],_img_p2_a = [], img_p3_a = [].... _img_p10_a = [] repeated for every variable in alphabetArray. _yt_p10_all1=[] Super short version Code: var alphabetArray =[letters/numbers]; var a; var i=0; while(a=alphabetArray[i++]){ eval('var _img_'+a+' = []'); } // works now I need to add 10 page prefixes before each var in alphabetArray Code: var pageNum = ['','p2_','p3_','p4_','p5_','p6_','p7_','p8_','p9_','p10_'] need to add pageNum to every alphabetArray so... _img_a = [],_img_p2_a = [], img_p3_a = [].... _img_p10_a = [] repeated for every variable in alphabetArray. _yt_p10_all1=[] Please explain how this might be possible in a way that your dog might understand. I have written the following code which returns a simple times table. The problem is that I want the resulting times table written to the div id=results section in the body of the html page rather than writing it to another page. I hope that makes sense! Thanks in advance for any help. <html> <head> <script type="text/javascript"> function timestable() { var num = parseInt(document.timesForm.times.value); var counter = 1; while (counter<=12) { document.write(counter+" X "+num+" = "+counter*num+"<br />"); counter++; } } </script> </head> <body> <form id="timesForm" name="timesForm"> <p>Enter the number he <input type="text" id="times" /></p> <p> <input type="button" value="Show Times Facts" onclick="timestable()" /> </p> <div id="results">Times Facts</div> </form> </body> </html> hey guys im trying to make something that selects two different images but it keeps selecting two images that are the same, and dont know how to go about it to make it select two different. please help Code: <!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 http-equiv="Content-Type" content="text/javascript; charset=utf-8" /> <title>Untitled Document</title> <script language="JavaScript"> <!-- var theImages = new Array() theImages[0] = '100.jpg' theImages[1] = '200.JPG' theImages[2] = '300.JPG' theImages[3] = '400.jpg' var j = 0 var p = theImages.length; var preBuffer = new Array() for (i = 0; i < p; i++){ preBuffer[i] = new Image() preBuffer[i].src = theImages[i] } var whichImage = Math.round(Math.random()*(p-1)); function showImage(){ document.write('<img src="'+theImages[whichImage]+'">'); } //--> </script> </head> <body> <div align="center"></div> <table width="996" height="511" border="1"> <tr> <th scope="col"><script language="JavaScript"> <!-- showImage(); //--> </script> or <script language="JavaScript"> <!-- showImage(); //--> </script> </th> </tr> </table> </body> </html> I don't know if this is in the correct section, sorry if it is not. I am creating a form in mailchimp for my site, I need to know if I can put the following all on one line instead of "last name" on one line and "input box" on another line. I know this is probably an easy fix for the pro's! <div class="mc-field-group" style="margin: 1.3em 5%;clear: both;overflow: hidden;"> <label for="mce-LNAME" style="display: block;margin: .3em 0;line-height: 1em;font-weight: bold;">Last Name <strong class="note-required">*</strong> </label> <input type="text" value="" name="LNAME" class="required" id="mce-LNAME" style="margin-right: 1.5em;padding: .2em .3em;width: 95%;float: left;z-index: 999;"> </div> Hi All Javascript novice here so just need a bit of help. I'm sure it's something easy I have a form, attributes below: Code: <form id="frmOrder" name="input" method="post" onsubmit="return OnSubmitForm();"> I need the deposit input value to match the total input value if the weeks10 checkbox is ticked. The reason for this is my client requires full payment if this box is ticked. This must be done upon form submission. The reason for this is the email.php and payment.php submission pages collect the deposit value using $_POST and use that as the payment total Attributes for inputs below: Weeks10 checkbox: Code: <input type="checkbox" name="weeks10" id="weeks10" class="weeks10" /> Deposit input: Code: <input type="text" name="deposit" id="txtTotal3" readonly="readonly" size="2" value="0.00"></input> Totals input: Code: <input type="text" readonly="readonly" id="txtTotal" value="0.00" size="2" name="total"/> I'm using the following script: Code: <script type="text/javascript"> function OnSubmitForm() { if(document.input.weeks10[0].checked == true) { document.input.deposit.value = document.input.total.value; } return true; } function OnSubmitForm() { if(document.input.operation[0].checked == true) { document.input.action ="email.php"; } else if(document.input.operation[1].checked == true) { document.input.action ="payment.php"; } return true; } </script> The problem is, the second function works (email.php or payment.php action depending on radio selection). But the first one to adjust the total doesnt Now I know my script is wrong so would somebody be kind enough to lend me a hand? Thanks! *Edit - forgot to mention the example is live here if you need to see the full code. It's a fairly complicated form (for me atleast anyway) http://lake-form.carpbookings.co.uk Hello, I have a script that makes a link a different color on click, i would like to add a hover color to the links that are NOT active. Script below. Thanks in advance! Code: function activate(el) { var links=document.getElementsByTagName("a"); for(i=0;i<links.length;i++) { if(links[i].className=="toggle") { links[i].style.color="#999"; } } el.style.color="#DF8700"; } Hi all, I am trying to add this slider: http://cssglobe.com/lab/easyslider1.5/04.html to my website but due to my inexperience can't seem to get it to work.. please help... Here is my code: <!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> <title>Welcome to Somerset Wedding Wishes</title> <meta http-equiv="content-type" content="text/html;charset=UTF-8" /> <script type="text/javascript" src="easyslider1.5/js/jquery.js"></script> <script type="text/javascript" src="easyslider1.5/js/easySlider.js"></script> <script type="text/javascript"> $(document).ready(function(){ $("#slider").easySlider({ auto: true, continuous: true }); }); </script> <style type="text/css"> <!-- body { background-color: #000000; background-image: url(bg1.jpg); background-repeat: repeat-x; } #slider{} #slider ul, #slider li{ margin:0; padding:0; list-style:none; } #slider li{ width:696px; height:241px; overflow:hidden; } #prevBtn, #nextBtn{ display:block; width:30px; height:77px; position:absolute; left:-30px; top:71px; } #nextBtn{ left:696px; } #prevBtn a, #nextBtn a{ display:block; width:30px; height:77px; background:url(images/btn_prev.gif) no-repeat 0 0; } #nextBtn a{ background:url(images/btn_next.gif) no-repeat 0 0; } --> </style> </head> <body leftmargin="0" topmargin="0" marginwidth="0" marginheight="0"> <!-- ImageReady Slices (Untitled-1) --> <table width="922" height="864" border="0" align="center" cellpadding="0" cellspacing="0" id="Table_01"> <tr> <td> <img src="images/home_01.png" width="922" height="230" alt=""></td> </tr> <tr> <td><div id="slider"><ul> <li><img src="easyslider1.5/images/01.jpg" alt="pic1"></li> <li><img src="easyslider1.5/images/02.jpg" alt="pic2"></li> <li><img src="easyslider1.5/images/03.jpg" alt="pic3"></li> ... </ul> </div> <div align="center"></div></td> </tr> <tr> <td> <img src="images/home_03.png" width="922" height="239" alt=""></td> </tr> <tr> <td> <img src="images/home_04.png" width="922" height="170" alt=""></td> </tr> </table> <!-- End ImageReady Slices --> }); </body> </html> I can not figure out why my function is not working or why my alert does not pop up.. can anyone help? When you enter a total in the box, all I need to do is have a total with shipping show up in an alert box. (Minimum shipping is $1.50, if the total is over $25 shipping is 10%) <code> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>CalcShipping</title> <meta http-equiv="content-type" content="text/html; charset=iso-8859-1" /> <script type="text/javascript"> /* <![CDATA[ */ function calcShipping() { var priceInput; var total; priceInput = document.form1.subtotal.value; if (priceInput <= 25) total = 1.5 + number(priceInput); } else { total = number(priceInput) + (number(priceInput) * .1); } window.alert("Your total is $" + total + ); /* ]]> */ </script> </head> <body> <h1>To find out your shipping costs, please enter your purchase price:</h1> <form action ="" name ="form" method = "post" onsubmit="calcShipping();"> <div style="text-align: center"> <input type="text" name="subtotal" value= ""/> <input type="submit" value ="submit"/> </div> </form> </body> </html> </code> |