JavaScript - How To Generate Mathematical Tables With Javascript
Similar TutorialsI'm really new to scripting. I created some forms using Adobe livecycle and I'm running into a problem. I have some fields that require A.P.R. and some other mathematical calculations. When I enter one number into one field or cell I get a message stating that there is an error arithmentic over/underflow. It seems that I need to add some type of code to let it know that there are more numbers involved in the formula. Can anyone tell me what type of books to buy or how I can resolve this. ok so heres where I stand, I don't know too much about javascript. Just enough to get me by. I am a PHP developer, I know how to do this in PHP but the client insists on doing it through javascript. Basically there are 3 different form values that determine the Premium Death Benefit Ratio. This is the formula the client wants: Premium to Death Benefit Ratio % (Created by formula = Annual (Level) Premium Amount (Divided by) Death Benefit Amount (equals a percentage) That percentage multiplied by Life Expectancy The 3 form values in the formula would be Annual Premium Amount (fypremium), Death Benefit Amount (dbp), Life Expectancy (average_le) I was messing around with javascript trying to figure it out and I have gotten no where since I am not used to writing formulas in JS. Anyways here is what I have so far: Code: function calculateLE(inputFieldId1, inputFieldId2, inputFieldId3, outputFieldId){ var DBR; var input = document.getElementById(inputFieldId).value; APA = document.getElementById(fypremium).value; DBA = document.getElementById(dbp).value; LE = document.getElementById(average_le).value; formula = document.getElementById(fypremium).value / document.getElementById(dbp).value = formula3; formula2 = document.getElementById(average_le).value * formula3; if { APA = "" } { document.getElementById(outputFieldId).value = "Error getting Annual Premium Amount"; } else if { DBA = "" } { document.getElementById(outputFieldId).value = "Error getting Death Benefit Amount"; } else if { LE = "" } { document.getElementById(outputFieldId).value = "Error getting Life Expectancy"; } else { document.getElementById(outputFieldId).value = formula3; } } Now I honestly have no clue if I am on the right track but what i've found on the net hasnt really pointed me in the right direction Here is the form values. Code: <input type="text" name="fypremium" id="fypremium" onblur="calculateLE('fypremium', 'dbp', 'average_le', 'premium_dbr')"> <input type="text" name="dbp" id="dbp" onblur="calculateLE('fypremium', 'dbp', 'average_le', 'premium_dbr')"> <input type="text" name="average_le" id="average_le" onblur="calculateLE('fypremium', 'dbp', 'average_le', 'premium_dbr')"> In a nut shell the values for the 3 inputs stated above will determine premium_dbr's value. fypremium / dbp = percentage; average_le * percentage = DBR (death benefit ratio); If someone could point me in the right direction to finishing this id be very greatful. Hi All, i want to achieve an effect like the following, please help 1. i want to get the current time, possibility no from client computer ( sometimes their time is wrong)? i dont know whether can achieve but if cannot, then never mind, just get from client computer. 2. for example now is 1:25 am, i want to generate dynamically every half an hour timing from 2 am(round up) till for example 11 am something like <select> <option>2:00</option> <option>2:30</option> ................ <option>11:00</option> </select> for me this is a bit complicated, anybody can help me? <option>3:00</option> Hello, I'm a complete javascript beginner so sorry if I'm just being stupid I wanted to know if it's possible for me to add a picture (as in a .png file) to a page by clicking on something which would then make an image appear on the screen (which I would then want to be able to drag and move but I made a different thread for that question) I hope this explanation made sense Thank you for your time I would like to remove some hosting imposed google ads on my phpbb board. Currently I accomplish this by deleting via javascript all the banners divs when the page is loaded. But unfortunately in that way advertisements are quickly displayed before disappearing. Now I am thinking about a different (neater) approach to my problem: maybe I might write some javascript code which interferes with the one injected by google thus generating the inability to show those annoying divs... Any idea? Hi, I have a problem. please help me in this regard. I have a combobox which contain numeric values from 1-7. i want to generate a table with 2 rows and 4 columns through javascript. Means when a user select numeric value like '3' from a combo box then a page generates '3' tables without refreshing a page. And if a user selects '4' from a combobox then a script generates 4 tables with 2 rows and 4 columns and so on. kindly guide me that how can i mkae this javascript. plz help I've done a bit of searching and I can't find the answer to my question. I'm working on a website for my business. I have some basic knowledge of coding but I'm mostly a code cobbler. I find various pieces and put it together and hope it works so take it easy on me. I have some code to display products on my site. It works fine. We just have a lot of products and for me to add each one by hand was getting ridiculous. I finally had the bright idea to use Javascript to generate the code for me and then copy it back into my actual HTML page. Last night I wrote the code below. It works perfectly except I have to constantly "View Source" in order to get the code. I was hoping to cut down on a step or two and have the code go into a TextArea. From there I can just select it and copy it into the HTML file. It should make things a little quicker and most importantly easier. Maybe after that I'll try to figure out how to write function to select everything in the TextArea and copy it to my clipboard. That would make things even faster. Any 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/html; charset=iso-8859-1" /> <title>Untitled Document</title> <SCRIPT LANGUAGE="JavaScript"> function calc (form) { var images = form.images.value; var imagesArray = images.split("\n"); var linebreak = "<br />"; var i=0; var j=0; var a=0; while(i < imagesArray.length) { if(j==0) { document.write (" <!-- -------------------------------------------- -->\n"); document.write (" <div id=\"cols3-top\"></div>\n"); document.write (" <div id=\"cols3\" class=\"box\">\n"); } a++; if(j/2!=1) { if(a==imagesArray.length) { document.write ("\n <!-- ---------------- -->\n\n"); document.write (" <div class=\"col last\">\n"); document.write (" <h3>Header</h3>\n"); document.write (" <p class=\"nom t-center\">\n"); document.write (" <a href=\"../../product_imgs/resins/pdu/54xxxgs/" + imagesArray[i] + ".jpg\" class=\"nivoZoom center\"><img src=\"../../product_imgs/resins/pdu/54xxxgs/" + imagesArray[i] + ".jpg\" alt=\"" + imagesArray[i] +"\" height=\"200px\" /></a></p>"); document.write (" <!-- /col-text -->\n"); document.write (" <div class=\"col-itemnum\">PDU: " + imagesArray[i] + "</div>\n"); document.write (" </div>\n"); document.write (" <!-- /col -->\n"); document.write (" <hr class=\"noscreen\" />\n"); document.write (" </div>\n"); document.write (" <div id=\"cols3-bottom\"></div>\n"); document.write (" <!-- /Columns End Here -->\n\n\n"); break; } else { document.write ("\n <!-- ---------------- -->\n"); document.write (" <div class=\"col\">\n"); document.write (" <h3>Header</h3>\n"); document.write (" <p class=\"nom t-center\">\n"); document.write (" <a href=\"../../product_imgs/resins/pdu/54xxxgs/" + imagesArray[i] + ".jpg\" class=\"nivoZoom center\"><img src=\"../../product_imgs/resins/pdu/54xxxgs/" + imagesArray[i] + ".jpg\" alt=\"" + imagesArray[i] +"\" height=\"200px\" /></a></p>"); document.write (" <!-- /col-text -->\n"); document.write (" <div class=\"col-itemnum\">PDU: " + imagesArray[i] + "</div>\n"); document.write (" </div>\n"); document.write (" <!-- /col -->\n"); document.write (" <hr class=\"noscreen\" />\n"); i++; j++; } } else { document.write ("\n <!-- ---------------- -->\n\n"); document.write (" <div class=\"col last\">\n"); document.write (" <h3>Header</h3>\n"); document.write (" <p class=\"nom t-center\">\n"); document.write (" <a href=\"../../product_imgs/resins/pdu/54xxxgs/" + imagesArray[i] + ".jpg\" class=\"nivoZoom center\"><img src=\"../../product_imgs/resins/pdu/54xxxgs/" + imagesArray[i] + ".jpg\" alt=\"" + imagesArray[i] +"\" height=\"200px\" /></a></p>"); document.write (" <!-- /col-text -->\n"); document.write (" <div class=\"col-itemnum\">PDU: " + imagesArray[i] + "</div>\n"); document.write (" </div>\n"); document.write (" <!-- /col -->\n"); document.write (" <hr class=\"noscreen\" />\n"); document.write (" </div>\n"); document.write (" <div id=\"cols3-bottom\"></div>\n"); document.write (" <!-- /Columns End Here -->\n\n\n"); i++; j=0; } } document.close(); } </script> </head> <body> <div style="width:960px; margin:0 auto;"> <form name="myform" method="get" action=""> <textarea label="Image Names:"name="images" cols="30" rows="15" onclick="this.value=''" ></textarea> <p> <label> <input type="button" name="calculate" value="Calculate" onClick="calc(this.form)"/> </label> </p> </form> </div> </body> </html> As a homework assignment, we are being asked to generate a table of images with at least 2 rows and 3 columns from an external javascript function. I've been trying to find some kind of javascript reference for this and I can't. I don't want someone to do it for me, but if I could get a basic example that would be great.
I pulled this code from Google's example section to make markers on a v3 Google Maps API (I have added my own lat/long points and corresponding event listeners, of course, but this is still the spirit of the code):
Code: <script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false"></script> <script type="text/javascript"> var map; function initialize() { var map_center = new google.maps.LatLng(39.2,-84.479381); var store1 = new google.maps.LatLng(39.112456,-84.574779); var store2 = new google.maps.LatLng(39.314153,-84.261379); var store3 = new google.maps.LatLng(39.197099,-84.667579); var store4 = new google.maps.LatLng(39.16836,-84.479381); var myOptions = { zoom: 10, center: map_center, mapTypeId: google.maps.MapTypeId.ROADMAP } map = new google.maps.Map(document.getElementById("map_canvas"), myOptions); var marker1 = new google.maps.Marker({ position: store1, map: map, title:"Store 1" }); var marker2 = new google.maps.Marker({ position: store2, map: map, title:"Store 2" }); var marker3 = new google.maps.Marker({ position: store3, map: map, title:"Store 3" }); var marker4 = new google.maps.Marker({ position: store4, map: map, title:"Store 4" }); google.maps.event.addListener(marker1, 'click', function() { map.set_center(store1); map.set_zoom(16); }); google.maps.event.addListener(marker2, 'click', function() { map.set_center(store2); map.set_zoom(16); }); google.maps.event.addListener(marker3, 'click', function() { map.set_center(store3); map.set_zoom(16); }); google.maps.event.addListener(marker4, 'click', function() { map.set_center(store4); map.set_zoom(16); }); } </script> This works without fail, but when I try to use a javascript array to hold my values and loop my way through the marker creation like so: Code: <script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false"></script> <script type="text/javascript"> var map; function initialize() { var map_center = new google.maps.LatLng(39.2,-84.479381); var store_locations = new Array(); var temporary_stuff = new Array(); store_locations[0] = "39.112456,-84.574779"; store_locations[1] = "39.314153,-84.261379"; store_locations[2] = "39.197099,-84.667579"; store_locations[3] = "39.16836,-84.479381"; var myOptions = { zoom: 10, center: map_center, mapTypeId: google.maps.MapTypeId.ROADMAP } map = new google.maps.Map(document.getElementById("map_canvas"), myOptions); for(i=0;i<store_locations.length;i++){ var marker_string = "position: "+new google.maps.LatLng(store_locations[i])+", map: map, title:\"Store "+(i+1)+"\";"; temporary_stuff[i] = new google.maps.Marker(marker_string); } var markers = new Array(); for(i=0;i<temporary_stuff.length;i++){ var the_marker = "position: temporary_stuff[" + i + "], map: map, title:\"Store " + (i+1) + "\";"; markers[i]= new google.maps.Marker(the_marker); } } </script> I get a blank map. Here's a link to the test file: http://rowsdower.freehostia.com/map_test.php It's not throwing up any errors in Firefox's developer or in IE but there it sits, a blank map. I'm sure this isn't clean or optimized code, but it looks correct to me. I've color-coded the code above to show what "for" loops are being used to try to replace which code. Hopefully that makes this more sensible. I haven't even tried to add the listeners yet since I can't get the markers to appear. Can anyone tell me why this isn't working or point me in a more productive direction? Is there a better way already out there that I haven't noticed? I am trying to learn about the trace tables and truth tables in Javascript for the booleans. But I cannot seem to pick up the things. Does anyone know of a good resource where I can learn more? Thanks in advance for any useful help with this. How can I build a table that prompts user for number of rows and then number of columns and then builds it based on user input?
Hi Guys, I am posting this to see if anyone has any ideas or sample code that has worked in the past. What i am aiming at doing is having two tables, with the same amount of rows side by side, effectively rendering them the same. I wish then to select a row on the one table, and this event would trigger the same row on the 2nd table to be selected too. Has anyone done something like this before? Appreciate any feedback! Thanks. Hi folks, i am trying to generate a dynamic datefield with date mask "mm/dd/yyyy" and trying to insert it into Oracle db ...i still got the error ORA invalid month ehich means the date filed is not recognized as date: below is what i am doing : newStartDate = document.createElement( 'INPUT' ); newStartDate.setAttribute('type','Date'); newStartDate.setAttribute('id1','id'+ elementid+elementrow); newStartDate.setAttribute('name','StartDateName'+ elementid+elementrow); newStartDate.size=8; newStartDate.style.backgroundColor= bgc; any help thanks ?? Also i want to add a datepicke to this textbox..how it is posible / other option is to use Jquery datepicker but could not know how to impement it thanks again Hi, I have three tables and I want show one table at one time. At the bottom of one table I need to have "next" and "previous" links to go other two tables.Can you please help me. Thank You. Hi there, Not sure what sub category this falls under sorry, but I have an issue changing a table based menu to a css based menu. This has been done however the javascript code no only partly works, I would like for it to completely work and am not sure whether I should use aspanel or <div> tags to get it to work as I have tried both and neather seem to work so there is something i am obviously missing! here is the javascript: Code: $(function() { $('#mainCategories a').live('click', function() { $.ajax({ type: "GET", contentType: "text/html; charset=utf-8", dataType: "html", url: "/ajax/menu.aspx?CategoryId=" + this.name, cache: false, success: function(newMenu) { $("#left-menu-control").replaceWith(newMenu); $('html, body').animate({ scrollTop: 0 }, 'slow'); } }); return false; }); $('#left-menu-collapse-category').live('click', function() { $.ajax({ type: "GET", contentType: "text/html; charset=utf-8", dataType: "html", url: "/ajax/menu.aspx", cache: false, success: function(newMenu) { $("#left-menu-control").replaceWith(newMenu); } }); return false; }); }); and here is the page code: Code: <div id="menu-left"> <asp:Panel ID="pnlLeftMenuControl" runat="server"> <asp:Panel ID="pnlCategories" runat="server"> <asp:Panel ID="pnlCurrentlyViewing1" runat="server" Visible="false"> <div id="menu-left-main-categories"> <div id="menu-left-currently-viewing-title">Currently Viewing...</div> <div id="menu-left-currently-viewing-close"><a href="javascript:void(0);" title="Collapse category" id="left-menu-collapse-category"><img src="~/images/button-menu-left-currently-viewing-close.jpg" runat="server" border="0" /></a></div> </div> </asp:Panel> <asp:Panel ID="pnlCurrentlyViewing2" runat="server" Visible="false"> <div id="menu-left-currently-viewing"> <div id="menu-left-currently-viewing-text"><asp:Hyperlink ID="hlCategory" runat="server" CssClass="left-menu-viewing"></asp:Hyperlink></div> </div> </asp:Panel> <asp:Panel ID="pnlSubCategories1" runat="server" Visible="false"> <asp:Repeater ID="rptSubCategories" runat="Server"> <ItemTemplate> <div id="menu-left-currently-viewing"> <div id="menu-left-currently-viewing-text">- <asp:HyperLink ID="hlSubCategory" runat="server" CssClass="left-menu-viewing"></asp:HyperLink></div> </div> </ItemTemplate> </asp:Repeater> </asp:Panel> <asp:Panel ID="pnlMainCategories" runat="server"> <asp:Repeater ID="rptMainCategories" runat="server"> <ItemTemplate> <div id="menu-left-main-categories"><div id="menu-left-main-categories-text"><asp:HyperLink ID="hlCategory" runat="server" CssClass="left-menu"></asp:HyperLink></div></div> </ItemTemplate> </asp:Repeater> </asp:Panel> </asp:Panel> <asp:Panel ID="pnlBrands" runat="server" Visible="false"> <asp:Panel ID="pnlBCurrentlyViewing1" runat="server" Visible="false"> Currently viewing... </asp:Panel> <asp:Panel ID="pnlBCurrentlyViewing2" runat="server" Visible="false"> <asp:Label ID="lblBCurrentlyViewing" runat="server" CssClass="left-menu-viewing"></asp:Label> </asp:Panel> <asp:Repeater ID="rptBrands" runat="server"> <ItemTemplate> <asp:HyperLink ID="hlBrand" runat="server" CssClass="left-menu"></asp:HyperLink> </ItemTemplate> </asp:Repeater> </asp:Panel> </asp:Panel> </div> any help would be greatly appreciated Not really sure why this isn't working. I've mirrored this webpage from a friend's page - everything is literally identical, save for the references to the databases. His works, and mine doesn't. Here's an example of one of the tables I'm trying to sort: http://www.iblhoops.net/iblv2archive...isplay=ratings The code in question for said table: Code: // BEGIN RATINGS TABLE $table_ratings="<table class=\"sortable\"> <thead> <tr bgcolor=$color1><th><font color=$color2>Pos</font></th><th><font color=$color2>Player</font></th><th><font color=$color2>Age</font></th><th><font color=$color2>Sta</font></th><th><font color=$color2>2ga</font></th><th><font color=$color2>2g%</font></th><th><font color=$color2>fta</font></th><th><font color=$color2>ft%</font></th><th><font color=$color2>3ga</font></th><th><font color=$color2>3g%</font></th><th><font color=$color2>orb</font></th><th><font color=$color2>drb</font></th><th><font color=$color2>ast</font></th><th><font color=$color2>stl</font></th><th><font color=$color2>tvr</font></th><th><font color=$color2>blk</font></th><th><font color=$color2>o-o</font></th><th><font color=$color2>d-o</font></th><th><font color=$color2>p-o</font></th><th><font color=$color2>t-o</font></th><th><font color=$color2>o-d</font></th><th><font color=$color2>d-d</font></th><th><font color=$color2>p-d</font></th><th><font color=$color2>t-d</font></th><th><font color=$color2>Foul</font></th><th><font color=$color2>Inj</font></th></tr> </thead> <tbody> "; $i=0; while ($i < $num) { if ($yr == "") { $name=mysql_result($result,$i,"name"); $team=mysql_result($result,$i,"teamname"); $pid=mysql_result($result,$i,"pid"); $pos=mysql_result($result,$i,"altpos"); $p_ord=mysql_result($result,$i,"ordinal"); $age=mysql_result($result,$i,"age"); $inj=mysql_result($result,$i,"injured"); $r_2ga=mysql_result($result,$i,"r_fga"); $r_2gp=mysql_result($result,$i,"r_fgp"); $r_fta=mysql_result($result,$i,"r_fta"); $r_ftp=mysql_result($result,$i,"r_ftp"); $r_3ga=mysql_result($result,$i,"r_tga"); $r_3gp=mysql_result($result,$i,"r_tgp"); $r_orb=mysql_result($result,$i,"r_orb"); $r_drb=mysql_result($result,$i,"r_drb"); $r_ast=mysql_result($result,$i,"r_ast"); $r_stl=mysql_result($result,$i,"r_stl"); $r_blk=mysql_result($result,$i,"r_blk"); $r_tvr=mysql_result($result,$i,"r_to"); $r_sta=mysql_result($result,$i,"sta"); $r_foul=mysql_result($result,$i,"r_foul"); $r_totoff=mysql_result($result,$i,"oo")+mysql_result($result,$i,"do")+mysql_result($result,$i,"po")+mysql_result($result,$i,"to"); $r_totdef=mysql_result($result,$i,"od")+mysql_result($result,$i,"dd")+mysql_result($result,$i,"pd")+mysql_result($result,$i,"td"); $r_oo=mysql_result($result,$i,"oo"); $r_do=mysql_result($result,$i,"do"); $r_po=mysql_result($result,$i,"po"); $r_to=mysql_result($result,$i,"to"); $r_od=mysql_result($result,$i,"od"); $r_dd=mysql_result($result,$i,"dd"); $r_pd=mysql_result($result,$i,"pd"); $r_td=mysql_result($result,$i,"td"); $r_bird=mysql_result($result,$i,"bird"); $draftyear=mysql_result($result,$i,"draftyear"); $exp=mysql_result($result,$i,"exp"); $cy=mysql_result($result,$i,"cy"); $cyt=mysql_result($result,$i,"cyt"); $yearoffreeagency=$draftyear+$exp+$cyt-$cy; } else { $name=mysql_result($result,$i,"name"); $team=mysql_result($result,$i,"team"); $pid=mysql_result($result,$i,"pid"); $r_2ga=mysql_result($result,$i,"r_2ga"); $r_2gp=mysql_result($result,$i,"r_2gp"); $r_fta=mysql_result($result,$i,"r_fta"); $r_ftp=mysql_result($result,$i,"r_ftp"); $r_3ga=mysql_result($result,$i,"r_3ga"); $r_3gp=mysql_result($result,$i,"r_3gp"); $r_orb=mysql_result($result,$i,"r_orb"); $r_drb=mysql_result($result,$i,"r_drb"); $r_ast=mysql_result($result,$i,"r_ast"); $r_stl=mysql_result($result,$i,"r_stl"); $r_blk=mysql_result($result,$i,"r_blk"); $r_tvr=mysql_result($result,$i,"r_tvr"); $r_totoff=mysql_result($result,$i,"r_oo")+mysql_result($result,$i,"r_do")+mysql_result($result,$i,"r_po")+mysql_result($result,$i,"r_to"); $r_totdef=mysql_result($result,$i,"r_od")+mysql_result($result,$i,"r_dd")+mysql_result($result,$i,"r_pd")+mysql_result($result,$i,"r_td"); $r_oo=mysql_result($result,$i,"r_oo"); $r_do=mysql_result($result,$i,"r_do"); $r_po=mysql_result($result,$i,"r_po"); $r_to=mysql_result($result,$i,"r_to"); $r_od=mysql_result($result,$i,"r_od"); $r_dd=mysql_result($result,$i,"r_dd"); $r_pd=mysql_result($result,$i,"r_pd"); $r_td=mysql_result($result,$i,"r_td"); } if(($i % 2)==0) { $bgcolor="FFFFFF"; }else{ $bgcolor="EEEEEE"; } if ($tid == 0) { $table_ratings=$table_ratings." <tr bgcolor=$bgcolor><td>$pos</td><td><a href=\"http://www.iblhoops.net/modules.php?name=Player&pa=showpage&pid=$pid\">$name</a></td><td>$age</td><td>$r_sta</td><td>$r_2ga</td><td>$r_2gp</td><td>$r_fta</td><td>$r_ftp</td><td>$r_3ga</td><td>$r_3gp</td><td>$r_orb</td><td>$r_drb</td><td>$r_ast</td><td>$r_stl</td><td>$r_tvr</td><td>$r_blk</td><td>$r_oo</td><td>$r_do</td><td>$r_po</td><td>$r_to</td><td>$r_od</td><td>$r_dd</td><td>$r_pd</td><td>$r_td</td><td>$r_foul</td><td>$inj</td></tr> "; } else { if ($p_ord > 959) { $table_ratings=$table_ratings." <tr bgcolor=$bgcolor><td>$pos</td><td>(<a href=\"http://www.iblhoops.net/modules.php?name=Player&pa=showpage&pid=$pid\">$name)*</a></td><td>$age</td><td>$r_sta</td><td>$r_2ga</td><td>$r_2gp</td><td>$r_fta</td><td>$r_ftp</td><td>$r_3ga</td><td>$r_3gp</td><td>$r_orb</td><td>$r_drb</td><td>$r_ast</td><td>$r_stl</td><td>$r_tvr</td><td>$r_blk</td><td>$r_oo</td><td>$r_do</td><td>$r_po</td><td>$r_to</td><td>$r_od</td><td>$r_dd</td><td>$r_pd</td><td>$r_td</td><td>$r_foul</td><td>$inj</td></tr> "; } elseif ($r_bird == 0) { $table_ratings=$table_ratings." <tr bgcolor=$bgcolor><td>$pos</td><td><i><a href=\"http://www.iblhoops.net/modules.php?name=Player&pa=showpage&pid=$pid\">$name</i></a></td><td>$age</td><td>$r_sta</td><td>$r_2ga</td><td>$r_2gp</td><td>$r_fta</td><td>$r_ftp</td><td>$r_3ga</td><td>$r_3gp</td><td>$r_orb</td><td>$r_drb</td><td>$r_ast</td><td>$r_stl</td><td>$r_tvr</td><td>$r_blk</td><td>$r_oo</td><td>$r_do</td><td>$r_po</td><td>$r_to</td><td>$r_od</td><td>$r_dd</td><td>$r_pd</td><td>$r_td</td><td>$r_foul</td><td>$inj</td></tr> "; } else if ($fayr == "" OR $yearoffreeagency == $fayr) { $table_ratings=$table_ratings." <tr bgcolor=$bgcolor><td>$pos</td><td><a href=\"http://www.iblhoops.net/modules.php?name=Player&pa=showpage&pid=$pid\">$name</a></td><td>$age</td><td>$r_sta</td><td>$r_2ga</td><td>$r_2gp</td><td>$r_fta</td><td>$r_ftp</td><td>$r_3ga</td><td>$r_3gp</td><td>$r_orb</td><td>$r_drb</td><td>$r_ast</td><td>$r_stl</td><td>$r_tvr</td><td>$r_blk</td><td>$r_oo</td><td>$r_do</td><td>$r_po</td><td>$r_to</td><td>$r_od</td><td>$r_dd</td><td>$r_pd</td><td>$r_td</td><td>$r_foul</td><td>$inj</td></tr> "; } } $i++; } $table_ratings=$table_ratings." </tbody> </table> "; if ($tid != 0) { $table_totals=$table_totals." <table class=\"sortable\"> <thead> <tr bgcolor=$color1><th><font color=$color2>Pos</font></th><td colspan=3><font color=$color2>Player</font></th><th><font color=$color2>g</font></th><th><font color=$color2>gs</font></th><th><font color=$color2>min</font></th><th><font color=$color2>fgm</font></th><th><font color=$color2>fga</font></th><th><font color=$color2>ftm</font></th><th><font color=$color2>fta</font></th><th><font color=$color2>3gm</font></th><th><font color=$color2>3ga</font></th><th><font color=$color2>orb</font></th><th><font color=$color2>reb</font></th><th><font color=$color2>ast</font></th><th><font color=$color2>stl</font></th><th><font color=$color2>to</font></th><th><font color=$color2>blk</font></th><th><font color=$color2>pf</font></th><th><font color=$color2>pts</font></th></tr> </thead> <tbody> "; To clarify, when I say "sort", I mean being able to click on the header of a column within the table, and having that sort the entire table by that column. It works fine on my friend's website (and this is a duplicate of his, with only the database references changed)...For what it's worth, he does have a sorttable.js located in a "jslib" folder on the main portion of the site, but not in the directory that this file is in. Yet his sorting works perfectly. I should link to a working example of what I'm wanting to have: http://www.ijbl.net/modules.php?name...isplay=ratings I am building a search function for a sermon blog on squarespace. The format url for category search is www.mysite.org/blog?category=... I have drop down menus and a datepicker but need to figure out how to get java to build the url and redirect to it. The output url should look like http://www.mysite.org/sermons?catego...+mybook+mydate. Any help would be greatly appreciated. Here is my java so far. Code: function search() { var myRootSite = 'www.mysite.org/sermons?category='; var myNewTitle = document.getElementById('myTextField').value; var mySpeaker = document.getElementById('mySpeaker').value; var myService = document.getElementById('myService').value; var mySeries = document.getElementById('mySeries').value; var myBook = document.getElementById('myBook').value; var myDate = document.getElementById('myDate').value; if (myNewTitle == 0 && mySpeaker == 0 && myService == 0 && mySeries == 0 && myBook == 0 && myDate == 0) { alert('Please enter some search criteria'); return; } var title = document.getElementById('title'); title.innerHTML = mySpeaker; } Hi, I am developing a html ordering system that does not use a database but sends the data via email. To differentiate between two orders I would like to generate and add an unique identifier to the email. One approach I have seen is using data object to generate an unique id: Code: function uniqid() { var newDate = new Date; return newDate.getTime(); } This is not guaranteed to be unique as two people can send their request at the exact same time. One question pops up, the data being generated, is this local or utc time? Also, the number being generated in this situation is quite big and not so easy to differentiate two orders for a human. Ideally I would like to generate a global sequence starting at 1 and incrementing by one for each user that clicks on the order button regardless of timing, timezone etc. Is this possible given the constraints given at the start of the post? Any suggestions are welcome. Hi, I am trying to develop a quiz system.Here is a simplified version of my code with lots of modifications made mainly for easier comprehension. Code: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <html lang="en"> <head> <script type="text/javascript"> var count=3; var questions = new Array(3); for (var i = 1; i <=count; i++) { questions[i] = "Question "+String(i); } </script> <script type="text/javascript"> /* Global "swap" holder Use value, null, if no layer initially visible */ var currlayerId = "question1"; function toglayer(id) { if(currlayerId) setDisplay(currlayerId, "none"); if(id)setDisplay(id, "block"); currlayerId = id; } function setDisplay(id,value) { var elm = document.getElementById(id); elm.style.display = value; } </script> <style type="text/css" media="screen, print, projection"> .text { display:none; } </style> </head> <body> <li><a href="#" onclick="toglayer('question1');return false;">Q.1</a></li> <li><a href="#" onclick="toglayer('question2');return false;">Q.2</a></li> <li><a href="#" onclick="toglayer('question3');return false;">Q.3</a></li> <div id="question1" class="text"> <script>document.write(questions[1]);</script> <br> </div> <div id="question2" class="text"> <script>document.write(questions[2]);</script> </div> <div id="question3" class="text"> <script>document.write(questions[3]);</script> </div> <script>toglayer('question1');</script> </body> </html> When you will run the code,you will find three links Q.1 Q.2 Q.3 These links are basically due to the following code Code: <li><a href="#" onclick="toglayer('question1');return false;">Q.1</a></li> <li><a href="#" onclick="toglayer('question2');return false;">Q.2</a></li> <li><a href="#" onclick="toglayer('question3');return false;">Q.3</a></li> When you click on any of the links,you will see the question associated with it.This is because of the following code Code: <div id="question1" class="text"> <script>document.write(questions[1]);</script> <br> </div> <div id="question2" class="text"> <script>document.write(questions[2]);</script> </div> <div id="question3" class="text"> <script>document.write(questions[3]);</script> </div> -------------------------------------------------------------------------------------- Now,here's the question,how do I put the div layers and their links in a loop.That is,I want it to be something like this Code: (for var i=1;i<=count;i++) { <li><a href="#" onclick="toglayer('question[i]');return false;">Q.[i]</a></li> } Code: (for var i=1;i<=count;i++) { <div id="question[i]" class="text"> <script>document.write(questions[i]);</script> <br> </div> } The reason why I ask this is,is because the number of questions in the quiz depends on the value of the javascript variable "count".Therefore,if the value of count is 5,the number of questions would be 5,if it is 6 the number of questions will be 6,etc. Thanks Hemant |