1,330 Posted Topics
Re: Behseini, I think you can achieve what you want with a combination of [iCODE].slideToggle[/iCODE] and [iCODE].slideUp[/iCODE], without any conditional statements. [CODE] $(document).ready(function(){ $(".login").click(function(){ $(".panel").stop().slideToggle("slow"); $(".panel2").stop().slideUp("slow"); }); $(".register").click(function(){ $(".panel").stop().slideUp("slow"); $(".panel2").stop().slideToggle("slow"); }); });[/CODE] This gives each link a toggle action for its own panel, whilst ensuring that the other panel is hidden. … | |
Re: Muralikalpana I have seen this before. Google maps don't initialise properly in a hidden element. You must ensure that [iCODE]canvas[/iCODE] is showing when [iCODE]new google.maps.Map(canvas, options)[/iCODE] is called. [B]Airshow[/B] | |
Re: Chris, it's always worth asking but Javascript/DHTML/AJAX is probably not the best place. Looking through the Daniweb forum titles, there's not one specifically for server setup/config but would have thought [I]Web Development > Configuring Readymade Scripts[/I] is better than here. [B]Airshow[/B] | |
Re: [QUOTE=TySkby;1594777]Another solution(which would be a bit more advanced) would be to incorporate some Ajax functionality into your existing buttons, so that when they're clicked they make a call to a PHP script that saves the current form data to mysql, and then when it calls back successfully, you go ahead … | |
Re: For completeness ..... HTML's <del>...</del> and <ins>...</ins> are included for use as editorial "laymarks". I have never used either of them. There's also a very old, now deprecated, tag <s>...</s> for strikethrough. Whilst <del> generally results in a single strikethrough, W3C leaves it open as to how <del> (and <ins>) … | |
Re: [QUOTE=dantheman50_98;1593538]... wrapped in its own script tags, and is it directly related to the script beneath it? Can I put these both in their own external js file? [/QUOTE] Yes but they don't logically belong together. The statement [ICODE]$j = jQuery;[/ICODE] belongs with whatever statements use $j. It is more … | |
Re: Apanimesh, You appear not to have a mechanism for propagating the count value from refresh to refresh. You can't maintain the counter on the page, either in the DOM or in javascript, because the whole environment gets wiped out when the page is refreshed. There are two basic ways to … | |
Re: [QUOTE=apanimesh061;1593047]I am sorry ! I could not get meaning of 'focus' mainly in case of Javascript .... Moreover what kind of focus is it talking about ?? I would be glad if you could elaborate.[/QUOTE] Various elements in a browser page (including the page itself) take "focus" when they are … ![]() | |
Re: It's just a question of which events fire on the img element. You may find differences between browsers. [B]Airshow[/B] | |
Re: Tunde, Make sure that cal_current_date is always authoritative. Change its value with eg. .setMonth(), .setDay, .setDate(), .setYear() when next/prev buttons are clicked. Don't rely on other variables. [B]Airshow[/B] | |
Re: Rowly, The error message makes me suspicious that FF doesn't like the javascript: url. I guess you're using : [CODE=html] <a href="javascript:Newitem2(...);">...</a> [/CODE] Whereas I'm not aware of FF having a problem with this construction, you might like to try: [CODE=html] <a href="#" onclick="Newitem2(...);return false;">...</a> [/CODE] Even better, attach your … | |
Re: Grabit, The page has major structural problems. It has several <!DOCTYPE>s, each with its own <html><head>...</head><body>...</body></html> structure. There's also a <tittle> above the first <!DOCTYPE>. Various blocks of markup/javascript/css are repeated in each structure. It looks like the page is pulled together by including a bunch of self-contained web pages … | |
Re: Chompchomp, I can see nothing in your javascript that should cause FF to behave differently from the other browsers. We therefore have to be suspicious that the loaded content might be to blame. I would be inclined to find a solution not involving an iframe if possible. In my experience, … | |
Re: Assuming the php delivers what is expected, try [iCODE]http.responseHTML[/iCODE] instead of [iCODE]http.responseText[/iCODE], ie.: [CODE] results = http.responseHTML.split(","); [/CODE] By the way, you could avoid the cumbersome string-building in php by making $textout an array, pushing the data elements onto it in turn, then echoing [iCODE]implode(",", $textout);[/iCODE]. This avoids the need … | |
Re: I'm a bit in the dark here in that I don't fully understand the nature of the conversion. I'm struggling with the question, "how can I do it in wordpress using slice and split". Wordpress is a PHP application. Javascript runs client-side. Are you seeking to do something server-side that … | |
Re: Jamojo, I don't normally encourage people to use a javascript lib but your problem is fairly difficult in standard javascript and very simple in jquery, as you will see below. I think this is what you want: [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 … | |
Re: Remember to declare local variables (inside functions), otherwise you will create globals: [CODE] function addHead(level){ var html='H'+level; var text=this.toString(); var start="<"+html+">"; var stop="</"+html+">"; return start+text+stop; } [/CODE] Even better, do it in one line; local variables not required: [CODE] function addHead(level){ return "<h%s1>%s2</h%s1>".replace(/%s1/g,level).replace("%s2",this.toString()); } [/CODE] [B]Airshow[/B] | |
Re: ofir, Your code looks like it should work providing jquery is installed on the page. The version below applies zebra stripes only to tables with [iCODE]class="zebraStripes"[/iCODE], and applies the [iCODE]:odd[/iCODE] selector more efficiently. [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> <style type="text/css"> .paint { background-color: … | |
Re: In general, the following are equivalent in javascript: [LIST] [*]object.x.y.z [*]object['x']['y']['z'] [/LIST] Your two statements may or may not both select the same document node. I think the first version is more likely to be successful, not because of its syntax but because it addresses the collection [ICODE]document.forms[/ICODE]. [ICODE]document.myForm...[/ICODE] may … | |
Re: Your two nested loops both iterate from 0-10; ie. 11 iterations. For 10 rows/columns, either iterate from 0-9 or 1-10. [B]Airshow[/B] | |
Re: Tellalca, [iCODE]String.search[/iCODE] expects its argument to be a regular expression. Try [iCODE]String.indexOf[/iCODE] instead, with arguments ("@") and (".") as you were trying. [B]Airshow[/B] | |
Re: Notepad++ has an "as-you-type" auto-indent feature. It doesn't convert previously written code (at least not without lots of manual interaction, which is tantamount to doing it yourself). I've not used it but understand that Eclipse's auto-indent tends to be well liked but may offer nothing more that Notepad++. [B]Airshow[/B] | |
Re: I expect you find that "Duck Sauce" and "No Sleep" are OK but the others are not? If I'm right then it's to do with editplayer()'s arguments, ie. the ids generated by [iCODE]foreach ($temp as $id)[/iCODE]. [CODE=javascript] editPlaylist(6); //ok, argument is a number editPlaylist(R); //will generate a javascript error unless … | |
Re: Yes, exactly so. The if clause is a "safety wrapper" to ensure the method is called only if it exists. [B]Airshow[/B] | |
Re: I can only think that you have to reattach the onclick handler to the td after calling transformNode. [B]Airshow[/B] | |
Re: aPPmaSTer, [iCODE]mySelectMenu.value[/iCODE] is not universally understood. Use the longwinded [iCODE]mySelectMenu[mySelectMenu.selectedIndex].value[/iCODE] instead. Try this: [CODE] function doit() { var model = document.getElementById("model"); var list1 = document.getElementById("list1"); var list2 = document.getElementById("list2"); var list3 = document.getElementById("list3"); if(model && list1 && list2 && list3) { var val = model[model.selectedIndex].value; list1.style.display = (val == "standard") … | |
Re: AstnRocker Easiest way is to control spacing in the HTML with table attributes, eg: [CODE] document.write("<table cellpadding=\"5\" cellspacing=\"2\" border=\"1\">" + tblHTML + "</table>"); [/CODE] Cellpadding and cellspacing add vertical as well as horizontal spacing. Alternatively, you can use CSS, which gives more control, eg: [CODE] <style> td { padding: 3px … | |
Re: Saadi, The simplest solution is to replace the entire menu from <select ...> to </select>. You can either build the menu like this in php or "top and tail" the options string in the ajax success handler. If you don't already have an addressable container, then wrap the original menu … | |
Re: jiten_raulo, You can further exploit jquery, chiefly by attaching the onclick handler to the checkboxes, which simplifies the HTML and the script. [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> <style> form { margin: 12px 0; } #myImages a { visibility: hidden; } #myImages img { … | |
Re: The traditional/safe way to do this is by using good old steam-age HTML; no need for any javascript. Exercise your php skills to build the select menus with the attribute [ICODE]selected="selected"[/ICODE] for the required option. For example, for a user whose profile says "Canada": [CODE=HTML]<select name="country" id="country"> <option value="">Select Country</option> … | |
Re: Anandhikrishnan, Dynamically rewriting a stylesheet is not generally the preferred approach. It is complex (as evidenced by the code you posted) and not always reliable (as you have found). It is far easier to change the style properties of all elements currently styled with the relevant style direcitve. A potential … | |
Re: Ibn, Post your whole test page. There's got be an error in it somewhere. [B]Airshow[/B] | |
Re: Jonsan, Reading between the lines here, I think you want something that is part algorithmic and part lookup (to accommodate a discount structure). Therefore, the rate per player per workout is to be discovered by lookup, but the other two values are to be calculated, based on the lookup value. … | |
Re: Avocado_juice, Now I have read stbuchok's answer, I think I better understand the problem however I would approach it differently, without needing to use a popup window. Assuming you already have the means to get the scan process to populate an HTML <input> field, then all you need is a … | |
Re: ya.basha, Try [URL="http://raphaeljs.com/"]Raphaël[/URL] or [URL="http://jsdraw2d.jsfiction.com/"]jsDraw2D[/URL] [B]Airshow[/B] | |
Re: This sort of thing is easily achieved with jQuery. [CODE] $("#firstdrop").find("select").clone().appendTo($("#seconddrop")); //where id="seconddrop" is a block element (eg. div) or inline element (eg. span). [/CODE] Any attached event handlers will be attached to the clone automatically. I'm not sure about the current selectedIndex. It probably reverts to zero in the … | |
Re: A reliable 800 millisecond poll across the internet is a big ask. On a private LAN, with a single IP packet in each direction, optimised dedicated server-farm for load sharing, optimised sql, a compiled servlet rather than an interpreted script, and with all client computers in some sort of non-interruptive … | |
Re: alxrite, I think what you want is quite easy but I'm finding it difficult to understand what each table and each "collection" comprises. Can you post one collection's worth of HTML please? [B]Airshow[/B] | |
Re: As far as I know there's no particular issue with [iCODE]* 0.5[/iCODE], however when performing any arithmetic calculation, javascript can give unexpected (imprecise) results due to all numbers being floating point. There's no such thing as a genuine, guaranteed integer value as exists in most programming languages. The good news … | |
Re: [CODE=javascript] location.href = 'view_results.php?month=' + month + '&program=' + program; [/CODE] It's sometimes convenient to build the string like this: [CODE] var querystring = []; querystring.push('month=' + month); querystring.push('program=' + program); location.href = 'view_results.php?' + querystring.join('&'); [/CODE] [B]Airshow[/B] | |
Re: Agrarian, [iCODE]eval[/iCODE] should be avoided and is generally unnecessary. Easiest thing is to use the tree names as properties of an object: [CODE] var arTreePrefixes = ['boxe', 'warn', 'safe', 'indi', 'desc', 'dosa', 'stud'];// etc. var arTrees = {};//new Object for (var i=0; i<arTreePrefixes.length; i++) { var treeName = arTreePrefixes[i] + … | |
![]() | Re: drPHP, I only looked at the javascript, which (barring errors on my part) would be better phrased as follows: [CODE] $(function() { //find all required dom elements var $form = $(form).eq(0); var $first_name = $('[name="first_name"]'); var $last_name = $('[name="last_name"]'); var $reply = $('[name="reply"]'); var $flash = $("#flash"); var $post_reply = … |
Re: Steve, [CODE]function product(a,b) { return a*b; }[/CODE] is equivalent to [CODE]function product(a,b) { var c = a*b; return c; }[/CODE] And there's nothing to prevent you writing the function that way. The line [iCODE]var c = a*b;[/iCODE] works as follows: [LIST=1] [*]performs the calculation and stores the result in a … | |
Re: The only obvious problems are: [LIST] [*]unbalanced quotes [ICODE]<td align="right"">[/ICODE](twice) [*]unbalanced tags [ICODE]<form><table> ... </form></table>[/ICODE] [/LIST] But, for me, neither of these prevents the validation function working. Try saving the page locally with .html extension and without the <%@ page ... %> directive and see if that makes a difference. … | |
Re: Joe, I think you just need a some safety conditions to avoid errors. Personally I would write the code something like this: [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> <script type='text/javascript'> var currentId; function edit_div(id){ var addnew = document.getElementById("addnew"); if(addnew){ addnew.style.display = 'block'; currentId = … | |
Re: Try doing the whole thing in jquery rather than hybrid code: [CODE=javascript] function showContent(x){ var $cont = $("#content"); $cont.slideUp("slow", function(){ $.ajax({ url: x + ".txt", type: "GET", success: function(data){ $cont.html(data).slideDown("slow"); } }); }); } [/CODE] [I](untested)[/I] Note that [iCODE]$cont---.slideDown("slow");[/iCODE] is inside the success function to give the desired effect (I … | |
Re: It sounds like you are describing a "sprite". Sprites are well explained on the web, so I won't try to add anything here. Try googling "sprite javascript css". [B]Airshow[/B] | |
Re: [QUOTE=uselessninja;1579155]uhmm.... can u teach me how to set up that in html?... have 1 button and 2 textbox (1 textbox is where u input a number then the 2nd is to display the result) thankzz so much^^[/QUOTE] Is that not exactly the same as the demo? [B]Airshow[/B] | |
Re: Rents, I have used your requirement as a long overdue exercise in writing a jQuery plugin; something I've not done in earnest before. Try this: [CODE=HTML] <!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> <style> #mydiv1 { height: 150px; margin-top:12px; padding: 10px; border: 1px solid #000000; } … |
The End.