JavaScript - Having Java Script Switch Pictures
Good afternoon!
I am very new to javascript and I am having trouble getting Javascript to work right. What I am trying to do is when a user clicks one of the boxes, the box will switch to a random picture (3 different ones). It is supposed to work like memory but with three of the same for a match, not just two. I am unsure if I am telling Java the right code. I am not sure if I am linking Java correctly to html. Here is my code, please help me!!! Code: <html> <head> <title></title> <script language="JavaScript"> Var score= 0; var multiplier =1; var counter = 0; // overall counter (1..3) var counter1 = 0; // number of times picture 1 was picked var counter2= 0; // number of times picture 2 was picked var counter3 = 0; // number of times picture 3 was picked var picture1 = 1.gif var picture2 = 2.gif var picture3 = 3.gif function uncover (ref) { if (ref.alt != "0") return; if (counter == 3) if (click() ) choosePicture(); } function choosePicture() { Math.random() = number; if(number <= .33) return picture1; else if(number > .33) && (number <= .66) return picture2; else return picture3; } function click() { } </script> </head> <style type="text/css"> input { text-align: center; background: #004080; color: white } </style> </script> <form> </head> <body> <center> <table border="1" cellspacing="0" cellpadding="5"> <tr> <td><A HREF="javascript:choosePicture();"><img src="0.gif"> </A> </td> <td><A HREF="javascript:choosePicture();"><img src="0.gif"> </A> </td> <td><A HREF="javascript:choosePicture();"><img src="0.gif"> </A> </td> </tr> <tr> <td><A HREF="javascript:choosePicture();"><img src="0.gif"> </A> </td> <td><A HREF="javascript:choosePicture();"><img src="0.gif"> </A> </td> <td><A HREF="javascript:choosePicture();"><img src="0.gif"> </A> </td> </tr> <tr> <td><A HREF="javascript:choosePicture();"><img src="0.gif"> </A> </td> <td><A HREF="javascript:choosePicture();"><img src="0.gif"> </A> </td> <td><A HREF="javascript:choosePicture();"><img src="0.gif"> </A> </td> </tr> </table> </center> </body> </html> Similar TutorialsHi there, I saw this on the website for the new blackberry playbook and want to do something similar to that. http://us.blackberry.com/playbook-tablet/ Does anyone know of a script that will let me have 5 pictures or so and it will automatically go through them all but you can fastforward to the picture you like by clicking on a dot at the bottom like on the blackberry website? Hope I explained that well enough Hopefully this is a noob and simple question to answer, but I used this random ads script and modified it to show random boxarts for PS3 games.. http://javascript.internet.com/misce...andom-ads.html You can see what I'm trying to do he http://empireelite.org/index2.htm - (temporary page just for testing the code, refresh and see that the PS3 boxarts become randomized) Everything looks perfect in Internet Explorer, but in Firefox it looks to have about 15px in spacing on both top and bottom. I know the table itself is fine, because everything fits fine on the real main page http://www.empireelite.org/ The pictures are also not overlapping the cell. It's 9 pics x 22 width, (198px in a 200px wide cell) and it has the same spacing even if I just have 1 pic there using the script. Is there a code I can add or remove to get rid of the spacing in Firefox? I already removed , spacing from this line: function randomorder(targetarray, spacing) { and removed +spacing from this line: document.write(targetarray[the_one]+spacing) Neither did anything and the script works the same way without those small pieces of code (I'm not sure what either of them did to begin with). Here is the javascript page I'm using: http://empireelite.org/randomAds.js And also View Source in this test page: http://empireelite.org/index2.htm I'm using a image of the day script and my pictures will not be located at the site where the code will be. Code: images[0] = "<img src='yourimage.jpg'>" Do I/can I use the link such as <a href="http://www.sample.com/mphases.htm"> right where (yourimage) is, in between the quotes to link to an offsite picture? Could someone retype this snippet of code showing how it would look for me? Thanks I need to assign a key in the javascript to actually make the javascript work,. I have a bookmark in chrome , a javascript , which actually works when clicked on it .,. but how can i edit it so that i can actually make it work on click a key or combination of keys. i want to declare the key or keycombo in the script itself .,. the script is for catching the selected text on the webpage and opening a new tab(or window) and doing an exact search search of the selected text using google.com .,., So I want it to work it this way ., select the text press a key and it opens a new tab (or window) with an xact search .,. i want to declare the key or keycombo in the script itself .,. the script is for catching the selected text on the webpage and opening a new tab(or window) and doing an exact search search of the selected text using google.com .,., So I want it to work it this way ., select the text press a key and it opens a new tab (or window) with an xact search .,. Thanks in advance ., Nani I was hoping someone could help me fix this javascript code. I have been working for hours and it does not work. <html> <head> <title>Moondoe's Coffee House</title> </head> <script type="text/javascript"> var drink, ounces; prompt( "Enter the drink type:espresso, latte, cappuccino, americano" ); prompt( "Enter the ounce size: 8, 12, 16" ); var shots = prompt ( "Enter the number of shots" ); if ( drink == "espresso") price = 1.40; if ( drink == "latte") || drink == "cappuccino" ) { if ( ounce == 8 ) price = 1.95; else if ( ounce == 12 ) price = 2.35; else if ( ounce == 16 ) price = 2.75; } if ( drink == "americano" ) price = 1.20 + ( ( (ounce/8) -1 ) * .30 ); price = price + ( (shots-1) * .50 ); price = price * 1.055; price = Math.round ( price*100 ) /100; alert ( "Your " + ounce + "oz. " + drink + "with " + shots + "\nshots of espresso costs: $ " + price ); alert( "drink = " + drink + "ounce = "ounce + "shots = "shots ); </script> </html> how to get first 4 digits of mobile number using substing method and then how to check that number in if condition using java script.that is i entered the mobile number 9688786064.i want to check first four digits 9688 .in that same check all the entered number only 9688 started nymber can allow to store data base..how can i develop the program..plz help me var ph1=document.getElementById('ph'); ph1=ph.substring(0,4) is it correct or not .if it is correct then tell further steps.if it wrong tell me the correct code hi i have this code i want to put a java script for this java scrip should be (amt1*amt2)+(amt3)*(amt4)=amt5 if (amt1*amt2)+(amt3)*(amt4) > amt5 should giver mesage on keyup of amount amt4 plzz help me how do i put javascript for this ...........plz help me Code: <table width="1113" height="99" border="0"> <tr bgcolor="#99FF66"> <td width="60"><div align="center"><strong>GROUP ID</strong></div></td> <td width="46"><div align="center"><strong>PART ID</strong></div></td> <td width="97"><div align="center"><strong>ITEM NAME</strong></div></td> <td width="144"><div align="center"><strong>UNIT</strong></div></td> <td width="144"><div align="center"><strong>a/b/c</strong></div></td> <td width="144"><div align="center"><strong>Qty/Crtn</strong></div></td> <td width="144"><div align="center"><strong>Nbr of Crtns</strong></div></td> <td width="144"><div align="center"><strong>Nett Wt/Crt</strong></div></td> <td width="152"><div align="center"><strong>Grs Wt/Crtn</strong></div></td> </tr> <?php $noofrow=0; $result10 = mysql_query("SELECT * FROM Ibws_Data WHERE Sc_No='$PcNo' AND Seq_No='$SeqNo' "); // $row1000 = mysql_fetch_array( $result1000 ); //$Sub_Total=""; while($row10 = mysql_fetch_array( $result10 )) { //$ttlamt=mysql_number_format(); $noofrow++; ?> <tr bgcolor="#99CC66"> <td><label> <?php echo '<input name="Group_ID'.$noofrow.'" value="'.$row10['Group_ID'].'" type="text" size="8" maxlength="12" readonly="readonly" style="text-align:center" />' ; ?> </label></td> <td><label> <?php echo '<input name="Part_ID'.$noofrow.'" value="'.$row10['Part_ID'].'" type="text" size="8" maxlength="12" readonly="readonly" style="text-align:center" />' ; ?> </label></td> <td><label> <?php echo '<input name="Name'.$noofrow.'" value="'.$row10['Name'].'" type="text" size="20" maxlength="25" readonly="readonly" style="text-align:center" />' ; ?> </label></td> <td><label> <?php echo '<input name="Unit'.$noofrow.'" value="'.$row10['Unit'].'" type="text" size="8" maxlength="25" readonly="readonly" style="text-align:center" />' ; ?> </label></td> <td><label> <?php echo '<input name="cat'.$noofrow.'" value="a" type="text" size="8" maxlength="25" readonly="readonly" style="text-align:center" />' ; ?> </label></td> <td><label> <?php echo '<input name="amt1'.$noofrow.'" value="a" type="text" size="8" maxlength="25" readonly="readonly" style="text-align:center" />' ; ?> </label></td> <td><label> <?php echo '<input name="amt2'.$noofrow.'" value="a" type="text" size="8" maxlength="25" readonly="readonly" style="text-align:center" />' ; ?> </label></td> <td><label> <?php echo '<input name="amt3'.$noofrow.'" value="a" type="text" size="8" maxlength="25" readonly="readonly" style="text-align:center" />' ; ?> </label></td> <td><label> <?php echo '<input name="amt4'.$noofrow.'" value="a" type="text" size="8" maxlength="25" readonly="readonly" style="text-align:center" />' ; ?> </label></td> <td><label> <?php echo '<input name="amt5'.$noofrow.'" value="a" type="text" size="8" maxlength="25" readonly="readonly" style="text-align:center" />' ; ?> </label></td> </tr> <tr> <td><label> <input type="submit" name="button" id="button" value="Submit" /> </label></td> <td><label></label></td> <td><label></label></td> <td> </td> <td><label></label></td> <td><label></label></td> </tr> </table> <p> </p> <p> </p> </form> plz help me with a sample java scrip code Can someone help me with this javascript? It works fine with 10 images, but when I add the 11th it will not rotate the 11th image but still rotate the 1st 10. <br> <script type="text/javascript"> var imgs1 = new Array("/resource/resmgr/Ad_Banner/ad16.jpg","/resource/resmgr/Ad_Banner/ad13.jpg","/resource/resmgr/Ad_Banner/ad14.jpg","/resource/resmgr/Ad_Banner/ad8.jpg","/resource/resmgr/Ad_Banner/ad15.jpg","/resource/resmgr/Ad_Banner/ad18.jpg","/resource/resmgr/Ad_Banner/ad12.jpg","/resource/resmgr/Ad_Banner/ad19.jpg","/resource/resmgr/Ad_Banner/ad20.jpg","/resource/resmgr/Ad_Banner/ad21.jpg","/resource/resmgr/Ad_Banner/ad21.jpg","/resource/resmgr/ad_Banner/ad3.jpg"); var lnks1 = new Array("http://www.adamscollision.com","http://www.huntleyrealty.com","http://www.trinitycpraed.com","http://www.sccah.com/?page=SCFestival","http://www.blazekshomefurnishings.hdspd.com","http://www.sccah.com/?page=JB_Const","http://tgconsultantsinc.com/","http://blueskiespilotshop.com/index.html ","http://www.aaaglass.com/ ","http://www.carytravelexpress.com/","http://www.sccah.com/?page=Ad_Inquiry "); var alt1 = new Array("Adams Collision","Huntley Realty","Trinity","Sun City Arizona","Hunter Douglas Window Coverings and Custom Draperies","J&B Construction","TGI Consulting","Blue Skies","AAA Glass","Cary Travel Express","THIS COULD BE YOUR AD!!!"); var currentAd1 = 0; var imgCt1 = 11; function cycle1() { if (currentAd1 == imgCt1) { currentAd1 = 0; } var banner1 = document.getElementById('adBanner1'); var link1 = document.getElementById('adLink1'); banner1.src=imgs1[currentAd1] banner1.alt=alt1[currentAd1] document.getElementById('adLink1').href=lnks1[currentAd1] currentAd1++; } window.setInterval("cycle1()",4000); </script> <a href=""http://www.adamscollision.com"" id="adLink1" rel="nofollow" target="_blank"> <img src="/resource/resmgr/Ad_Banner/ad16.jpg" id="adBanner1" border="0" width="170" height="200"></a> hi i want to implement this java script . This is the Original Java script page . Where you see if i click on the yahoo or | google buttons the new window is loading and the same page is displaying with a tab bar menu and close button. I want to implement the same on one of my documents where i created css and java script based drop down menus. But when i tried to implement the same java script on my own page its not working properly.Please help me fix it . I have changed the code only on Button -4 Link-1 only Hers the Live Demo of the page : Live Demo Of the page Heres the Java Script: Java Script Here's the CSS : Code: html,body { padding:0; margin: 0px; background: #306f80; } #wrapper{ width: 1024px; margin-right: auto; margin-left: auto; background: #FFFFFF; height: 1000px; } #header{ height: 100px; width: 1024px; background: url(../images/header.png) repeat-x; } .icons_hold{ float: right; height: 55px; width: 200px; position: relative; top: 10px; right: 10px; } .navestyle{ width: 1024px; font-weight: bold; margin-right: auto; margin-left: auto; } .navestyle:after{ /*Add margin between menu and rest of content in Firefox*/ content: "."; display: block; height: 0; clear: both; visibility: hidden; } .navestyle ul{ border: 1px solid #BBB; width: 100%; background: url(../images/nav_bg.png) repeat-x center center; /*THEME CHANGE HERE*/ padding: 4px 0; margin: 0; text-align: center; font: 12px Verdana, Arial, Helvetica, sans-serif; } .navestyle ul li{ display: inline; margin-right: 2px; margin-left: 2px; } .navestyle ul li a{ color: #494949; padding: 4px 45px 4px 7px; margin: 0; text-decoration: none; border-right: 1px solid #DADADA; } .navestyle ul li a:hover, .navestyle ul li a.selected{ /*script dynamically adds a class of "selected" to the current active menu item*/ background: url(../images/hover.png) repeat-x center center; /*THEME CHANGE HERE*/ color: #FFFFFF; } /* ######### Style for Drop Down Menu ######### */ .dropmenudiv{ position:absolute; top: 0; border: 1px solid #BBB; /*THEME CHANGE HERE*/ border-bottom-width: 0; font:normal 12px/18px Verdana, Arial, Helvetica, sans-serif; z-index:100; background-color: white; visibility: hidden; width: 200px; } .dropmenudiv a{ width: auto; display: block; text-indent: 3px; border-bottom: 1px solid #BBB; /*THEME CHANGE HERE*/ padding: 2px 0; text-decoration: none; font-weight: bold; color: black; } * html .dropmenudiv a{ /*IE only hack*/ width: 100%; } .dropmenudiv a:hover{ /*THEME CHANGE HERE*/ background-color: #F0F0F0; } img { border: none; } .pagination{ padding: 0px 2px 2px; clear: both; } .pagination ul{ margin: 0; padding: 0; text-align: center; /*Set to "right" to right align pagination interface*/ font-size: 16px; } .pagination li{ list-style-type: none; display: inline; padding-bottom: 1px; } .pagination a, .pagination a:visited{ padding: 0 5px; border: 1px solid #9aafe5; text-decoration: none; color: #2e6ab1; } .pagination a:hover, .pagination a:active{ border: 1px solid #2b66a5; color: #000; background-color: #FFCC33; } .pagination a.currentpage{ background-color: #2e6ab1; color: #FFF !important; border-color: #2b66a5; font-weight: bold; cursor: default; } .pagination a.disablelink, .pagination a.disablelink:hover{ background-color: white; cursor: default; color: #929292; border-color: #929292; font-weight: normal !important; } .pagination a.prevnext{ font-weight: bold; } #demoArea { padding: 10px ; height: 580px ; background: #FFFFFF ; /*border: 1px solid black ;*/ /*display: table ;*/ } #demoLinks { width: 20% ; border-right: 1px dotted blue ; float: left ; } #demoBrowser { position: relative; width: 950px; margin-left: auto; margin-right: auto; } #tabBrowser { position: absolute ; width: 100% ; } /* --------------- TABS -------------------*/ #tabDemo { display: none } #tabContainer { display: block ; } #tabs { cursor: default ; list-style-type: none ; /*width: 560px ;*/ margin: 0 ; padding: 0 ; } #tabs li { background: #FFFBF0 ; border: 1px solid green ; border-bottom: 0 ; -moz-border-radius-topleft: 5px ; -moz-border-radius-topright: 5px ; float: left ; width: 100px ; min-width: 35px ; height: 20px ; margin: 0 2px 3px 0 ; padding-left: 3px ; } .tabTitle { float: left ; width: 80% ; height: 100% ; overflow: hidden ; } .closeTab { text-align: center ; text-transform: uppercase ; margin: 2px 3px 2px 80% ; border: outset 1px #D40000 ; } .closeTab:hover { background: #000000; } /* --------------- BROWSER -------------------*/ #tabContent { position: relative ; clear: both ; width: 100% ; } #tabContent div { position: absolute ; width: 100% ; } Here's the Mark Up : 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" lang="en" xml:lang="en"> <head> <title>Testing page</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <link rel="stylesheet" type="text/css" href="css/css.css" /> <script type="text/javascript" src="js/tabbed_browser.js"></script> <script type="text/javascript" src="js/chrome.js"> </script> </head> <body> <div id="wrapper"> <div id="header"> <div class="icons_hold"><a href="#"><img src="images/home.png" title="home" /></a> <a href="#"><img src="images/help.png" title="help" /></a> <a href="#"><img src="images/sign_out.png" title="signe out" /></a></div> </div> <div class="navestyle" id="navemenu"> <ul> <li><a href="#" title="chaitnyas testing page">Button-1</a></li> <li><a href="#" title="chaitnyas testing page">Button-2</a></li> <li><a href="#" title="chaitnyas testing page">Button-3</a></li> <li><a href="#" rel="dropmenu1" title="chaitnyas testing page">Button-4</a></li> <li><a href="#" rel="dropmenu2" title="chaitnyas testing page">Button-5</a></li> <li><a href="#" rel="dropmenu3" title="chaitnyas testing page">Button-6</a></li> <li><a href="#" title="chaitnyas testing page">Button-7</a></li> <li><a href="#" title="chaitnyas testing page">Button-8</a></li> </ul> </div> <!--1st drop down menu --> <div id="dropmenu1" class="dropmenudiv"> <a id="link1" onclick="openTab('link1')" href="http://yahoo.com." title="chaitnyas testing page" ><img src = "images/1.gif" /> Link-1</a> <a href="link-2.htm" title="chaitnyas testing page"><img src = "images/2.gif" /> Link-2</a> <a href="link-3.htm" title="chaitnyas testing page"><img src = "images/3.gif" /> Link-3</a> <a href="link-4.htm" title="chaitnyas testing page"><img src = "images/4.gif" /> Link-4</a> <a href="link-5.htm" title="chaitnyas testing page"><img src = "images/5.gif" /> Link-5</a></div> <!--2nd drop down menu --> <div id="dropmenu2" class="dropmenudiv" style="width: 150px;"> <a href="#" title="chaitnyas testing page"><img src = "images/6.gif" /> Link-1</a> <a href="#" title="chaitnyas testing page"><img src = "images/7.gif" /> Link-2</a> <a href="#" title="chaitnyas testing page"><img src = "images/8.gif" /> Link-3</a></div> <!--3rd drop down menu --> <div id="dropmenu3" class="dropmenudiv" style="width: 150px;"> <a href="#" title="chaitnyas testing page"><img src = "images/9.gif" /> Link-1</a> <a href="#" title="chaitnyas testing page"><img src = "images/10.gif" /> Link-2</a> <a href="#" title="chaitnyas testing page"><img src = "images/11.gif" /> Link-3</a></div> <script type="text/javascript"> cssdropdown.startchrome("navemenu") </script> <p><br /> <div id="demoBrowser"> <div id="tabBrowser"> <div id="tabContainer"> <ul id="tabs"><li id="tabDemo"><div class="tabTitle">Google</div><div class="closeTab">x</div></li> </ul> </div> <div id="tabContent"> </div> </div> </div> </div><br /> <br /> <br /> <br /> <br /> <br /> <br /> <br /> </p> <div class="pagination"> <ul> <li><a href="products.htm" class="currentpage" title="Products">1</a></li> <li><a href="products1.htm" title="Products">2</a></li> <li><a href="products2.htm" title="Products">3</a></li> </ul> </div><br /> </p> </div> </body> </html> please hekp to sort this out.. .. The price of a ticket to a passenger on AOU-Airways is computed based on the following table: [9] Class Price First Class KD 300 Economy Class (with meal) KD 150 Economy Class (without meal) KD 130 Using nested if statements, write a JavaScript code which will work according to the following specifications: a. Read the class that the passenger wants to travel on. b. If the class is the first class, print the price of ticket. c. If the class is the economy class, ask the user if he/she wants a meal on the flight. Then print the price of the ticket according to the response of the passenger. The program should simply accept one possible strings the user enters; it is not required to work for all possible inputs such as First, first, FIRST or Yes , yes, YES. hi, i have a html form and i have three text boxes named Max Accessories: Accessory SKU: Accessory CPC ID: and i want a javascript functionality like, if the user enters in the max accessories text box value as 1, then the below two text boxes should update like automatically like below, AcceSsory 1 SKU ACCESSORY 1 CPC ID SIMILARLY if user enters Max accessories value as 2 in the text box, then the below two text boxes should update like automatically like below AcceSsory 1 SKU ACCESSORY 1 CPC ID AcceSsory 2 SKU ACCESSORY 2 CPC ID onchange of the key, for accessory it should call some function in the same page and dynamically update. can any one please provide, a solution for this , thanks. i am getting error in document.createElement('input') index1 = { init: function() { var but=document.getElementById('button1'); index1.addEvent(but,'onClick',fun1,false); }, fun1: function(e) { var bo=document.getElementById('body1'); var in=document.createElement('input'); in.type="button"; in.value="songs"; in.id="song"; bo.appendChild(in); } } index1.addEvent(window,'load',index.init,false); Hi all i have this code
Code: <TR id="tr1" onClick="var ret_val = clickedfun(this.id)" /> , and this javacript code Code: <script language="javascript">function clickedfun(tid) {var elemento = document.getElementById(tid);if(confirm("Tem a certeza que quer remover esta fila?")){elemento.style.visibility='hidden';var numero=tid.substring(2,tid.length);return numero;}}</script>; i want to get the return value of the javascript function to use in database for deletion of that value please help i'm usin jsp and java classes. Thanks guys. i have been experimenting on this...i don't know why this happens i am sure there is something wrong with my javascript code this is what happens... Code: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <script language="Javascript" type="text/javascript"> function addRow() { // grab the element, i.e. the table your editing, in this we're calling it // 'mySampleTable' and it is reffered to in the table further down on the page // with a unique of id of you guessed it, 'mySampleTable' var tbl = document.getElementById('mySampleTable'); // grab how many rows are in the table var lastRow = tbl.rows.length; // if there's no header row in the table (there should be, code at least one //manually!), then iteration = lastRow + 1 var iteration = lastRow; // creates a new row var row = tbl.insertRow(lastRow); // left cell // insert a cell // var cellLeft = row.insertCell(0); // here we're just using numbering the cell, like anything else you don't // have to use this, but i've kinda noticed users tend to like them // var textNode = document.createTextNode(iteration); // takes what we did (create the plain text number) and appends it the cell // we created in the row we created. NEAT! //cellLeft.appendChild(textNode); // right cell // another cell! var cellRight = row.insertCell(1); // creating an element this time, specifically an input var el = document.createElement('input'); // a data type of text el.type = 'text'; // the name of the element txtRow, and because this is dynamic we also // append the row number to it, so for example if this is the eigth row // being created the text box will have the name of txtRow8. super fantastic. el.name = 'txtRow' + iteration; // the exact same thing with a unique id el.id = 'txtRow' + iteration; // set it to size of 40. setting sizes is good. el.size = 40; // same thing as earlier, append our element to our freshly and clean cell cellRight.appendChild(el); // select cell // our last cell! var cellRightSel = row.insertCell(0); // create another element, this time a select box var sel = document.createElement('select'); // name it, once again with an iteration (selRow8 using the example above) sel.name = 'selRow' + iteration; // crates options in an array // the Option() function takes the first parameter of what is being displayed // from within the drop down, and the second parameter of the value it is carrying over sel.options[0] = new Option('text zero', 'value0'); sel.options[1] = new Option('text one', 'value1'); sel.options[2] = new Option('text two', 'value2'); // append our new element containing new options to our new cell cellRightSel.appendChild(sel); el.size = 40; } function removeRow() { // grab the element again! var tbl = document.getElementById('mySampleTable'); // grab the length! var lastRow = tbl.rows.length; // delete the last row if there is more than one row! if (lastRow > 2) tbl.deleteRow(lastRow - 1); } </script> <html> <head> <title>Page Title</title> </head> <body leftmargin="0" topmargin="0"> <form action="addrow.html" name="eval_edit" method="post" format="html"> <table align="center" width = "75%"> <tr> <td align = "center"> click add to you know, add a row, and remove to remove a row, and submit to submit your page! whee! </td> </tr> <tr> <td align = "center"> <!--- very imporant to give the table an id ---> <!--- otherwise it won't know where to edit ---> <table border="1" id="mySampleTable"> <tr> <td> Type of Leave </td> <td> No. of Days allowed </td> </tr> <!--- i create the initial row by hand, there are a lot of ---> <!--- different ways to do this depending on what parsing ---> <!--- language you use, i found this was easiest for the ---> <!--- snippet, but experiment, do your thing mang. ---> <!--- this matches the same specs we laid out in the javascript ---> <tr> <td><select name="selRow0"> <option value="value0">text zero</option> <option value="value1">text one</option> <option value="value2">text two</option> </select> </td> <td> <input type="text" name="txtRow1" id="txtRow1" size="40" /> </td> </tr> </table> <!--- our buttons call our javascript functions when clicked ---> <input type="button" value="Add" onclick="addRow();" /> <input type="button" value="Remove" onclick="removeRow();" /> <input type="submit" value="Submit" /> </td> </tr> </table> </form> </body> </html> Hi, I have a .js file for creating a menus..in that i have a menu called 'reserved', i just want to remove the name from the menu i want the menu size should be the same as earlier.. what i need to do? Hi everyone , I have been working with java script for a couple of weeks now and have run into some practice obstacles, ok so I am trying to build a html java program for my website and I wants there to be a web page in which users can dynamically change the styles of page elements (e.g.,background, text) by typing the style name into a dialog box. So basically enter a word and the that word should be set to change the attributes once entered in. Ive tried working with if else statements but have run into many problems. Again I am a beginner and am trying to self teach myself if you all could help me that would be great. Thanks Sash i am newbie on javascript i want to get my domain to twitter but i spent 3 hour nothing find my code java script function Code: <script type="text/javascript"> function putmydomainhere() { var url; url = (document.domain) document.write(url); } </script> html code Code: <a href="http://twitter.com/share" class="twitter-share-button" data-counturl="http://+ putmydomainhere() +/get?123" data-url="http://+ putmydomainhere() +/get?123" data-via="myuserid" data-count="horizontal">Tweet</a> <script type="text/javascript" src="http://platform.twitter.com/widgets.js"></script> thank you hi friends, i got a two textboxes,my requirement is when i enter two charectors in textbox1,automatically cursor must point to textbox2. but in my case it is not happening like above,when ever i enter charector3,curosr is entering textbox2 along with the entered charector, please find my code below and help me in modifying it. 1.abc.ascs.cs file code is: txtCategory.Attributes.Add("OnKeyPress", "Focus1(this.id);"); 2.abc.ascx file code is: <script type="text/javascript"> function Focus1(that) { if (document.getElementById(that).value.length>1) { //If Len(.Text) = 2 Or Len(TXTbox.Text) = 5 Then document.getElementById('ShippedQtyAdjEntry1_txtDetail').disabled=false; document.getElementById('ShippedQtyAdjEntry1_txtDetail').style.backgroundColor="White"; document.getElementById('ShippedQtyAdjEntry1_txtDetail').focus(); } <script type="text/JavaScript"> function refreshPage(s) { window.location.reload(); if((s.options[s.selectedIndex].value) = "zed=catcher") { alert (s.selectedIndex); //this is showing <?PHP //the next lines does not execute????? echo $form['service_code']->renderLabel(); echo $form['service_code']->renderError(); echo $form['service_code']; ?> } } </script> please help? thanks I have good knowledge in web designing like Coding Psd to Html format. But i don't have much knowledge in using JavaScript for in website designing like for basic animation using it with hover or drop down list etc. I am using JavaScript in the form's only for basic form submission. Can anyone suggest me some good resource to learn JavaScript.
|