Jump to content

hacknsack

Members
  • Posts

    183
  • Joined

  • Last visited

Everything posted by hacknsack

  1. Hi vijay, Prismatic,I think what Prismatic is looking for is javascript's "Number()" or "parseInt()". A link reference for Number():http://www.w3schools.com/jsref/jsref_Number.aspparseInt():http://www.w3schools.com/jsref/jsref_parseInt.aspparseFloat():http://www.w3schools.com/jsref/jsref_parseFloat.aspTo my knowledge there is no function that converts the variable, you have to reassign it:<script type="text/javascript">var a = "125.35";alert(a + 3); //a treated as Stringalert(Number(a) + 3);alert(a + 3); //a is still a Stringa = Number(a);alert(a + 3);</script> Thanks,
  2. You have to loop through the radio group to work with each one. <script type="text/javascript"> function checkPets(cfield){ var p = document.forms['f1'].elements['Pet']; if(cfield.checked) { for(var i = 0; i < p.length; i++){ //remove the next line if you don't want them unchecked p[i].checked = false; p[i].disabled = true; } } else { for(var j = 0; j < p.length; j++){ p[j].disabled = false; } } } </script> </head> <body> <form name="f1"> <input type="radio" name="Pet" value="Cat"> Cat <br> <input type="radio" name="Pet" value="Dog"> Dog <br> <input type="radio" name="Pet" value="Snake"> Snake <br> <input type="checkbox" name="c1" onclick="checkPets(this)"> Don't Like Any Pets <b>Especially Snakes</b> </form> Thanks,
  3. This was an interesting project..I could not get the "onblur()" to work correctly(IE6) on the appended boxes, hence the use of <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><html> <head> <meta http-equiv="content-type" content="text/html; charset=windows-1250"> <title></title> <style type="text/css"> .hdr td { text-align: center; } </style> <script type="text/javascript"> var rowArray = new Array('R0','R1','R2','R3'); var colArray = new Array('C0','C1','C2','C3'); var rowSumArrayH = new Array('HSubR0','HSubR1','HSubR2','HSubR3'); var rowSumArrayM = new Array('MSubR0','MSubR1','MSubR2','MSubR3'); var colSumArray = new Array('TC0','TC1','TC2','TC3'); var rowCount = 4; function addRow(){ var x = 0; rowArray.push('R' + rowCount); rowSumArrayH.push('HSubR' + rowCount); rowSumArrayM.push('MSubR' + rowCount); var tbody = document.getElementById("table1").getElementsByTagName("tbody")[0]; var row = document.createElement("TR"); for(var j = 0; j < colArray.length; j++) { var cell=document.createElement("TD"); var inp1=document.createElement("INPUT"); inp1.setAttribute("type","text"); inp1.setAttribute("value",""); inp1.setAttribute("size","1"); inp1.setAttribute("id","R" + rowCount + "C" + x++); cell.appendChild(inp1); row.appendChild(cell); } for(var j = 0; j < 2; j++) { var cell=document.createElement("TD"); var inp1=document.createElement("INPUT"); inp1.setAttribute("type","text"); inp1.setAttribute("value",""); inp1.setAttribute("size","1"); inp1.setAttribute("id", (j==0)? 'HSubR' + rowCount : 'MSubR' + rowCount); cell.appendChild(inp1); row.appendChild(cell); } tbody.appendChild(row); rowCount++; } function ckSumVert(){ var form = document.forms['f1']; var numInput = 0; for(var i = 0; i < colSumArray.length; i++){ var temp = 0; for(var k = 0; k < rowArray.length; k++){ if(numInput = parseInt(document.getElementById( rowArray[k] + colArray[i] ).value)) temp += numInput; } form.elements[colSumArray[i]].value = temp; } ckSumHorz(); } function ckSumHorz(){ var form = document.forms['f1']; var numInput = 0; for(var i = 0; i < rowArray.length; i++){ var tempH = tempM = 0; for(var k = 0; k < colArray.length; k++){ if(numInput = parseInt(document.getElementById( rowArray[i] + colArray[k] ).value)){ (k % 2 == 0)? tempH += numInput : tempM += numInput; } } form.elements[rowSumArrayH[i]].value = tempH; form.elements[rowSumArrayM[i]].value = tempM; } ckTotals(); } function ckTotals(){ var form = document.forms['f1']; var numInput = 0; var tempH = tempM = 0; for(var i = 0; i < rowSumArrayH.length; i++){ if(numInput = parseInt(document.getElementById( rowSumArrayH[i] ).value)) tempH += numInput; if(numInput = parseInt(document.getElementById( rowSumArrayM[i] ).value)) tempM += numInput; } document.getElementById('HTotal').value = tempH; document.getElementById('MTotal').value = tempM; } </script> </head> <body onKeyUp="ckSumVert()"> <form name="f1"> <table id='table1'> <tbody> <tr class='hdr'> <td>H</td> <td>M</td> <td>H</td> <td>M</td> <td>H</td> <td>M</td> </tr> <tr> <td><input type='text' id='R0C0' size='1' /></td> <td><input type='text' id='R0C1' size='1' /></td> <td><input type='text' id='R0C2' size='1' /></td> <td><input type='text' id='R0C3' size='1' /></td> <td><input type='text' id='HSubR0' size='1' /></td> <td><input type='text' id='MSubR0' size='1' /></td> </tr> <tr> <td><input type='text' id='R1C0' size='1' /></td> <td><input type='text' id='R1C1' size='1' /></td> <td><input type='text' id='R1C2' size='1' /></td> <td><input type='text' id='R1C3' size='1' /></td> <td><input type='text' id='HSubR1' size='1' /></td> <td><input type='text' id='MSubR1' size='1' /></td> </tr> <tr> <td><input type='text' id='R2C0' size='1' /></td> <td><input type='text' id='R2C1' size='1' /></td> <td><input type='text' id='R2C2' size='1' /></td> <td><input type='text' id='R2C3' size='1' /></td> <td><input type='text' id='HSubR2' size='1' /></td> <td><input type='text' id='MSubR2' size='1' /></td> </tr> <tr> <td><input type='text' id='R3C0' size='1' /></td> <td><input type='text' id='R3C1' size='1' /></td> <td><input type='text' id='R3C2' size='1' /></td> <td><input type='text' id='R3C3' size='1' /></td> <td><input type='text' id='HSubR3' size='1' /></td> <td><input type='text' id='MSubR3' size='1' /></td> </tr> </tbody> </table> <table> <tbody> <tr> <td><input type='text' id='TC0' size='1' /></td> <td><input type='text' id='TC1' size='1' /></td> <td><input type='text' id='TC2' size='1' /></td> <td><input type='text' id='TC3' size='1' /></td> <td><input type='text' id='HTotal' size='1' /></td> <td><input type='text' id='MTotal' size='1' /></td> </tbody> </table> <input type="button" value="Add Row" onclick="addRow()"> </form> </body></html> If anyone finds a way to make the "onblur()" active(IE6) on the appended boxes I wouldappreciate it very much if you could post the solution.Thanks,
  4. Maybe this will give you better performance in IE.Does not use "setAttribute()", set the className instead. <script type="text/javascript"> function mkDiv(){ var iDiv = document.getElementById('insert_here'); var str = "This is a test, does it work?"; nwDiv = document.createElement('DIV'); nwDiv.className = "highlight"; textNode = document.createTextNode(str) nwDiv.appendChild(textNode); iDiv.appendChild(nwDiv); } window.onload = mkDiv; </script> </head> <body> <div id="insert_here"> </div> Thanks,
  5. You can use the RegExp method "match" to check: <script type="text/javascript"> var testA = 'Someone@onewww.com'; if(testA.match(/@/g) == null || testA.match(/@/g).length != 1 ){ alert('bad string'); } else { alert('good string'); } </script> Thanks,
  6. OK, still don't know what the window widget is so I made my own for the example: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><html> <head> <meta http-equiv="content-type" content="text/html; charset=windows-1250"> <title></title> <script type="text/javascript"> var currentVersion = "1.0"; var xmlhttp; function checkForUpdate(){ //var url = "http://site/updaters/update_v.txt"; var url = 'testvar.txt'; // code for Mozilla, etc. if (window.XMLHttpRequest) { xmlhttp=new XMLHttpRequest(); xmlhttp.onreadystatechange=xmlhttpChange; xmlhttp.open("GET",url,true); xmlhttp.send(null); } // code for IE else if (window.ActiveXObject) { xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); if (xmlhttp) { xmlhttp.onreadystatechange=xmlhttpChange; xmlhttp.open("GET",url,true); xmlhttp.send(); } } } function xmlhttpChange() { // if xmlhttp shows "loaded" if (xmlhttp.readyState==4) { // if "OK" if (xmlhttp.status==200) { if(parseFloat(currentVersion) == parseFloat(xmlhttp.responseText)){ document.getElementById('newUpdate').style.display = 'none'; } } else { alert("Version Request Error-Please Refresh") } } } function wControl(){ this.openURL = function(url, t, a){ window.open(url, t, a); } } widget = new wControl(); function openLink(url){ if(window.widget){ widget.openURL(url); } else{ window.location = url; } } </script> </head> <body onload="checkForUpdate()"> <div id="newUpdate"> <a id="updateLink" href="java script:openLink('testvar.txt');" style="text-decoration: none; display: block;"> New Update<br />Available! </a> </div> </body></html> Recommendation:You could do this with a straight script source like: <script type="text/javascript" src="testvar.txt"></script> Thanks,
  7. I think this page covers everything, as far as the escape, I've read that "escape()"is being depricated so "encodeURI()" might be better for this, included an example of the literal "\" escape, don't know if that is what you require.I tested the "onunload" in IE6 and FF, worked fine. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"><html><head> <title></title><script type="text/javascript">var phrases = new Array('Never say Never','That\'s what I\'m talking about','Don\'t run with scissors');var words = new Array('test', 'data', 'w3schools');var stra = 'O"M"G" T"H"I"S"';var strb = "O'M'G' T'H'I'S'";//this regexp checks for the ' or " in the stringvar re = /('|")/g;alert(encodeURI(stra));alert(escape(stra));//use match here so that the character is remembered//then used in our replacement stringvar m = stra.match(re);str = stra.replace(re,'\\' + RegExp.$1);alert(str);var m = strb.match(re);str = strb.replace(re,'\\' + RegExp.$1);alert(str);function pickSel(){var oSel = document.forms['f1'].elements['s1'];//next line picks active item in selectoSel.selectedIndex = 2;}//this function loops through the phrases as it finds one// in the textarea it increments the variable "occurs"function testPhrase(s){var occurs = 0; for(var i = 0; i < phrases.length; i++){ var re = new RegExp(phrases[i],"i"); if(s.match(re)){ occurs++; } }alert('Matches found: ' + occurs);}// loops thru words array tests value of word textareafunction testWords(s){var occurs = 0; for(var i = 0; i < words.length; i++){ var re = new RegExp(words[i],"i"); if(s.match(re)){ occurs++; } }alert('Matches found: ' + occurs);}window.onunload = function() { alert('test') };</script> </head><body onload="pickSel()"><form name="f1"> <select name="s1"> <option value="">Pick One <option value="1">First Item <option value="2">Second Item </select> <h3>Phrase Text Box:</h3> <textarea name="ta1" rows="3" cols="35" onblur="testPhrase(this.value)">Never say never </textarea> <br /> <!-- COULD BUILD A FUNCTION TO SCROLL THRU THE PHRASES --> <input type="button" value="<<"> <input type="button" value=">>"> <h3>List Some Words:(test, data, w3schools)</h3> <textarea name="ta2" rows="3" cols="35" onblur="testWords(this.value)">test truck car bus data </textarea> <br /></form></body></html> The buttons below the textarea are just there so that you could study whether or notyou might want to let the user scroll thru the phrases.Shout back if you want to make them active.Thanks,
  8. This thread is going to go forever unless you show us the whole page( or at least all of the javascript )..Not being rude, it's just not possible to help you properly without the code Thanks,
  9. You can use the "new Function()" to create a function that is persistant-or-You can use "var name = function(arg){ stuff to do } <script type="text/javascript">var myTest = "Test is OK";var dynFunc = null;function mkFunc(tStr){ if(tStr.indexOf('OK') > -1){ myFunction = new Function("str", "alert(str)"); myFunction('Testing String Has \'OK\''); dynFunc = myFunction; } else { thatFunction = new Function("str", "alert(str)"); thatFunction('Testing does not contain \'OK\''); dynFunc = thatFunction; }}mkFunc(myTest);myTest = "Test without..You Know 'ok'";mkFunc(myTest);dynFunc('Called Again');</script> Thanks,
  10. Gosh Dan,Gonna take you a while to hop the rest of the threads here.Better get you a cup of coffee.
  11. ruegen,We are assuming that your openURL method points to "window.open()" the function that opens a new window(in JavaScript). <script type="text/javascript">function wControl(){this.openURL = function(url, t, a){ window.open(url, t, a); }}widget = new wControl();function openLink(url){if(window.widget){ //closeDesc(); widget.openURL(url);}else{ window.location = url;}}openLink("http://www.w3schools.com","_blank");</script> Here's a link(example) just in case you need it:http://www.w3schools.com/js/tryit.asp?file...s_openallwindowOf course, we have no idea what the "closeDesc()" does.Thanks,
  12. Ok,Well, this was just a test....You have all come through wonderfully!Now you guys can delete all these posts(unneeded).A++ to the Moderators.Shake Hands and come out posting. Thanks,
  13. First, congratulations on your new positions!(Thanks for your time and efforts).I just wanted to mention 3 things(none of which are emergencies by any means).1) Link color or decoration(already seen the thread on this one)2) Noticed that pasting code from 'code' and 'codebox' work differently, code pastedfrom codeboxes contains no formatting.3) Can a 'codebox' button be added to the 'reply' menu.Thanks again,
  14. This is interesting, Jonas recommends using a class name, and I'm going to suggestusing id's for each input. These 2 ideas will cut your page down considerably.If you assign unique id's to each input e.g. R1C1....R8C13 then we can loop thru thedocument.getElementsByTagName() grab the value of the input then fill the totals.Unfortunately, I don't have much time to spend on the project this morning.If another member hasn't provided an example by this evening, I'll build one when I get home from work.Thanks,
  15. shashank, When you add the row with the inputs, are you assigning names to the new inputs?Thanks,
  16. Thanks Skemcin, that is a much better(not just simpler) solution.I didn't think of putting an iframe in the table cell.Appreciate the pointer,
  17. I think this tutorial may help you:http://www.w3schools.com/xml/xml_http.aspTry the example here:http://www.w3schools.com/xml/tryit.asp?fil...lhttprequest_jsQuestions for you:1) Does the above example work for you(In your browser?)2) Are you trying to use my example locally or did you upload it to a server(with the text files)?3) After studying the W3school example above, tell us which parts you don't understand.The XMLHttpRequest only works when you are interacting with a server.Thanks,
  18. You can add an ID to each start input(since it's compiled at the server) and then runthrough the form elements to check for values. <html><head> <title></title><script type="text/javascript">function ckRadio(form, n){var one_checked = false;var group = form.elements[n]; for(var i = 0; i < group.length; i++){ if(group[i].checked){ one_checked = true; } }return one_checked;}function ckForm(){var form = document.forms['f1'];var i = 0; for(var i = 0; i < form.elements.length; i++){ var field = form.elements[i]; var where = field.id; if(field.type == 'text'){ if(field.value.length == 0){ alert('Check entries for ' + where + '...'); return false; } if(!ckRadio(form, form.elements[i + 1].name)){ alert('Check entries for ' + where + '...'); return false; } } }return true;}</script></head><body><form name="f1" onsubmit="return ckForm(this)"><table><td class="td120">Kathy Jones</td><td class="td60"><input type="text" id="Kathy Jones" name=numgrade0 size="3"></td><td class="td30"><input type="radio" name=grade0 value="A">A</td><td class="td30"><input type="radio" name=grade0 value="B">B</td><td class="td30"><input type="radio" name=grade0 value="C">C</td><td class="td30"><input type="radio" name=grade0 value="D">D</td><td class="td30"><input type="radio" name=grade0 value="F">F</td></tr><tr><td class="td120">Margaret Rogers</td><td class="td60"><input type="text" id="Margaret Rogers" name=numgrade1 size="3"></td><td class="td30"><input type="radio" name=grade1 value="A">A</td><td class="td30"><input type="radio" name=grade1 value="B">B</td><td class="td30"><input type="radio" name=grade1 value="C">C</td><td class="td30"><input type="radio" name=grade1 value="D">D</td><td class="td30"><input type="radio" name=grade1 value="F">F</td></tr><tr><td class="td120">Jack Smith</td><td class="td60"><input type="text" id="Jack Smith" name=numgrade2 size="3"></td><td class="td30"><input type="radio" name=grade2 value="A">A</td><td class="td30"><input type="radio" name=grade2 value="B">B</td><td class="td30"><input type="radio" name=grade2 value="C">C</td><td class="td30"><input type="radio" name=grade2 value="D">D</td><td class="td30"><input type="radio" name=grade2 value="F">F</td></tr></table><input type="submit"></form></body></html> Post back if you need help with any changes.Thanks,
  19. kaijim,Sorry to hear about the injury.We hope for a speedy recovery.Thanks for your work here!
  20. This example uses an xml request to fill a table cell.Create 4 text (.txt) files RAM, Hard Disk, CDROM and Mouse that contain your info,save them to the same directory as the following page.When you mouseover the device name the definition will be retreived and placed in a cell. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN""http://www.w3.org/TR/html4/loose.dtd"><html><head> <title>W3 Schools Definition Fetcher</title><meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"><style type="text/css">.def_list { background-color: #3A73B1; color: #D7356D; }.def_list td{ background-color: #D0DFF0; padding: 8px; }.active_word{ background-color: #D0DFF0; color: #FF8040; padding: 8px; } </style><script type="text/javascript">/** jibbering.com **/var xmlhttp;/*@cc_on @*//*@if (@_jscript_version >= 5) try { xmlhttp=new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) { try { xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); } catch (E) { xmlhttp=false; } }@else xmlhttp=false;@end @*/if (!xmlhttp && typeof XMLHttpRequest!='undefined') { try { xmlhttp = new XMLHttpRequest(); } catch (e) { xmlhttp=false; }}/* *** */var prevCell = null;var tmp = 0;function getDef(device, c){if(!xmlhttp) return;var dispObj = document.getElementById('def');var url = encodeURI(device);if(prevCell) { prevCell.className = ''; } dispObj.innerHTML = 'Fetching Data...'; xmlhttp.open("GET", url, true); xmlhttp.setRequestHeader("If-Modified-Since", "Sat, 1 Jan 2000 00:00:00 GMT"); xmlhttp.setRequestHeader("Content-Type", "text/xml"); xmlhttp.onreadystatechange=function() { if (xmlhttp.readyState==4){ if(xmlhttp.status == 200){ dispObj.innerHTML = xmlhttp.responseText; } else { alert('Try Again..'); return; } } } xmlhttp.send(null);c.className = 'active_word';prevCell = c;}</script> </head><body><table class="def_list"> <tbody> <tr> <td id="def" rowspan="4" width="240"> Mouse Over Device > ><br /> for Definition </td> <td onmouseover="getDef('RAM.txt', this)"> RAM </td> </tr> <tr> <td onmouseover="getDef('Hard Disk.txt', this)"> Hard Disk </td> </tr> <tr> <td onmouseover="getDef('CDROM.txt', this)"> CDROM </td> </tr> <tr> <td onmouseover="getDef('Mouse.txt', this)"> Mouse </td> </tr> </tbody></table> </body></html> Helpful resources:http://developer.mozilla.org/en/docs/AJAX:Getting_Startedhttp://www.onlamp.com/pub/a/onlamp/2005/05...ttprequest.htmlhttp://jibbering.com/2002/4/httprequest.htmlhttp://en.wikipedia.org/wiki/XMLHttpRequest
  21. I voted yes. Count at 13.I don't see much of the admins where do they hang out?
  22. I don't see anything that would make it act up."Bald" links...in your style you took off the decoration is that what you meant to do?Did something a little different with the style, you can use ".menu td" <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"><html><head> <title></title><style>body{font-family:Times New Roman;}table{font-size:80%;}a{color:#435611;text-decoration:none;font:bold}a:hover{color:#435611}table.menu{font-size:100%;position:absolute;visibility:hidden;}.menu td{background:#fdf5ac}</style><script type="text/javascript">function showmenu(elmnt){document.getElementById(elmnt).style.visibility="visible"}function hidemenu(elmnt){document.getElementById(elmnt).style.visibility="hidden"}</script><body><table width="80"><tr bgcolor="#fdf5ac" border="0"> <td onmouseover="showmenu('animals')" onmouseout="hidemenu('animals')"> <a href="http://www.wildfigurines.com/Animal_Figurines.html">Animals</a><br /> <table class="menu" id="animals" width="80"><tr><td><a href="http://www.wildfigurines.com/Animal_Figurines/Cows1.html">Cows</a></td></tr> <tr><td><a href="http://www.wildfigurines.com/Elephant_Figurines.html">Elephants</a></td></tr><tr><td><a href="http://www.wildfigurines.com/Animal_Figurines/Goats1.html">Goats</a></td></tr> <tr><td><a href="http://www.wildfigurines.com/Giraffe_Figurines.html">Giraffes</a></td></tr> <tr><td><a href="http://www.wildfigurines.com/Lion_Figurines.html">Lions</a></td></tr><tr><td><a href="http://www.wildfigurines.com/Animal_Figurines/Llamas1.html">Llamas</a></td></tr> <tr><td><a href="http://www.wildfigurines.com/Moose_Figurines.html">Moose</a></td></tr> <tr><td><a href="http://www.wildfigurines.com/Pig_Figurines.html">Pigs</a></td></tr><tr><td><a href="http://www.wildfigurines.com/Animal_Figurines/Rabbits1.html">Rabbits</a></td></tr><tr><td><a href="http://www.wildfigurines.com/Animal_Figurines/Sheep1.html">Sheep</a></td></tr><tr><td><a href="http://www.wildfigurines.com/Tiger_Figurines.html">Tigers</a></td></tr><tr><td><a href="http://www.wildfigurines.com/Wolf_Figurines.html">Wolves</a></td></tr><tr><td><a href=""></a></td></tr><tr><td><a href=""></a></td></tr><tr><td><a href=""></a></td></tr> </table> </td> </tr></table>test text</body></html> Here's a pretty cool tool that will take the uglies out of your table format..http://www.fixingyourwebsite.com/drhtml.htmlThanks,
  23. Haven't used the ones you mentioned, but I have used PSPAD.http://www.pspad.com/
  24. Glad it was helpful Chocolate570.(Pssst...)Jonas Mail DynamicDrive and tell them to block Chocolate570's ip address before I go insane..ooops too late. :ph34r: And look here Chocolate570, I'm an advanced member now, I say Thanks So Much to you.
  25. hacknsack

    onerror

    What browser are you using?Test results with IE6, FF were..With the "return false":IE6 Displays the error icon lower left corner, homemade alert and regular error alertFF Turns on the alert icon(upper right hand corner)(javascript console records error) Homemade alert displaysWith the "return true":IE6 Displays homemade alert, nothing elseFF Displays the homemade alert, nothing elseSo the return true keeps the user from worrying about the error.Of course your results will depend on your browser's user settings.
×
×
  • Create New...