1,330 Posted Topics
Re: nJS, What an interesting problem. My solution is about as efficient as I can make it. The sieve function is 9 (well packed) lines of code, including its function wrapper. Everything else is user interface or comments. [CODE] <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html> <head> <title>Airshow :: … | |
Re: It's hard to help without seeing your existing code. [B]Airshow[/B] | |
Re: Mapper, You can avoid the need for the toggle flag by testing whether class name "toggled" is set or not. This makes life much easier. Also, in jQuery you can address many elements with one statement by giving them all the same class. Here I assume the class name "myTogglingClass", … | |
Re: Soomro_moon, A Date object can made in the following ways: [CODE]var d = new Date();//Now var d = new Date(milliseconds);//milliseconds since 1st Jan 1970 var d = new Date(dateString);//eg. ("November 23, 1995 10:30:00") var d = new Date(year, month, day, hours, minutes, seconds, milliseconds);[/CODE] So, assuming that the value in … | |
Re: I tried Dreamweaver years ago and it drove me nuts, same as all the other code-cutters. It's probably improved but I still have this really bad memory. If, like me, you like to cut your own code all of the time, then you will do a lot worse than to … | |
Re: There's no point trying to return result from the outer function. It returns BEFORE the AJAX success funtion. Reason ... AJAX is ASYNCHRONOUS! You need to do whatever you need to do with result in the inner function(data){...}. [CODE] function name_free(value, element){ //validation rule if($('input[name="name"]').val() != value) { $.post(CI.base_url + … | |
Re: Infame, How is the function called/attached? [B]Airshow[/B] | |
Re: It doesn't behave as the documentation says it should. Both sample date formats "yyyyMMdd" and "yyyyMMMdd" give "undefined". Try adding the following lines to function FormatDate : [CODE] else if (this.Format.toUpperCase()=="YYYYMMDD") return (this.Year+DateSeparator+(this.Month+1)+DateSeparator+pDate); [/CODE] [B]Airshow[/B] | |
Re: New Order, In document head: [CODE=javascript] <script type="text/javascript"> function swapImage(imgID, src){ var img = document.getElementById(imgID) || document.all[imgID] || document[imgID] || null; if(img) { img.src = src; img.alt = src;//for testing } }; </script> [/CODE] Then compose each link as follows: [CODE=HTML] <li><a href="#" onMouseOver="swapImage('dadfadsfasdf','Answers_14.gif'); ">What does the Bronze membership include?</a></li> … | |
Re: Andrew, Very nearly. Assuming the HTML to be part of a php print or echo statement: [CODE] '<div class="update' . $item_id . '">'; [/CODE] And assuming the javascript not to be part of a php print or echo statement: [CODE] $(document).ready(function(){ $('.update<?php echo $item_id; ?>').hide(); [/CODE] [B]Airshow[/B] | |
Re: It's a dual question of variable "scope" and runtime asychronicity. [B]Variable Scope[/B] y in your statement [ICODE]y = 1;[/ICODE] is in a different scope from the y in [ICODE]alert(y);[/ICODE]. To ensure that both y's are the same y, declare it with [ICODE]var y;[/ICODE] in the global namespace (ie not inside … | |
Re: Ello, The PHP doesn't actually output anything, and what you want to be output isn't JSON encoded. Try: [CODE=php] <?php if($_GET['act'] == "char_con") { echo '<div id="dark_ad"><img src="img/data/under_ad.png" alt="Click here to begin"></div><div id="con_sep"></div>'; } else { echo '<a href="index.php?act=gen_con"><img src="img/vpbg/vpbgt.png" alt="Click here to begin"></a>'; } ?> [/CODE] and [CODE=javascript] $(document).ready(function(){ … | |
Re: You need to pass to calcTotal a reference to the select menu that has been changed: [CODE=HTML] <select name="field1" class="qty" onchange="calcTotal(this);"> [/CODE] Then, calcTotal will be something like: [CODE=javascript] function calcTotal(menu){ var total = 0; for(var i=0; i<menu.length; i++) { total += Number(menu[i].value); } alert(total);//or whatever you want to do … | |
Re: Number.toFixed(n) rounds a number to n decimal places. Try [ICODE]Number($pence.value).toFixed(2)[/ICODE]. [B]Airshow[/B] | |
Re: Samsambm, Can you post an example of the page as served, post PHP processing. [B]Airshow[/B] | |
Re: Probelm is that the second instance overwrites the first because the same variable/function names are used. You can fix it yourself by making all the variable/function names unique, though this is only a "band-aid" solution. The script you have found looks pretty outdated by today's javascript coding standards. For a … | |
Re: Speer25, You should be able to do what you want in javascript without needing to use AJAX to go back to the server for a simple calculation. Even if the eventual algorithm is more complex, javascript should be able to handle it. The code will simplify as follows (untested): [CODE] … | |
Re: Sounds like you want to become a [URL="http://community.screen-scraper.com/index.html"]screen-scraper[/URL]. (Other products also exist). [B]Airshow[/B] | |
Re: [QUOTE=brynFlew;1449876]I was wondering if it is possible to restrict the values of a text input box to only accept set values such as "XBC1". I am trying to make a form for a scanner so you can scan bar codes and it will auto fill the form out and have … | |
Re: Javascript's [ICODE]form.submit()[/ICODE] initiates traditional html form submission unconditionally. If your forms have [ICODE]onsubmit[/ICODE] handlers, they will not be called when forms are submitted in this way. Added to that, browser behaviour is not standardised should a second html form submission be ordered before the first has taken effect. Therefore it's … | |
Re: Nbogatin, Your HTML page must have just one <body>...</body> containing all the HTML including the <form>...</form> tags. Blocks of HTML can't each have their own body, but they can be wrapped in <div>s or <table>s. With just one body, fillCategory will be called just once. You need to work out … | |
| |
Re: k2k, The two calls to GetXmlHttpObject() will each cause an independent request objets to be returned and they should both work quite happily. The only proviso is that if the two response handlers both affect the same js objects or the same areas of the DOM, then you [I]could[/I] get … | |
Re: This is a shot in the dark .... Try remembering the jQuery object to which the tabs are first applied: [CODE] var $tabs = $("#tabs"); $tabs.tabs({ collapsible: true, cache: true, ajaxOptions: { error: function(xhr, status, index, anchor) { $(anchor.hash).html("Couldn't load this tab. We'll try to fix this as soon as … | |
Re: [QUOTE=eefh01;1447160]The db is updating perfectly when I disable JS on firefox.[/QUOTE] Is this just an FF issue? Are other browsers OK? [B]Airshow[/B] | |
Re: Johnathan, Cookie handling is a bunch of rather tedious string handling, so it's best to let some ready-made cookie class handle all that, freeing you to invoke some simple methods. Here's a demo: [CODE] <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html> <head> <title>Airshow :: Untitled</title> <style type="text/css"> {} … | |
Re: At the risk of revealing my gross ignorance about struts, here's my best guess ... Struts will forward either to a unique URL or to a more general URL with some query string in the path to indicate the required action. If the page is unique (action [U]is not[/U] determined … | |
Re: Mbarandao, Something like this maybe: [CODE]<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html> <head> <title>Airshow :: Untitled</title> <script> onload = function(){ var foreName = document.myForm.foreName; var familyName = document.myForm.familyName; var initials = document.myForm.initials; function makeInitials(){ initials.value = foreName.value.charAt(0) + familyName.value.charAt(0); } foreName.onkeyup = familyName.onkeyup = makeInitials;//This fires makeInitials as … | |
Re: Kkjay, You need to be careful with [ICODE]window.location.hash[/ICODE] and [ICODE]anchor.location.hash[/ICODE]. Some js engines include the leading [ICODE]#[/ICODE] symbol in the returned string, and some don't. This makes any solution slightly ugly, but not necessarily any more lines that you already have. Try this: [CODE=javascript] //replace // var selected = window.location.hash … | |
Re: It's difficult to see how the title and question relate to each other. | |
Re: Adam_C, I have a theory on this issue. I reckon that all the major browsers can in theory handle multiple, simultaneous AJAX requests but the different javascript engines compete for motherboard resources in different ways to make multiple requests fail in some cases. If I recall correctly, I answered a … | |
Re: Localp, It would help to see the code that opens the child window. Could you post it please. [B]Airshow[/B] | |
Re: You need to suppress renumbering after deleting a row. For row[1]+ renumbering of the previous row has already happened. Unnecessary, though no error thrown. For row[0] an error will be thrown because [ICODE]i--[/ICODE] gives table.rows[-1] - illegal index. [CODE] ... else{ table.rows[i].cells[1].childNodes[0].nodeValue=i+1; } ... [/CODE] [B]Airshow[/B] | |
Re: Public-image, If I understand correctly, you want [ICODE]window.open('alert_update.php?id=<? echo"$alertm[id]"; ?>', 'alert');[/ICODE] to open an invisible child window, which will exist solely to handle the alert_update.php request (and its response). You can do it this way but the code would be substancially different - chiefly in that a window opened with … | |
Re: If you hide "back" there's no point hiding "alertzy" as well. When "back" is hidden, all its contents will be hidden too. You can formulate the hider function like this: [CODE] function hidethis(element) { element.style.visibility = "hidden"; } [/CODE] and call it like this to hide "back": [CODE] <a href="#" … | |
Re: Raul8, You may already know this but [ICODE]false[/ICODE] in [ICODE]xhttp.open("GET","details.xml",false);[/ICODE] means that you are trying to handle the response synchronously, which will not work in most browsers (IIRC, only IE will handle synchronous requests). I'm not exactly experienced at handling XML in javascript but here's my best guesses .... 1. … | |
Re: Waniejjang, There's several ways to do this. I'll give you the HTML and javascript. You will need to write the php. 1. [B]Custom HTML Attributes[/B] [CODE=html] <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html> <head> <title>Airshow :: Untitled</title> <style type="text/css"> {} </style> <script> function showEmail(s){//s is the select element … | |
Re: As far as I can see, there's nothing unusual in the javascript. I guess one of three things is happening. In each case, you can't fix it but you can politely advise the user of why things aren't working. 1. [B]Javascript not included or disabled in the user's device[/B] [B]Solution[/B]: … | |
Re: MOrteza, Try this: [CODE] function removeDuplicateOptions(s, comparitor) { if(s.tagName.toUpperCase() !== 'SELECT') { return false; } var c, i, o=s.options, sorter={}; if(!comparitor || typeof comparitor !== 'function') { comparitor = function(o) { return o.value; };//by default we comare option values. } for(i=0; i<o.length; i++) { c = comparitor(o[i]); if(sorter[c]) { s.removeChild(o[i]); … | |
Re: Moonknight, [CODE=html] <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html> <head> <title></title> </head> <script type="text/javascript"> onload = function(){ var wolfLinksContainer = document.getElementById("wolfLinksContainer"); var wolfLinks = wolfLinksContainer.getElementsByTagName("a"); var placeHolder = document.getElementById("placeholder"); placeHolder.style.height = "400px"; for(var i=0; i<wolfLinks.length; i++) { wolfLinks[i].onclick = function() { placeHolder.src = this.href; return false; }; } … | |
Re: Try this: [CODE=javascript] function outputSelected(f) { var inputs = f.getElementsByTagName('input'); var sel = []; for (var i=0; i<inputs.length; i++) { if(inputs[i].name !== 'mail') { continue; } if (inputs[i].checked) { sel.push(inputs[i].value); } } emailStr = sel.join(";"); subject = "TEST"; body_message = "This is a test message"; var mailto_link = 'mailto:' + … | |
Re: I've never needed to do it but you probably need to get into "[URL="http://www.adobe.com/devnet/acrobat/javascript.html"]JavaScript for Acrobat[/URL]". [B]Airshow[/B] | |
Re: Try this: [CODE=JavaScript] <script> function toggleTable(link) { var reasonTable = document.getElementById("reasonTable"); if(reasonTable.style.display == "none") { reasonTable.style.display = "block"; link.innerHTML = "Hide Table"; } else { reasonTable.style.display = "none"; link.innerHTML = "Show Table"; } return false;//important } </script> [/CODE] [CODE=HTML] <form id="MyForm" method="post" name="MyForm"> <table id="reasonTable" style="display:none;" width="612" cellpadding="0" cellspacing="0" align="center"> … | |
Re: Umesh, Cookies are small text files containing a set of concatenated strings each comprising a name=value pair, and delimited with a ";" (semicolon). A cookie is simply retreived by javascript as document.cookie. If no cookie has been set, then document.cookie is "" (empty string). [CODE] function getCookie(c_name)//function which will return … | |
Re: Hussainiat, It's so simple you will kick yourself. Remember that javascript is delivered as text, just like HTML, so you can write it with php echo or print statemets as if you were typing it yourself at the keyboard. [CODE] <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html> <head> … | |
Re: Kardklub, You have to go through the pain barrier of getting your mind round the "relational model", ie. the way related data gets stored in the records of two or more database tables, which are associated with each other by "foreign keys" (integers) which point to "primary keys", thus implementing … | |
Re: Hard to say. I can't find the documentation for the plugin. The domain name "carnovsky.net" seems to have disappeared. At least, my ISP's DNS server doesn't know of it. Do you know of an alternative URL for the [B]callout[/B] documentation? [B]Airshow[/B] | |
Re: Nathan, The code should work. All you have done is to add user_id=........, which is quite legal (moreover [U]required[/U]) according to the API. I can only think that this is a charset issue. The API makes it clear [URL="http://www.flickr.com/services/api/misc.encoding.html"]here[/URL] that "The Flickr API expects all data to be UTF-8 encoded" … | |
![]() | Re: Hi Ardav, Yes you're spot on, asychronous structure of jquery.post() makes nonsense of returning a value from the anon (success) fn. There's a couple of approaches: 1. You can write the [ICODE]rules...[/ICODE] code (and whatever uses rules) inside the anon fn, like this: [CODE] function checkDBData() {//You may well need … ![]() |
Re: Peter, There's no unique solution. I would handle this with two functions; one in the popup and one in the main window: In Popup: [CODE=javascript] function selectImage(imgURL){ if(confirm('Show ' + imgURL + ' in the main window?')){//optional confirm; delete if not requied opener.displayImage(imgURL); } } [/CODE] In main window: [CODE=javascript] … |
The End.