JavaScript - Displaying Javascript Result In Column
using a javascript function to determine if a string is all digits or not and return result based off the decision. if it is all digits, mask all digits except the first two, if not all digits just return the string.
these are the snippets however i am not seeing anything returned in the column Code: <script > var start = function RenderRC(CodeOwner) { var Rcode = CodeOwner.toString(); var pattern = new RegExp("^\d{2,}$ "); if (Rcode.match(pattern)) { if (Rcode.length > 2) { var newcode = Rcode.substr(0, 2) + Array(Rcode.length - 2 + 1).join("*"); return newcode; } } else { return Rcode; } }; </script> <ext:RecordField Name="CodeOwner" /> <ext:Column Header="<%$ Resources:Text, CodeOwner %>"DataIndex="CodeOwner" Width="110" > <Renderer Fn ="start" /> </ext:Column> Similar Tutorialsthank you
Good Day, I am very new to JavaScript and I am working on an assignment that is almost finished, but I have a problem getting the result to work. When I enter the two values and then hit submit, nothing is returned. I am guessing that either my code is incorrect or I have used the wrong ids maybe. Basically, the user enters 2 parameters (hourly wage and hours worked) and the first function turns the parameters into the gross pay (depends on if the hours are standard pay or if overtime is involved). The second function takes the gross pay and does the tax amounts for local, state and federal. Then it adds all taxes to give a total of tax amount paid. The input for the parameters is done by <input> tag. The return reslut is supposed to be just the number which is the total amount of taxes to be taken out. This all has to be done by <input> tags. Could someone look over the html and JS and help me find where the problem is at. The instructor said we could use ? : operator for determining the pay rates, but I found it easier to do if/else staements because I was not sure how you would script that. Any help would be great. Thanks HTML Code Code: <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <title>Calculate Tax Amount</title> <link href="style.css" rel="stylesheet" type="text/css"> <script type="text/javascript" src="calculateGross.js"></script> <script type="text/javascript" src="calculateTax.js"></script> </head> <body> <table width="60%" border="0" cellpadding="0" cellspacing="2" align="center" class="view"> <tr> <td colspan="3" class="textview">Calculate the gross pay:</td> </tr> <tr> <td class="labeltext">Pay rate(dollars per hour)</td> <td>:</td> <td><input type="text" name="payrate" id="payrate" class="textval"></td> </tr> <tr> <td class="labeltext">Hours worked</td> <td>:</td> <td><input type="text" name="hours" id="hours" class="textval"></td> </tr> <tr> <td colspan="3" align="center"><input type="button" name="" value="Submit" onclick="return calculate(); "> </td> </tr> </table> <br> <br> <table width="60%" border="0" cellpadding="0" cellspacing="2" align="center" class="view"> <tr> <td colspan="3" class="textview">Total Tax Paid:</td> <tr> </tr> <td class="labeltext">Grand Total of Taxes</td> <td>:</td> <td><input type="text" name="total" id="totalTax" class="textval" disabled="disabled"></td> </tr> </table> </body> </html> First Function JS Code: function calculate() { var payRate = document.getElementById("payrate").value; var hoursWorked = document.getElementById("hours").value; var oTime; var oPay; var oHour; var grossPay; if(hoursWorked > 40) { oTime = Number ( hoursWorked ) - 40; oPay = Number ( ( payRate ) * 1.5 ) * oTime; oHour = Number ( hoursWorked )- Number ( oTime ); grossPay = Number ( payRate ) * Number ( oHour ) + Number ( oPay ); } else grossPay = Number ( hoursWorked ) * Number ( payRate ); } The second function JS Code: function calculateTax(gross) { var gross; var localTax; var localTaxBal; var stateTax; var stateTaxBal; var fedTax; var fedTaxBal; var totalTax; localTax = Number ( gross ) * 2/100; localTaxBal = Number ( gross ) - Number ( localTax ); stateTax = Number ( localTaxBal ) * 8/100; stateTaxBal = Number ( localTaxBal ) - Number ( stateTax ); fedTax = Number ( stateTaxBal ) * 31/100; fedTaxBal = Number ( stateTaxBal ) - Number ( FedTax ); totalTax = Number ( localTax.toFixed(2) ) + Number ( stateTax.toFixed(2) ) + Number ( fedTax.toFixed(2) ); return totalTax.toFixed(2); } I run a website for a skittle league and am looking to create a form to allow teams to sumbit results on line. I'm not an expert on Javascript, the code I've created so far allows the user to enter the player name and score for one team and calcutate the total. However, I'm having problems duplicating this for a second team, and would like to remove the Get Total button (i.e. Auto Calculate total). Can anyone advise how I can do this. The Code I have so far is <html> <head> <script type="text/javascript" language="javascript"> function getTotalH1(oForm) { var field, i = 0, total = 0, els = oForm.elements; var fieldnames = ['PSH1' , 'PSH2' , 'PSH3' , 'PSH4' , 'PSH5']; for (i; i < fieldnames.length; ++i) { field = els[fieldnames[i]]; if (field.value != '' && isNaN(field.value)) { alert('Please enter a valid number here.') field.focus(); field.select(); return ''; } else total += Number(field.value); } return ' ' + total; } </script> </head> <body> <form> <div align="center"><table border="0" cellpadding="2" cellspacing="0" width="305"> <col width="250" align="left"> <col width="42" align="center"> <tr> <td><input type="text" name="PNH1" size="35"> </td> <td><input id="PSH1" type="text" name="PSH1" value="" size="4"></td> </tr> <tr> <td><input type="text" name="PNH2" size="35"></td> <td><input id="PSH2" type="text" name="PSH2" value="" size="4"></td> </tr> <tr> <td><input type="text" name="PNH3" size="35"></td> <td><input id="PSH3" type="text" name="PSH3" value="" size="4"></td> </tr> <tr> <td><input type="text" name="PNH4" size="35"></td> <td><input id="PSH4" type="text" name="PSH4" value="" size="4"></td> </tr> <tr> <td><input type="text" name="PNH5" size="35"></td> <td><input id="PSH5" type="text" name="PSH5" value="" size="4"></td> </tr> <tr> <td><input type="button" value="Get Total" onclick="total.value=getTotalH1(this.form)" /> <input type="reset" /></td> <td><input id="total" type="text" name="totalh1" value="" readonly="readonly" size="4"></td> </tr> </table></div> <br><br> </form> </body> </html> thanks Hi guys, I have a simple calculator on my website which has a few options selectable by radio buttons. When the user adds selections - the total price of their order is automatically calculated and displayed in a <div> for them to see. The client then can deselect options or add according to their budget. The code which deals with this is as follows (just sections of it but you get the point ....) In the <HEAD> Code: <script type = "text/javascript"> var allprices = []; var index = 0; function chkrads(frmName,rbGroupName) { var chosen = ""; var radios = document[frmName].elements[rbGroupName]; for (var i=0; i <radios.length; i++) { if (radios[i].checked) { chosen = radios[i].value; } } if (chosen == 0) {printprice = 0} if (chosen == 1) {printprice = 99} if (chosen == 2) {printprice = 150} if (chosen == 3) {printprice = 250} if (chosen == 21) {printprice = 200} if (chosen == 22) {printprice = 300} if (chosen == 30) {printprice = 50} if (chosen == 41) {printprice = 50} if (chosen == 42) {printprice = 70} if (chosen == 43) {printprice = 90} if (rbGroupName == "size") {index = 0} if (rbGroupName == "colour") {index = 1} if (rbGroupName == "frame") {index = 2} if (rbGroupName == "glass") {index = 3} if (rbGroupName == "hook") {index = 4} if (rbGroupName == "delivery") {index = 5} allprices[index] = printprice; var totalprice = 0; for (var i =0; i <allprices.length; i++) { if (!isNaN(allprices[i])) { totalprice = totalprice + allprices[i]; } } document.getElementById("result").style.display = "block"; document.getElementById("result").innerHTML = totalprice; } </script> Then in the <BODY> Code: <form name= "myform" style="font-size:11px; font-family:Arial, Helvetica, sans-serif;"> <input type = "radio" name = "size" value = "0" onclick = "chkrads('myform', 'size')"> <b>0</b> <input type = "radio" name = "size" value = "1" onclick = "chkrads('myform', 'size')"> <b>1</b> <input type = "radio" name = "size" value = "2" onclick = "chkrads('myform', 'size')"> <b>2</b> <input type = "radio" name = "size" value = "3" onclick = "chkrads('myform', 'size')"> <b>3</b> <br /><br /><br /><br /> <input type = "radio" name = "colour" value = "0" onclick = "chkrads('myform', 'colour')"><b>No</b> <input type = "radio" name = "colour" value = "21" onclick = "chkrads('myform', 'colour')"><b>black</b> <input type = "radio" name = "colour" value = "22" onclick = "chkrads('myform', 'colour')"><b>Multi Colour</b> <br /><br /><br /><br /> <input type = "radio" name = "frame" value = "0" onclick = "chkrads('myform', 'logo')"><b>No</b> <input type = "radio" name = "frame" value = "30" onclick = "chkrads('myform', 'logo')"><b>Yes</b> <br /><br /><br /><br /> <input type = "radio" name = "glass" value = "0" onclick = "chkrads('myform', 'glass')"><b>No</b> <input type = "radio" name = "glass" value = "51" onclick = "chkrads('myform', 'glass')"><b>Yes</b> <br /><br /><br /><br /> <input type = "radio" name = "hook" value = "0" onclick = "chkrads('myform', 'hook')"><b>0</b> <input type = "radio" name = "hook" value = "41" onclick = "chkrads('myform', 'hook')"><b>1</b> <input type = "radio" name = "hook" value = "42" onclick = "chkrads('myform', 'hook')"><b>2</b> <input type = "radio" name = "hook" value = "43" onclick = "chkrads('myform', 'hook')"><b>3</b> <br /><br /><br /><br /> <input type = "radio" name = "delivery" value = "0" onclick = "chkrads('myform', 'delivery')"><b>No</b> <input type = "radio" name = "delivery" value = "61" onclick = "chkrads('myform', 'delivery')"><b>Yes</b> </form> This all calculates the cost and then supplies the answer into this code: Code: <div id="result" style="display:none;"><strong></strong> <span id="totalprice"></span> </div> This all works exactly as I want - my question is this .... I have added an HTML contact form at the bottom of the page which goes off to a Form2Email PHP script. (All working fine) I really want to autofill one of the sections of this form "QUOTED PRICE" with the value calculated by my earlier product calculator. The form looks like so: Code: <form id="ContactForm" method="post" action="FormToEmail.php" class="input2"> <label>Name: <input name="name" type="text" id="name" value="" size="" maxlength="80" class="input"/></label> <br /><br /> <label>QUOTED PRICE: <input name="QUOTED PRICE" type="text" id="QUOTED PRICE" value="" size="" maxlength="80" class="input"/></label> <br /><br /> <label> <input type="submit" class="submit" name="submit" id="submit" value="submit"/> </label> </form> Does anyone know how to achieve this?! It would be a massive help! I cannot figure out how to total my column data correctly with JavaScript. The code I have will enter a new row, but it is not summing the columns. The new row is just filled with zeros. Code: function totalColumns() { var tds = document.getElementById('users_table').getElementsByTagName('td'); var sum = 0; for(var i = 0; i < tds.length; i ++) { if(tds[i].className == 'dataRow') { sum += isNaN(tds[i].innerHTML) ? 0 : parseInt(tds[i].innerHTML); } } document.getElementById('users_table').innerHTML += '<tr><td>' + sum + '</td><td>' +sum+ '</td><td>' +sum + '</td></tr>'; alert ("Columns have been totalled and listed at the bottom of each"); } //end totalColumns I can't figure out how to get the rows to total at all. Any insight would be appreciated! Thanks! Below, I added: bmiresult to my database but I get the error: There has been an error: could not prepare statement (1 table bmical has no column named bmiresult) Code: html5rocks.webdb.createTable = function() { var db = html5rocks.webdb.db; db.transaction(function(tx) { tx.executeSql("CREATE TABLE IF NOT EXISTS bmical(ID INTEGER PRIMARY KEY ASC, height1 INTEGER, weight1 INTEGER, added_on DATETIME, bmiresult INTEGER)", []); }); } html5rocks.webdb.addTodo = function(todoText) { var db = html5rocks.webdb.db; db.transaction(function(tx){ var weight1 = document.getElementById("weight1").value; var height2 = todoText / 100 var BMI = weight1 / (height2 * height2) var BMI = BMI; var bmiresult = BMI.toFixed(3); var addedOn = new Date(); tx.executeSql("INSERT INTO bmical(height1, weight1, added_on, bmiresult) VALUES (?,?,?,?)", [todoText, weight1, addedOn, bmiresult], html5rocks.webdb.onSuccess, html5rocks.webdb.onError); }); } please help me~~Hi I have to create a table using javascript. Firefox displays the expected result but for IE, the column width is screwed >"< I have to use the col tag to set width because sometimes the first row maybe merged. All I need is to create a table that strictly displays according to the inputted column widths from my program. In below I have setup very short example that construct table in a similar way to my original javascript function. I also draw a ruler to help showing the proper width of 400px on the screen. column 1 should be 100px width and column 2 should be 300px. Please help me~~T_T Code: <?xml version='1.0' encoding='UTF-8'?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"> <body onload="init()"> Hard Coded: <DIV style="WIDTH: 400px; HEIGHT: 25px;overflow:hidden;"> <TABLE style="border:none; BORDER-SPACING: 0px; WIDTH: 400px; TABLE-LAYOUT: fixed" cellSpacing="0" cellpadding="0"> <col width="100px"> <col width="300px"> <TBODY> <TR> <TD style="background-color:blue"> a </TD> <TD style="background-color:green"> b </TD> </TR> </TBODY> </TABLE> </DIV> Ruler: <div id='ruler' style="background-color:yellow;width:400px;height:28px;"></div> Javascript inserted: <div id="hi"> </div> </body> <script language="javascript"> function init() { var w = [100, 300] // test table create var testDiv, testTBody, testTable, testTr, testTd, testCol; document.getElementById("hi").appendChild(testDiv = document.createElement("div")); with (testDiv.style) { width="400px"; height="25px"; } testDiv.appendChild(testTable = document.createElement("table")); with (testTable) { style.tableLayout="fixed"; style.borderSpacing="0px"; style.width = "400px"; appendChild(testCol = document.createElement("col")); testCol.style.width = 100 + 'px'; appendChild(testCol = document.createElement("col")); //testCol.style.width = 300 + 'px'; appendChild(testTBody = document.createElement("tbody")); cellSpacing= 0 } testTBody.appendChild(testTr = document.createElement("tr")); with (testTr){ } for (var i= 0; i < 2; i++) { testTr.appendChild(testTd = document.createElement("td")); testTd.innerHTML = "Testing"; with (testTd) { style.borderTop = "1px solid lightgray"; style.borderLeft="1px solid lightgray"; style.borderRight="1px solid black"; style.borderBottom="1px solid black"; } } } </script> </html> I am one problem. When i click a link a some information in html is to be displayed on the screen. I have written code for that. But before i click the link i am able to display the content. Please look into my code and give some suggestions: <html> <head> </head> <body> <center> <table> <tr> <td> <a href="javascript:Chg1()">Add Required (Features)</a> </td> <td> <a href="javascript:chg2()">Add via Search</a> </td> <td> <a href="javascript:Chg3()">Add via List</a> </td> </tr> </table> </center> function chg2() { document.write(<b> Type Model Feature Relationship Search and Add </b>);s <table> <tr> <td> Type<input type="text" id="type" name="type" value=""> </td> <td> Document Number<input type="text" id="doc" name="doc" value=""> </td> </tr> <tr> <td> Model<input type="text" id="model" name="model" value=""> </td> <td> Promoted<input type="text" id="promoted" name="promoted" value=""> </td> </tr> <tr> <td> Feature<input type="text" id="feature" name="feature" value=""> </td> </tr> </table> } </script> </body> Hi guys, I already posted this but it hasn't been approved by a mod or the mods are all at lunch or something lol. I want to display an image using javascript instead of HTML (or use javascript to change the HTML code dynamically when an update is made). I have created an XML file, which contains text data which is displayed in HTML by using Javascript. What I am having trouble with is getting Javascript to grab the image URL from the XML file, and then display that image in the correct div. How does one show an image by using javascript? and how do you get javascript to get the url from the XML? The following is my Javascript code which grabs the text from the XML and displays it in the HTML; Code: <script type="text/javascript"> var xmlDoc; <!-- if (window.XMLHttpRequest) { xhttp=new XMLHttpRequest(); } else // Internet Explorer 5/6 { xhttp=new ActiveXObject("Microsoft.XMLHTTP"); } xhttp.open("GET","SDS.xml",false); xhttp.send(""); xmlDoc=xhttp.responseXML; var x=xmlDoc.getElementsByTagName("NEWS"); i=0; function display() { title=(x[i].getElementsByTagName("TITLE")[0].childNodes[0].nodeValue.fontsize("5").fontcolor("white").bold()); date=(x[i].getElementsByTagName("DATE")[0].childNodes[0].nodeValue.fontsize("2").fontcolor("white").bold()); stitle=(x[i].getElementsByTagName("STITLE")[0].childNodes[0].nodeValue.fontsize("3").fontcolor("white").italics()); story=(x[i].getElementsByTagName("STORY")[0].childNodes[0].nodeValue.fontsize("3").fontcolor("white")); txt= title + "<br />" + date + "<br />" + stitle + "<br />" + story; document.getElementById("show").innerHTML=txt; } //--> </script> And this is the XML file; Code: <?xml version="1.0" encoding="ISO-8859-1"?> <BULLETIN> <NEWS> <PIC>"newssmall.jpg"</PIC> <DATE>14/3/2010</DATE> <TITLE>News Story 1</TITLE> <STITLE>This is a short sentence to describe the story in brief</STITLE> <STORY>This is the text of the news story</STORY> </NEWS> </BULLETIN> So what I want to do is create a function that grabs the url (relative) from the PIC tag in the XML ("newssmall.jpg") and then uses this URL to display the image on the HTML page. This way, only the XML needs updating when updating the news section of the site. Thanks for helping if you can, Dan Im coding a chat system, but the main thing which I cannot get working which is stopping me from doing this is displaying the data from the database. I have made a test XML document for the time being so that I can get the JavaScript/AJAX working properly, then I will figure out why my PHP isnt generating the XML file properly. Here is my XML document: Code: <?xml version="1.0" ?> <root> <message id="0"> <sender>martynball</sender> <receiver>someoneelse</receiver> <time>154375342</time> <text>Testing an XML document and seeing if the JavaScript will display it properly. If so then there is a problem with the PHP.</text> </message> </root> And here is my JavaScript/AJAX, for some reason there is NOTHING being displayed in the div which has the correct ID. Code: <script type="text/javascript"> function getXmlHttpRequestObject() { if (window.XMLHttpRequest) { // code for IE7+, Firefox, Chrome, Opera, Safari return new XMLHttpRequest(); } if (window.ActiveXObject) { // code for IE6, IE5 return new ActiveXObject("Microsoft.XMLHTTP"); } return null; } //Make variables for later use var lastMess = 0; var sendReq = getXmlHttpRequestObject(); var receiveReq = getXmlHttpRequestObject(); var mTimer; function getMessage() { if (receiveReq.readyState == 4 || receiveReq.readyState == 0) { //var url = "scripts/get_data.php?uid=<?=$_SESSION['uid']?>&m=" + lastMess + "&chat=1"; var url = "testXMLdoc.xml"; receiveReq.open("GET", url, true); receiveReq.onreadystatechange = manageMessage; receiveReq.send(null); lastMess++; } } function manageMessage() { if (receiveReq.readyState == 4) { var xmldoc = receiveReq.responseText; var chat_div = document.getElementById('chat'); var msg_nodes = xmldoc.getElementByTagName("message"); var n_msg = message_nodes.length; for (i = 0; i < n_msg; i++) { var sender_node = msg_node[i].getElementByTagName["sender"]; var receiver_node = msg_node[i].getElementByTagName["receiver"]; var time_node = msg_node[i].getElementByTagName["time"]; var text_node = msg_node[i].getElementByTagName["text"]; chat_div.innerHTML = "He <br />" + sender_node[0].firstChild.nodeValue + "<br />"; chat_div.innerHTML = reciever_node[0].firstChild.nodeValue + "<br />"; chat_div.innerHTML =time_node[0].firstChild.nodeValue + "<br />"; chat_div.innerHTML = text_node[0].firstChild.nodeValue + "<br />"; } } } </script> Also, I put a alert under the manageMessage() function before the IF statement and that gets displayed. I have to display a div before firing a sync ajax in javascript div is getting displayed in firefox but not in IE and chrome. I need to basically display a download bar to indicate the user that the request is in progress I'm working with greasymonkey scripts. Firefox JS console would always display GM script errors, but all of the sudden it stopped doing that. Script just won't load and no errors are displayed. I didn't touch any settings, yesterday they were showing fine, today none are displayed. Would appreciate any help.
Howdy all. I have Win 7, IE9. I have a HTML file on my hard drive, with Javascript within. When I load the page, it keeps popping up Do u want to allow this content, I have to click to allow. I want to stop this, and after doing some searching I found the setting in Internet Options, Advanced - "Allow active content to run in files on my computer". Perfect. Doesnt work. When i check this box, the page loads without the warning, but then the Javascript just doesnt work. Getting quite annoying, because this file is my home page. Any help would be great! I'm very new at JavaScript and I'm trying to get each of the if statements below in a text text box with the result depending on the answer of the equation. However i can't figure out a way to allow the user to click a button to to show the result in a text box. If anyone could help it would be much appreciated. Code: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <HTML> <HEAD> <TITLE> New Document </TITLE> <script type="text/javascript"> function calculate() { A = document.form1.text2.value B =(parseInt(A ) * 52) D= (parseInt(B ) * 0.015 ) if ( B <= 6000){ tax = 0;} else if (B <= 37001){ tax = (B - 6000) * .15; } else if (B<= 80001){ tax = (B - 37000) * .30 + (37000 - 6000) * .15; } else if (B <= 180001){ tax = (B- 80000) * .37 + (80000- 37000) * .30 + (37000 - 6000) * .15; } else tax = (B - 180000)* .45 + (180000 - 80000 begin_of_the_skype_highlighting**************180000 - 80000******end_of_the_skype_highlighting) * .37 + (80000- 37000) * .30 + (37000 - 6000) * .15;} </script> </HEAD> <BODY> <form name="form1"> Weekly Salary: <INPUT TYPE="TEXT" NAME="text2"> <INPUT TYPE="BUTTON" VALUE="SUBMIT" Onclick="calculate();"> </BODY> </HTML> I am currently using the JavaScript Light Box found on; http://www.huddletogether.com/projects/lightbox2/ I was wondering if it is possible, or easy enough to create something alike the one found on; http://www.whsmith.co.uk/Support/Hel...ffiliates.aspx when you click on; > How to become an affiliate > Complete the OMGuk.com affiliate application form. Many Thanks, Tim Hi all, I want to display varying company information from a javascript array randomly each time the page is refreshed. My problem is that the each piece of company information must be split up into 3-4 array elements since I have set up spans in the body where the information go accordingly and as such I don't how to randomize that. The relevant code is (I will only give two company examples as it's a long list): Code: <script type="text/javascript" language='javascript'> function compInfo(comp){ var companyInfo = new Array(); if(comp == document.getElementById('test').innerHTML) { //insert business name here. companyInfo[0] = 'Test'; //insert business type here. companyInfo[1] = 'Media'; //insert street name here. companyInfo[2] = 'Test Road.'; //insert actual opening time here. companyInfo[3] = '5am - 10pm'; //insert actual closing time here. companyInfo[4] = 'Christmas'; //insert contact info here. companyInfo[5] = 'test'; //insert web address here. companyInfo[6] = '<a href="http://www.test.com" style="color: #0092DD; text-decoration: none;">test.com</a>'; //insert image link here. companyInfo[7] = 'images/test.jpg'; } if(comp == document.getElementById('test1').innerHTML) { //insert business name here. companyInfo [0] = 'Test1'; //insert business type here. companyInfo [1] = 'Club'; //insert street name here. companyInfo[2] = 'Test1 Road.'; //insert actual opening time here. companyInfo[3] = '5am - 10pm'; //insert actual closing time here. companyInfo[4] = 'Christmas'; //insert contact info here. companyInfo[5] = 'test1'; //insert web address here. companyInfo[6] = '<a href="http://www.test1.com" style="color: #0092DD; text-decoration: none;">test1.com</a>'; //insert image link here. companyInfo[7] = 'images/test1.jpg'; } document.getElementById('title').innerHTML =companyInfo[0]; document.getElementById('name').innerHTML = companyInfo[1]; document.getElementById('street').innerHTML = companyInfo[2]; document.getElementById('open').innerHTML = 'Open'; document.getElementById('otime').innerHTML = companyInfo[3]; document.getElementById('close').innerHTML = 'Closed' document.getElementById('ctime').innerHTML = companyInfo[4]; document.getElementById('contact').innerHTML = 'Contact'; document.getElementById('cinfo').innerHTML = companyInfo[5]; document.getElementById('web').innerHTML = companyInfo[6]; document.getElementById('image').style.display = 'block'; document.getElementById('image').src = companyInfo[7]; } </script> </head> <body> <SPAN ID='test' onclick="compInfo(document.getElementById('test').innerHTML);"><b>Test</b></SPAN> <SPAN ID='test1' onclick="compInfo(document.getElementById('test1').innerHTML);"><b>Test1</b></SPAN> //info shown he <div style='text-overflow: ellipsis;'> <table cellpadding='0' cellspacing='0' border='0' style='height:178px; width:185px;'> <tr> <td align="left" style='height:25px;'> <b><SPAN ID='title' ></SPAN></b> </td> </tr> <tr> <td align="left" > <SPAN ID='name' ></SPAN> <br /> <SPAN ID='street'></SPAN> <div style='height:8px;'> </div> <SPAN ID='open'></SPAN> <br /> <SPAN ID='otime'></SPAN> <br /> <SPAN ID='close'></SPAN> <br /> <SPAN ID='ctime'></SPAN> <br /> <div style='height:8px;'> </div> <SPAN ID='contact'></SPAN> <br /> <SPAN ID='cinfo'></SPAN> <SPAN ID='web'></SPAN> <img ID='image' style='display:none;'></img> </td> </tr> </table> </div> </body> So essentially the process is: 1. The person clicks on the company name. 2. Relevant information from the array is shown in the div. But what I want is that on startup, information about a random company is shown automatically. How can I achieve this? Thanks. Box 1 - Box 2 / Box 3 and i put a round off number so the decimals dont give a million numbers the problem is...the math is wrong now.... someone please help me fix this.. <!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>Calc</title> <script type="text/javascript"> function calculate() { var one = document.getElementById("one").value*1; var two = document.getElementById("two").value*1; var three = document.getElementById("three").value*1; document.getElementById("answer").value=((one-two)/three); ; } </script> </head> <body> Enter Number 1 <br> <br><input type="text" id="one" /><hr>Enter Number 2<br><br><input type="text" id="two" /><br><br><hr>Enter Average number<br><br><input type="text" id="three" /><br><br><button onclick="calculate();">Calculate</button> <br id="result"></center></br> Total <input type="text" readonly="readonly" id="answer" /><br><br></center> </body> </html> </td> </tr> </table> </center> </body> </html> Hi, I'm using javascript in addition to a web service (BTBuckets) to display different content to visitors based on actions they take on my site. The javascript is working fine, but I noticed that if I simulate BTBuckets being disabled using Firefox Adblock none of the content shows up. So in the off chance of the service going offline it'll leave some pretty funky holes in the my content. I tried <noscript> tags which works with javascript off, but the content is still blank when I disable BTBuckets. I'm wondering if there's a way to display the default content if the service is unavailable? Here's the code I'm using: In the head: Code: <script type="text/javascript"> //<![CDATA[[ $BTB={s:XXXXX}; $BTB.jsh="http://static.btbuckets.com/bt.js"; //]]> </script> <script type="text/javascript"> document.write(unescape("%3Cscript src='" + $BTB.jsh.replace(/(https?:)/i,document.location.protocol) + "' type='text/javascript'%3E%3C/script%3E")); </script> The code in the body used to replace an image depending on visitor behavior: Code: <script type="text/javascript"> var _t = ""; if ($BTB.clusters["ppc_visitors"]) { _t = "\"images/top-photo-tracking-number.jpg\" alt=\"Call Toll-Free: 1-800-XXX-XXXX\">"; } else { _t = "\"images/top-photo.jpg\" alt=\"Call Toll-Free: 1-800-XXX-XXXX\">"; } document.write('<img src= ' + _t ); </script> <noscript><img src="images/top-photo.jpg" alt="Call Toll-Free: 1-800-XXX-XXXX"></noscript> I typed this code straight out of the book and it just doesn't seem to work. I have the headlines on the left side and when clicked the contents of the headline is supposed to show up in the text box on the right. Well, needless to say, nothing appears. Please someone tell me what I am doing wrong. I am not the only person in the class having this issue. Thanks a million. Code: <!DOCTYPE HTML> <!--mwelborn--> <!--Chapter 8 Page 475--> <!--October 25, 2011 --> <html> <head> <title>News Items</title> <script type="text/javascript"> /* <![CDATA[ */ var newsItem1 = "L'AQUILA, ITALY (AP) - L'Aquila's chief prosecutor announced an investigation into allegations of shoddy construction as people sill missing after a devastating earthquake five days ago. http://in.reuters. com/article/ idUSWBT01103020090411; var newsItem2 = "WASHINGTON (Reuters) - President Barack Obama said on Friday the recession- hit US economy was showing 'glimmers of hope' despite remaining under strain and promised further steps in coming weeks to tackle the financial crisis. http://in.reuters.com/article. idUSWBT01103020090411"; var newsItem3 = "(eweek.com) - Apple is close to hitting 1 billion downloads from its App Store and plans on a prize giveaway fo whoever downloads the billionth application that includes a MacBook Pro and an iPod Touch. http://www.eweek.com/c/a/ Application-Development/eWeek-Newsbreak -April-13-2009/"; var newsItem4 = "ATLANTA (AP) - Chipper Jones drove in two runs, including a tiebreaking single, and the Atlanta Braves beat Washington 8-5 on Sunday to hand the Nationals their sixth straight loss to start the season. http://www.newsvine.com/_news/2009/04/11 2667835-jones-braves-beat-winless -nationals-8-5?category=sports"; /* ]] */ </script> </head> <body> <form name="newsHeadlines" action="" method="get"> <table style="border: 0; width: 100%"> <tr valign="top"> <td> <select name="newsHeadlines" multiple="multiple" style="height: 93px"> <option onclick="document.newsHeadlines .news.value=newsItem1"> Investigation of building standards in quake zone</option> <option onclick="document.newsHeadlines .news.value=newsItem2"> Obama sees signs of economic progress</option> <option onclick="document.newsHeadlines .news.value=newsItem3"> Apple App Downloads Approach 1 Billion</option> <option onclick="document.newsHeadlines .news.value=newsItem4"> Jones, Baves beat winless Nationals 8-5</option> </select> </td> <td> <textarea name="newsHeadlines" cols="50" rows="10" style="background-color: Transparent"></textarea> </td> </tr> </table> </form> </body> </html> Ahoy, Lemme try to explain this as best as I can. Bullet points might help: When someone clicks on an image here (http://gta.kwivia.co.uk/gta-iv/), the rest of the images collapse and become invisible Below the image, some links appear Also, there will be a "show other images" button which will then show the rest of the images http://gta.kwivia.co.uk/gta-iv/ I will appreciate all solutions to this problem. If you need to know anything, simply ask me. |