[jQuery] Check function ... Not working in JQuery. Please, is urgent. Thank You.
Hello, I am applying a function (tinymce) to some text areas. However I need to check before if this function exists (if its js file was loaded). If I would use JS I would do this: $(document).ready(function() { if (typeof (tinymce) !== undefined) { $('textarea.Editor-Base').tinymce({ // ... This is not working. Even if the function tinymce is present it is not applied. I removed the code line (if (typeof (tinymce) !== undefined) {) and not tinymce runs. But I really need to test it. This was working when I was not using JQuery ... Any idea how to do this? Thanks, Miguel
[jQuery] Find text. Is this possible with JQuery?
Hello, Is it possible with JQuery to find all words xyz in a text and replace it by span class=xyzxyz/span? Thanks, Miguel
[jQuery] Get Value. Please, is kind of urgent. Thanks.
Hello, I have the following on my script: $(document).ready(function() { if (GBrowserIsCompatible()) { $.getJSON(/Google/Map, Initialise); } // Initialize Google Map } And in my HTML I have: input id=Place name=Place type=hidden value=3 / I want to run the JS code only if GBrowserIsCompatible() is defined. If it is and if Place hidden value is not then I want to call: $.getJSON(/Google/Map/{hidden_value}, Initialise); In this case hidden value is 3. If hidden value is then just call: $.getJSON(/Google/Map, Initialise); Please, could someone help me out? Thanks, Miguel
[jQuery] Re: Get Value. Please, is kind of urgent. Thanks.
And is there a way to check if GBrowserCompatible is valid? When I am not using google maps I don't load the Google maps script. However this code is always present. Thank You, Miguel On Jan 12, 8:13 pm, Nathan Klatt n8kl...@gmail.com wrote: Like so? if (GBrowserIsCompatible()) { var gmapsUrl = /Google/Map; if ($(#Place).val()) gmapsUrl += /+$(#Place).val(); $.getJSON(gmapsUrl, Initialise); }
[jQuery] Re: Click Even
On Dec 3, 2:52 am, JMcGinnis justin.mcgin...@gmail.com wrote: y0, Not really, why do you need to/ or want to? you could do this $('#Play').click(function() { $.cookies.set('WCA.Player', 'Play', { path: '/' }) }) ha, j/k same thing, just one line. Could you just explain why you would like to do it a different way? or where you just wondering? I was just wondering ... Thank you.
[jQuery] IF. What am I doing wrong?
Hello, I have the following code: alert($.cookies.get(WCA.Player)); var cookie = $.cookies.get(WCA.Player); if (cookie == null || cookie == 'Play') { $(#JPlayer).play(); } The alert gives me the correct value which is null or 'Play' but the if is not working correctly. Am I doing something wrong? Thanks, Miguel
[jQuery] IF and NULL. Please, could someone help me out?
Hello, I have the following: $(#JPlayer).jPlayer({ ready: function() { $(this).setFile($('#MusicPath').attr(value)).play(); }, swfPath: $('#JPlayerPath').attr(value) }); I would like the play the file: $(this).setFile($('#MusicPath').attr(value)).play(); Only if ( $.cookies.get(AlliedSkills.Player) = Play ) If ($.cookies.get(AlliedSkills.Player) is null then do not play and set only the file: $(this).setFile($('#MusicPath').attr(value)); Could someone please help me in doing this? Thanks, Miguel
[jQuery] Click Even
Hello, I am using the following to create a cookie and it is working fine: $('#Play').click(function() { $.cookies.set('WCA.Player', 'Play', { path: '/' }); }); Is there another way to do the same code but something like: $('#Play:click').cookies.set('WCA.Player', 'Play', { path: '/' }); Thanks, Miguel
[jQuery] Cookie
Hello, I am using JPlayer plugin with 2 buttons. Play and Stop. $(#jquery_jplayer).jPlayer({ ready: function () { $(this).setFile('http://mydomain.com/mymusic.mp3').play(); demoInstanceInfo($(this), $(#jplayer_info)); } }) .jPlayerId(play, play) .jPlayerId(stop, stop) }); I would like to: 1) Play the music on start if: There is no cookie JPlayer OR if there is a Cookie JPlayer with value true; 2) Change the value of JPlayer cookie to false if the button stop is pressed. If there is no cookie JPlayer then create one. 3) Change the value of JPlayer cookie to true if the button play is pressed. If there is no cookie JPlayer then create one. Basically I am trying to memorize the sound setting across pages. Thanks, Miguel
[jQuery] Re: Unknown pseudo-class or pseudo-element 'odd'.
On Dec 1, 11:33 pm, Karl Swedberg k...@englishrules.com wrote: Aha! I see it now. It's a warning, not an error, and it's a CSS warning. If you're seeing it in Firebug, you can hide it by unchecking Show CSS Errors in the Console preferences list. Thank You, Miguel
[jQuery] Cookie in JQuery. Create, Update and Get
Hello, I need to add a cookie with value true or false. If the cookie does not exist then created. Otherwise change its value to the new value. Later I need to get the cookie value. Can I do this with JQuery? Do I need a plugin? Which one? Thank You, Miguel
[jQuery] JQuery and Maybe IFrame Problem?
Hello, I am defuscating my email on the client as follows: $(span,a[href^=mailto:];).defuscate(); Is is working! So: a href=mailto:info(AT)domain.com class=Emailinfo(AT)domain.com/ a Becomes: a href=mailto:i...@domain.com; class=Emaili...@domain.com/a However, this is not working when the email is inside TinyMce: iframe id=Text_ifr frameborder=0 src=javascript: style=width: 100%; height: 104px; html head xmlns=http://www.w3.org/1999/xhtml; /head body id=tinymce class=mceContentBody spellcheck=false dir=ltr a class=Email mce_href=mailto:info(AT)domain.com href=mailto:info(AT)domain.cominfo(AT)domain.com/a Maybe this is because the email in the TinyMCE is inside an IFrame? How can I solve this problem? Thanks, Miguel
[jQuery] Get value from hidden input and use it in string
Hello, I am using JPlayer to play a sound on a page: http://www.happyworm.com/jquery/jplayer/0.2.5/demo-04.htm $(document).ready(function(){ $(#jquery_jplayer).jPlayer({ ready: function () { $(#trackname).text($(#track-01).text()); $(this).setFile('http://www.miaowmusic.com/mp3/Miaow-05-The- separation.mp3').play(); demoInstanceInfo($(this), $(#jplayer_info)); } }) }); How can I change the setFile code line to: $(this).setFile('http://domain.com/asset/get/[id]').play(); Where [id] value should be taken from the following hidden input: input TYPE=hidden VALUE=2 NAME=Music Thank You, Miguel
[jQuery] Re: Sound
On Nov 5, 11:14 pm, Erik Beeson erik.bee...@gmail.com wrote: No jQuery necessarily needed for this. Plenty of information here: http://www.google.com/search?q=html+embed+audio Not if a Play and Stop button is required ... Or maybe even a music list. I found the following: http://www.happyworm.com/jquery/jplayer/ What do you think? Thanks, Miguel
[jQuery] Sound
Hello, Is it possible to have a music on a HTML page with two buttons to play/ stop? Can I use JQuery for this? Thanks, Miguel
[jQuery] Add value to Link. How can I do this?
Hello, I have the following anchor: a href=http://www.example.com/files/map.pdf; onClick=javascript: pageTracker._trackPageview('/downloads/map'); How can I add onClick=javascript: pageTracker._trackPageview('/downloads/ map'); To all anchors of CSS class Download using JQuery? Thanks, Miguel
[jQuery] Re: (tooltip) Markup problem
On Oct 12, 8:57 pm, Jörn Zaefferer joern.zaeffe...@googlemail.com wrote: That sounds like you validate a page for the sake of validation. I think thats beneath the point, therefore I don't get your argument. Do you worry about accessibility? If so, did you test the tooltip with a screenreader? Afaik thats the best way to test for accessibility; validation not so much. Jörn, I didn't talk about validation. Take the example I created here: http://flyonpages.flyondreams.pt/tooltip.html The document structure already contains a H3 header. IMHO it does not make sense to me the tooltip to add a header at same level ... I even think the tooltip shouldn't have a header ... But of course that is my opinion. But in this example, to use a header on tooltip, it should be a H4 ... agree? I really like the functionality of your plugin: For example, when tooltip disappears when a input is selected ... Would be possible to tell me how to change the plugin code so the tooltip would be just: divspanTitle ... spandiv And I need to display only the title ... no url in case of anchors. Just the title in all situations. Basically, a really simple tooltip but with the same behavior as yours. I have been looking for such a plugin but they never work as good as yours. And all my tries to adapt your code ended with a broken plugin ... Thank You, Miguel
[jQuery] (tooltip) Markup problem
Hello, I have been using Bassistance tooltip but I think the markup is really incorrect. http://bassistance.de/jquery-plugins/jquery-plugin-tooltip/ Why forcing an H3 into the tooltip? Did you ever checked a page with it in Opera's table of contents? By imposing H3 you are breaking the semantics of a page ... At least you could allow to have an option to have the H3 or not ... What do you think? Thanks, Miguel
[jQuery] Clean code. Could someone, please, help me out?
Hello, I am using Bassistance tooltip but I need to simplify the markup. So instead of using: helper.parent = $('div id=' + settings.id + 'h3/h3div class=body/divdiv class=url/div/div') I would like to use: helper.parent = $('div id=' + settings.id + 'span/span/div') However, when I did this change everything stopped working. I think I need to clean some extra code but all my tries didn't solve the problem ... Could someone help me out with this? Here is the plugin original code: ;(function($) { // the tooltip element var helper = {}, // the current tooltipped element current, // the title of the current element, used for restoring title, // timeout id for delayed tooltips tID, // IE 5.5 or 6 IE = $.browser.msie /MSIE\s(5\.5|6\.)/.test(navigator.userAgent), // flag for mouse tracking track = false; $.tooltip = { blocked: false, defaults: { delay: 200, fade: false, showURL: true, extraClass: , top: 15, left: 15, id: tooltip }, block: function() { $.tooltip.blocked = !$.tooltip.blocked; } }; $.fn.extend({ tooltip: function(settings) { settings = $.extend({}, $.tooltip.defaults, settings); createHelper(settings); return this.each(function() { $.data(this, tooltip, settings); this.tOpacity = helper.parent.css(opacity); // copy tooltip into its own expando and remove the title this.tooltipText = this.title; $(this).removeAttr(title); // also remove alt attribute to prevent default tooltip in IE this.alt = ; }) .mouseover(save) .mouseout(hide) .click(hide); }, fixPNG: IE ? function() { return this.each(function () { var image = $(this).css('backgroundImage'); if (image.match(/^url\([']?(.*\.png)[']?\)$/i)) { image = RegExp.$1; $(this).css({ 'backgroundImage': 'none', 'filter': progid:DXImageTransform.Microsoft.AlphaImageLoader (enabled=true, sizingMethod=crop, src=' + image + ') }).each(function () { var position = $(this).css('position'); if (position != 'absolute' position != 'relative') $(this).css('position', 'relative'); }); } }); } : function() { return this; }, unfixPNG: IE ? function() { return this.each(function () { $(this).css({'filter': '', backgroundImage: ''}); }); } : function() { return this; }, hideWhenEmpty: function() { return this.each(function() { $(this)[ $(this).html() ? show : hide ](); }); }, url: function() { return this.attr('href') || this.attr('src'); } }); function createHelper(settings) { // there can be only one tooltip helper if( helper.parent ) return; // create the helper, h3 for title, div for url helper.parent = $('div id=' + settings.id + 'h3/h3div class=body/divdiv class=url/div/div') // add to document .appendTo(document.body) // hide it at first .hide(); // apply bgiframe if available if ( $.fn.bgiframe ) helper.parent.bgiframe(); // save references to title and url elements helper.title = $('h3', helper.parent); helper.body
[jQuery] Simple Tooltip
Hello, I need a simple tooltip which html markup is only a div. I have the following: this.tooltip = function(){ /* CONFIG */ xOffset = 10; yOffset = 20; // these 2 variable determine popup's distance from the cursor // you might want to adjust to get the right result /* END CONFIG */ $(a.tooltip).hover(function(e){ this.t = this.title; this.title = ; $(body).append(div id='tooltip'span+ this.t +/span/ div); $(#tooltip) .css(top,(e.pageY - xOffset) + px) .css(left,(e.pageX + yOffset) + px) .fadeIn(fast); }, function(){ this.title = this.t; $(#tooltip).remove(); }); $(a.tooltip).mousemove(function(e){ $(#tooltip) .css(top,(e.pageY - xOffset) + px) .css(left,(e.pageX + yOffset) + px); }); }; How can I change this plugin to use CSS Class selectors? And how can I add a parameter to define the tooltip div CSS Class? Does anyone knows a better Simple Tooltip? Most tooltips I see have complex markup and some of them even include headers tags in the tooltip which in my opinion shouldn't happen. Thanks, Miguel
[jQuery] Plugin not working with latest JQuery Plugin
Hello, I have been using on my projects the following Email Defuscator: http://www.ia-stud.hiof.no/~joakims/projects/defuscator/ Strangely when using it with the latest JQuery version I get the error: this.each is not a function [Break on this error] jQuery.fn.defuscate=function(settings){s...ace (regex,'$...@$2'));var is_link=true;}\r\n The Plugin code is really short: http://plugins.jquery.com/files/jquery.defuscate.js_1.txt Could someone, please, tell me what is wrong? If you can suggest me a better plugin please let me know. Thanks, Miguel
[jQuery] MultiSelect and CheckBoxes. Could someone please help me out?
Hello, I am using the following Multiple Select JQuery plugin with ASP.NET MVC. http://abeautifulsite.net/notebook/62 When the form is posted back the values selected before are unselected now ... I have an idea of how to solve this but I don't know how to implement it in JQuery. The plugin is aplied as follows: $(select.Multi).multiSelect(); And I get something like: input type=checkbox value=1 name=Roles/ input type=checkbox value=2 name=Roles/ 1) I need to find the IDs of all the select.Multi on the page before multiSelect() is applied; 2) After multiSelect() is applied I need to: a) Find all hidden inputs which ID is equal to IDs found in (1) plus Data. For example if in (1) I found the IDs Roles and Levels now I would find: RolesData and LevelsData b) RolesData and LevelsData contain the selected values before posted back: Example: RolesData contains 1, 4, 7, 11 c) I need to find all checkbox inputs which name is Roles and make the ones with value 1, 4, 7, 11 checked. I think this is the way to solve this problem. But I have no idea how to do this in JQuery. Could someone please, help me out? Thank You, Miguel
[jQuery] Unknown pseudo-class or pseudo-element 'odd'.
Hello, I am using JQuery 1.3.2 and the following code line: $(table.Engine tbody tr:odd).addClass(Alternate); I get the following error on firebug: Unknown pseudo-class or pseudo-element 'odd'. What am I doing wrong? Thanks, Miguel
[jQuery] this.each is not a function
Hello, I am using JQuery 1.3.2 and I get the error this.each is not a function when I try to use the following plugin: jQuery.fn.defuscate = function(settings) { settings = jQuery.extend({ link: true }, settings); var regex = /\b([A-Z0-9._%-]+)\([^)]+\)((?:[A-Z0-9-]+\.)+[A-Z] {2,6})\b/gi; return this.each(function() { if ($(this).is('a...@href]')) { // If it's an a element, defuscate the href attribute $(this).attr('href', $(this).attr('href').replace(regex, '$...@$2')); // Make sure that the element's contents is not made into a link var is_link = true; //alert($(this).attr('href')); } // Defuscate the element's contents $(this).html($(this).html().replace(regex, (settings.link ! is_link ? 'a href=mailto:$...@$2;$...@$2/a' : '$...@$2'))); }); } Could someone, please, tell me what is wrong? Thanks, Migueç
[jQuery] Re: this.each is not a function
On Sep 13, 7:28 pm, Mike McNally emmecin...@gmail.com wrote: Have you used a debugging tool to figure out what this is? Also, your function isn't returning this, possibly an unrelated problem but it probably should be fixed. What should I do? Sorry, I am not familiar with JQuery. I am just starting. This was a plugin I downloaded from JQuery Plugins site that keeps giving me errors. I am using Firebug and a Validator both in Firefox Thanks, Miguel
[jQuery] Check if function exists
Hello, I am loading TinyMCE using the new JQuery Plugin: script type=text/javascript $().ready(function() { $('textarea.tinymce').tinymce({ // Location of TinyMCE script script_url : '../js/tinymce/jscripts/tiny_mce/tiny_mce.js', Is there a way to load only if tinymce plugin is present without getting an error? Basically if I don't want to load the tinymce I just don't load the plugin ... ... Because I am not able to pass, I think, to my SiteScript.JS file if I want to load or not the plugin. Thanks, Miguel
[jQuery] Re: Email obfuscator/defuscator plugin
I found the following one: http://plugins.jquery.com/project/RotationalStringObfuscator It seems interesting. How can I apply it to all emails on my web page? Thank You, Miguel
[jQuery] Email obfuscator/defuscator plugin
Hello, Could someone recommend me a good email obfuscator/defuscator plugin? Thanks, Miguel
[jQuery] Re: Email obfuscator/defuscator plugin
I think the Rot13 is better at least according with the following results: http://www.josephfinsterwald.com/UI/Pages/article4.aspx On Sep 2, 7:01 pm, brian bally.z...@gmail.com wrote: I wrote one but have never gotten around to submitting it. Feedback welcome. /** * De-obfuscate printed email addresses which are of the type: * * span class=Obfuscated title=some title * some link text [ someone AT gmail DOT com ] * span * * The braces around the address part are hard-wired here. That should * probably be set by a param. Ditto for the AT DOT. * * @author brian ally, zijn digital **/ jQuery.fn.deobfuscate = function() { return this.each(function() { var content = $(this).text(); /* grab the part inside the braces, swap out placeholders, and trim */ var obfuscated = content.match(/\[(.*)\]/); var address = obfuscated[1] .replace(' AT ', '@') .replace(' DOT ', '.') .replace(/^\s+|\s+$/g, ''); /* get everything before the braces and trim */ var text = content.match(/.?[^[]+/); text = (text[0] != content) ? text[0].replace(/^\s+|\s+$/g, '') : address; // if there's no text part, use the address var title = $(this).attr('title') || ''; $(this).replaceWith($('a href=mailto:' + address + ' title=' + title + '' + text + '/a')); }); }; $(function() { $('.Obfuscated').deobfuscate(); }); The title attribute of the span will be given to the link. If you leave out the some link text part, the email address itself will be used. Here's a PHP function to create the span from an email address. /** * Wrap an email address in a formatted span tag in such a way * as to allow for easy javascript translation to a normal mailto: link. * * this: * f...@bar.net, 'email foo!', 'some title text' * becomes: * span class=Obfuscated title=some title textemail foo! [ foo AT bar DOT net ]/span * * @param string address email address * @param string text link text * @param string title link title * @return string obfuscated address, wrapped in i span tag * * @author brian ally, zijn digital **/ function obfuscateEmail($address, $text= null, $title = null) { if (empty($address)) return null; $regexp = '^[_a-z0-9-]+(\.[_a-z0-9-]+)*...@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,4})$'; $search = Array('@', '.'); $replace = Array(' AT ', ' DOT '); $class = 'Obfuscated'; if (is_string($address) eregi($regexp, $address)) { $obfuscated = str_replace($search, $replace, $address); return span class=\${class}\ . (!is_null($title) ? title=\${title}\ : null) . '' . (!is_null($text) ? $text : null) . [ ${obfuscated} ]/span; } return $address; } On Wed, Sep 2, 2009 at 12:35 PM, shappermdmo...@gmail.com wrote: I found the following one: http://plugins.jquery.com/project/RotationalStringObfuscator It seems interesting. How can I apply it to all emails on my web page? Thank You, Miguel
[jQuery] Form Tips
Hello, I would like to show a tip or balloon with some info when a user clicks an input to enter a value. Does anyone knows a good plugin that does this? Thank You, Miguel
[jQuery] Re: Find element. How can I do this?
Please, anyone? Thank You, Miguel On Mar 17, 9:46 pm, shapper mdmo...@gmail.com wrote: Yes, I tried that before but it did not work this is why I asked. I placed an example online:http://www.27lamps.com/Beta/Collapse/Form.html You can see that each form's fieldset has an ordered list inside. I want to show/hide the OL instead of adding it to a new div. Could someone, please, help me with this? Thanks, Miguel On Mar 17, 6:01 pm, ricardobeat ricardob...@gmail.com wrote: Try this: var body = fieldset.find('ol:first') http://docs.jquery.com/Selectors On Mar 17, 12:13 pm, shapper mdmo...@gmail.com wrote: Hello, I am trying to find update a plugin to create new functionality. On the current version I have the following: var legend = fieldset.find(':first'); var body = jQuery(document.createElement('div')); - How can I get the first OL element inside fieldset to use it as body instead of creating a new element (the div as it is currently? - And can I set which element should be searched (ol, ul, div, etc) inside the fieldset? Thank you, Miguel
[jQuery] Re: Find element. How can I do this?
Sorry, I don't understand what your mean. Please, check the code I am using in: http://www.27lamps.com/Beta/Collapse/JQuery.Collapsible-1.0.js The change I am trying to do is in the following lines: var legend = fieldset.find(':first'); var body = jQuery(document.createElement('div')); //var body = fieldset.find('ol:first') On Mar 18, 2:12 pm, AnatolyG anat...@geyfman.net wrote: $(fieldset ol:eq(0)).hide() shapper wrote: Hello, I am trying to find update a plugin to create new functionality. On the current version I have the following: var legend = fieldset.find(':first'); var body = jQuery(document.createElement('div')); - How can I get the first OL element inside fieldset to use it as body instead of creating a new element (the div as it is currently? - And can I set which element should be searched (ol, ul, div, etc) inside the fieldset? Thank you, Miguel
[jQuery] Re: Find element. How can I do this?
Hi, that is what I am trying to do but by using that plugin I can: 1. Have different CSS classes applied to collapsed and expanded fieldsets so I can get a toogle icons; 2. Control the speed of collapse (this is not very important) The problem is that the plugin, as far as I can see, gets all the markup on the fieldset, places it inside a div and aplies the collapse/ expand to the div. I would prefer the plugin to apply this to the ol, or even better, be able to specify to which element in the fieldset should this be applied (the collapase/expand) and the CSS classes. I am not expert in JQuery but the plugin seems ok ... or no? Thank You, Miguel On Mar 18, 6:17 pm, AnatolyG anat...@geyfman.net wrote: I don't have context for what you're trying to do, but if you want to hide the first OL that's displayed, then: fieldset.find(ol:eq(0)) finds it to hide it. but, if you just want this to be collapsable, and when clicking on the legend, uncollapse, wouldn't this be much easier? $('fieldset').each(function(index, obj){ var $item = $(obj); $item.find(legend).click(function(e){ $item.find(ol:first).toggle(); }); $item.find(ol:first).hide(); }); If you want to do something else, explain... A On Mar 18, 8:45 pm, shapper mdmo...@gmail.com wrote: Sorry, I don't understand what your mean. Please, check the code I am using in:http://www.27lamps.com/Beta/Collapse/JQuery.Collapsible-1.0.js The change I am trying to do is in the following lines: var legend = fieldset.find(':first'); var body = jQuery(document.createElement('div')); // var body = fieldset.find('ol:first') On Mar 18, 2:12 pm, AnatolyG anat...@geyfman.net wrote: $(fieldset ol:eq(0)).hide() shapper wrote: Hello, I am trying to find update a plugin to create new functionality. On the current version I have the following: var legend = fieldset.find(':first'); var body = jQuery(document.createElement('div')); - How can I get the first OL element inside fieldset to use it as body instead of creating a new element (the div as it is currently? - And can I set which element should be searched (ol, ul, div, etc) inside the fieldset? Thank you, Miguel
[jQuery] Find element. How can I do this?
Hello, I am trying to find update a plugin to create new functionality. On the current version I have the following: var legend = fieldset.find(':first'); var body = jQuery(document.createElement('div')); - How can I get the first OL element inside fieldset to use it as body instead of creating a new element (the div as it is currently? - And can I set which element should be searched (ol, ul, div, etc) inside the fieldset? Thank you, Miguel
[jQuery] Re: Find element. How can I do this?
Yes, I tried that before but it did not work this is why I asked. I placed an example online: http://www.27lamps.com/Beta/Collapse/Form.html You can see that each form's fieldset has an ordered list inside. I want to show/hide the OL instead of adding it to a new div. Could someone, please, help me with this? Thanks, Miguel On Mar 17, 6:01 pm, ricardobeat ricardob...@gmail.com wrote: Try this: var body = fieldset.find('ol:first') http://docs.jquery.com/Selectors On Mar 17, 12:13 pm, shapper mdmo...@gmail.com wrote: Hello, I am trying to find update a plugin to create new functionality. On the current version I have the following: var legend = fieldset.find(':first'); var body = jQuery(document.createElement('div')); - How can I get the first OL element inside fieldset to use it as body instead of creating a new element (the div as it is currently? - And can I set which element should be searched (ol, ul, div, etc) inside the fieldset? Thank you, Miguel
[jQuery] TextArea CountDown
Hello, Does anyone knows a good JQuery countdown that displays the number of remaining characters on a text box? Thank You, Miguel
[jQuery] Show/Hide element
Hello, I have a list of fieldsets and each one has a legend. I am thinking in having something like: fieldset legendPersonal Data/legend ul lifirst element/li lisecond element/li /ul /fieldset How can Show/Hide the ul when I click the legend? I would like to have many fielsets on a form and being able to Show/ Hide the contents of any fieldset. Thanks, Miguel
[jQuery] Bassistance Accordion and Others
Hello, I have been trying JQuery's Bassistance Accordion and a few others but until now I wasn't able to make it work with a form ... For example, consider the following form structure: form action=Create/Account fieldset id=f1 legenda href=#f1LegPersonal/a/legend ul id=f1Content liName: .../li liCity: .../li /ul /fieldset fieldset id=f2 legenda href=#f2LegContacts/a/legend ul id=f2Content liEmail: .../li liPhone: .../li /ul /fieldset /form I would like to show/hide each fieldset content (ul, div, etc. In this case I am using ul) when the legend is clicked. I inserted an anchor inside the legend … it seemed correct to do this in terms of markup. How can I use similar code with accordion plugin? Is this possible? Thanks, Miguel
[jQuery] Find Element. Could someone, please, help me? Thank You
Hello, On a plugin I have the following: var legend = fieldset.find(':first'); var body = jQuery(document.createElement('div')); Instead of creating a div for the body I would like to get a existing OL in the fieldset and make it the body. How can I do this? Thanks, Miguel
[jQuery] Re: TextArea CountDown
Thank You! On Mar 15, 5:09 pm, mkmanning michaell...@gmail.com wrote: No, but it's pretty easy to write one :) textarea/textarea div id=counter/div $('textarea').keyup(function(){ if(this.value.length = 100) { //handle the over the limit part here $(this).addClass('overlimit'); this.value = this.value.substring(0, 100); } else { $(this).removeClass('overlimit'); } $('#counter').text(100-this.value.length); }); On Mar 15, 7:37 am, shapper mdmo...@gmail.com wrote: Hello, Does anyone knows a good JQuery countdown that displays the number of remaining characters on a text box? Thank You, Miguel
[jQuery] Add value to input
Hello, In a form I have a select (S), a button (B) and an input (I) among other form elements. I would like to add the value of the select, when the button is clicked, to the end of the text that is currently in the input. How can I do this? Thanks, Miguel
[jQuery] Re: Order Items. Please help me. Thank You.
Hi Michael, It is working fine. Thank You Very Much. Just one final question. This is part of a form. When the form is submitted but not validated on the server I rebuild the themes list. There is only one problem: when I delete a theme all disappear. I think it is because themes is being initialized as follows: themes = []; Well, that is fine if initially the list is empty ... but if not then I should get all themes. So I am trying to create a function named InitThemes that initialize themes. li class=Themes Economiabr/ Secundário e Universitáriobr/ Note 1br/ a class=Remove href=#RemoveRemover/a input type=hidden name=Themes[0].Subject value=Economy/ input type=hidden name=Themes[0].LevelsCsv value=Secondary,College/ input type=hidden name=Themes[0].Note value=Note 1/ /li li class=Themes Matemáticabr/ Universitáriobr/ Note 2br/ a class=Remove href=#RemoveRemover/a input type=hidden name=Themes[1].Subject value=Mathematics/ input type=hidden name=Themes[1].LevelsCsv value=College/ input type=hidden name=Themes[1].Note value=Note 2/ /li So basically in InitThemes I need to parse all this back to themes. The values and text. Maybe the inputs are easy but not the rest ... I think ... Is there a better approach to accomplish this? Thanks, Miguel On Feb 24, 9:39 pm, mkmanning michaell...@gmail.com wrote: The problem is t[1] is now an array of objects, so you have to access the text and value attributes of the objects by their array index. Here are the buildThemesList function and the friendlyLevels functions rewritten to account for that. function buildThemesList(){ ol.empty(); //more string concatenation than I like, but OK if you aren't building a huge list $.each(themes,function(i,t){ //this handles the li content var li = $('li').addClass('Themes').html(t[0].text+'br /' +friendlyLevels(t[1])+'br /' +(t[2]==''?'':t[2]+'br /') +'a href=#Remove class=RemoveRemove/a' ).appendTo(ol); //now the inputs, this could also be done in another loop with an array of names, if it gets longer; and the brackets in the name are still a bad idea $('input').attr({'type':'hidden','name':'Themes['+i +'].Subject'}).val(t[0].value).appendTo(li); $('input').attr({'type':'hidden','name':'Themes['+i +'].LevelCsv'}).val($.map(t[1],function(l,i){return l.value;}).join ()).appendTo(li); $('input').attr({'type':'hidden','name':'Themes['+i +'].Note'}).val(t[2]).appendTo(li); }); //just to keep things exactly as the original example's UI $('#Index').val(themes.length); } function friendlyLevels(levels) { if (levels.length == 1){ return levels[0].text; } var friendly = ; $.each(levels,function(i,l){ friendly += l.text + ((i==levels.length-2)?' e ': (i==levels.length-1)?'':', '); }); return friendly; } Couple of things to note: friendlyLevels now has {} enclosing the first if statement. You'll see lots of coders not do that, but it's really a good idea, and not just a style choice: javascript suffers from automatic semicolon insertion which although not a common problem to run into, could make things difficult to debug. Even though there are only three checkboxes, the each function with the ternary means you don't have to refactor if you decide to add more checkboxes. To get the values into the hidden input, $.map() is used. Check it out in the documentation. Hope this helps. On Feb 24, 11:20 am, shapper mdmo...@gmail.com wrote: @Michael, I just installed Firebug and I almost made this working. The only problem I have is when I am adding the levels to the list as html and as hidden input: +friendlyLevels(t[1].text.join(', '))+'br /' $('input').attr({'type':'hidden','name':'Themes['+i +'].LevelCsv'}).val(t[1].value.join()).appendTo(li); I get an error in Firebug: t[1].text is undefined [Break on this error] +friendlyLevels(t[1].text.join(', '))+'br /' But as far as I know to get the text and value I use .text and .value. My friendlyLevels function is function friendlyLevels(levels) { if (levels.length 2) return levels.join(''); var first = levels.slice(0, -1), last = levels.slice(-1); var friendly = first.join(', '); if (last) { friendly
[jQuery] Re: Order Items. Please help me. Thank You.
I am not using Ajax because I need to submit the form all at once. I cannot submit the themes because the user is not created yet. Anyway, the other option you suggested me was what I was trying: $test = $('#Test'); $test.append(themes); Where Test would be an hidden input. I then read this value on the server. When the page is redisplayed I fill the Test input again. Then on document ready I read the content of this input, place it in themes, and call build. Am I thinking correctly? The only problem is that I get an error: Node cannot be inserted at the specified point in the hierarchy code: 3 [Break on this error] fragment.appendChild( ret[i] ); I am able to append a test string but not themes. Am I doing something wrong? Thanks, Miguel On Feb 25, 10:54 pm, mkmanning michaell...@gmail.com wrote: You could post to the server with ajax, or since you have all the data server-side, just render the page with the themes array already populated and call the build function On Feb 25, 11:55 am, shapper mdmo...@gmail.com wrote: Hi Michael, It is working fine. Thank You Very Much. Just one final question. This is part of a form. When the form is submitted but not validated on the server I rebuild the themes list. There is only one problem: when I delete a theme all disappear. I think it is because themes is being initialized as follows: themes = []; Well, that is fine if initially the list is empty ... but if not then I should get all themes. So I am trying to create a function named InitThemes that initialize themes. li class=Themes Economiabr/ Secundário e Universitáriobr/ Note 1br/ a class=Remove href=#RemoveRemover/a input type=hidden name=Themes[0].Subject value=Economy/ input type=hidden name=Themes[0].LevelsCsv value=Secondary,College/ input type=hidden name=Themes[0].Note value=Note 1/ /li li class=Themes Matemáticabr/ Universitáriobr/ Note 2br/ a class=Remove href=#RemoveRemover/a input type=hidden name=Themes[1].Subject value=Mathematics/ input type=hidden name=Themes[1].LevelsCsv value=College/ input type=hidden name=Themes[1].Note value=Note 2/ /li So basically in InitThemes I need to parse all this back to themes. The values and text. Maybe the inputs are easy but not the rest ... I think ... Is there a better approach to accomplish this? Thanks, Miguel On Feb 24, 9:39 pm,mkmanningmichaell...@gmail.com wrote: The problem is t[1] is now an array of objects, so you have to access the text and value attributes of the objects by their array index. Here are the buildThemesList function and the friendlyLevels functions rewritten to account for that. function buildThemesList(){ ol.empty(); //more string concatenation than I like, but OK if you aren't building a huge list $.each(themes,function(i,t){ //this handles the li content var li = $('li').addClass('Themes').html(t[0].text+'br /' +friendlyLevels(t[1])+'br /' +(t[2]==''?'':t[2]+'br /') +'a href=#Remove class=RemoveRemove/a' ).appendTo(ol); //now the inputs, this could also be done in another loop with an array of names, if it gets longer; and the brackets in the name are still a bad idea $('input').attr({'type':'hidden','name':'Themes['+i +'].Subject'}).val(t[0].value).appendTo(li); $('input').attr({'type':'hidden','name':'Themes['+i +'].LevelCsv'}).val($.map(t[1],function(l,i){return l.value;}).join ()).appendTo(li); $('input').attr({'type':'hidden','name':'Themes['+i +'].Note'}).val(t[2]).appendTo(li); }); //just to keep things exactly as the original example's UI $('#Index').val(themes.length); } function friendlyLevels(levels) { if (levels.length == 1){ return levels[0].text; } var friendly = ; $.each(levels,function(i,l){ friendly += l.text + ((i==levels.length-2)?' e ': (i==levels.length-1)?'':', '); }); return friendly; } Couple of things to note: friendlyLevels now has {} enclosing the first if statement. You'll see lots of coders not do that, but it's really a good idea, and not just a style choice: javascript
[jQuery] Re: Order Items. Please help me. Thank You.
Hi, I think I did that ... I have this example working with Subjects and FriendlyLevels function to add the e correctly: http://www.27lamps.com/Beta/List/List4.html Then I tried to do the same but for levels: http://www.27lamps.com/Beta/List/List5.html But I keep having errors. What am I missing? Sorry, but I am just starting with JQuery. Thank You, Miguel On Feb 23, 9:23 pm, mkmanning michaell...@gmail.com wrote: That's because you changed levels to an object, which you don't need to. Just use the original var levels = $('input:checkbox:checked'), and then levels.each(function(){ levelsCsv.push({'text':this.value,'value':$ (this).next().text()}) }) On Feb 23, 9:37 am, shapper mdmo...@gmail.com wrote: Hello, I tried to make the change: levels.each(function(){ levelsCsv.push({'text':this.value,'value':$(this).next().text()}) }) But I get an error on Firebug: levels.each is not a function Am I doing something wrong? I also made a change on buildThemesList to use text and also to fix the problem on your code that adds e only when there are 3 items. It should be also applied when there are 2: $.each(themes,function(i,t){ var li = $('li').addClass('Themes').html(t[0].text+'br /' +friendlyLevels(t[1].text)+'br /' +(t[2]==''?'':t[2]+'br /') +'a href=#Remove class=RemoveRemover/a' ).appendTo(ol); function friendlyLevels(levels) { if (levels.length 2) return levels.join(''); var first = levels.slice(0, -1), last = levels.slice(-1); var friendly = first.join(', '); if (last) { friendly += ' e ' + last; } return friendly; } I am not completely sure that I am doing this right because I get the error before. Thank You, Miguel On Feb 20, 5:02 pm, mkmanning michaell...@gmail.com wrote: levels.text = $('input[name=Levels]:checked + label'); levels.value = $('input[name=Levels]:checked'); Those don't get you the right values for the levels object, they both return a jQuery object. Accessing the levels object as this.value won't work either. Try this: levels.each(function(){ levelsCsv.push({'text':this.value,'value':$(this).next().text()}) }) On Feb 20, 5:22 am, shapper mdmo...@gmail.com wrote: Hi, I followed your tips but I still have a few problems. The subject is working fine but when I do the same to the levels it does not work. I think the problem, but I am not sure, is in: levels.each(function(){ levelCsv.push(this.value);//array to hold the levels }); I changed everything else. I updated my example:http://www.27lamps.com/Beta/List/List3.html Other problem I notice is that when two levels are added the word e is not added between the both. Only when 3 levels are added. On my first example I had a function that was doing it:http://www.27lamps.com/Beta/List/List.html I just don't know how to integrate this on your code. I don't need to use my FriendlyLevels example. I just need to have the e every time there is more then 1 level. How can I do it? Thank You, Miguel - The subject is working fine. - On Feb 20, 1:50 am, mkmanning michaell...@gmail.com wrote: You could modify the subject variable being put into the array to make it an object: subject = {} then add the option's value and text to it: subject.value = $('#Subject option:selected').val(); subject.text = $('#Subject option:selected').text(); or in one line to replace what's there now: subject = {'text':$('#Subject option:selected').text(),'value':$ ('#Subject option:selected').val()} then put it in the array the same way: temptheme.push(subject) To access it later when rebuilding just get the attributes of the object: var li = $('li').addClass('Themes').html(t[0].text+'br /' etc... for the display $('input').attr({'type':'hidden','name':'Themes['+i+'].Subject'}).val (t[0].value).appendTo(li); etc for the value Use the same object structure for storing the checkbox names/values On Feb 19, 4:36 pm, shapper mdmo...@gmail.com wrote: Hi Michaell, Sorry for the delay but when I started using JQuery 1.3 I solved this problem but I got a few others on my application. Anyway, there is just something else that I am not able to solve. When I add a theme I need to: 1. For the Select (Subject), add the selected value to hidden input but the text to the visible text. 2. For the CheckBoxes (Levels) add LevelsCsv (formed with values) to the hidden inputs. But the visible text should use the text in the labels associated to which check box ... I had something like that in my code
[jQuery] Re: Order Items. Please help me. Thank You.
@Michael, I just installed Firebug and I almost made this working. The only problem I have is when I am adding the levels to the list as html and as hidden input: +friendlyLevels(t[1].text.join(', '))+'br /' $('input').attr({'type':'hidden','name':'Themes['+i +'].LevelCsv'}).val(t[1].value.join()).appendTo(li); I get an error in Firebug: t[1].text is undefined [Break on this error] +friendlyLevels(t[1].text.join(', '))+'br /' But as far as I know to get the text and value I use .text and .value. My friendlyLevels function is function friendlyLevels(levels) { if (levels.length 2) return levels.join(''); var first = levels.slice(0, -1), last = levels.slice(-1); var friendly = first.join(', '); if (last) { friendly += ' e ' + last; } return friendly; } I am trying to display a join of the values in the hidden input and a join of the texts in the html but using friendlyLevels or anything similar to add the e at the end. I removed your code just because it was adding the e only for 3 items and using a function makes the code less confusing. I updated my code in: http://www.27lamps.com/Beta/List/List5.html I plan to optimize my code but first I would like to make it work so I can optimize it step by step. @seasoup I didn't forgot the problems you mentioned about using [] ... But what would you suggest to replace []? I can post the suggestion on ASP.NET MVC forums where I participate on a daily basis. I am using Microsoft ASP.NET MVC which gives me complete control of the HTML but still allows me to use C# and SQL. Microsoft ASP.NET MVC ships now with JQuery since there was a partnership created between JQuery creators and Microsoft. This is the reason why I am starting with JQuery but I am still learning ... but until now it seams great. Thanks, Miguel http://www.27lamps.com/Beta/List/List5.html On Feb 24, 4:57 pm, mkmanning michaell...@gmail.com wrote: Creating a complete html string won't solve the current problem; it is faster, and usually the way I prefer doing it also (see my note further below though), but as I indicated in a code comment, since this appears to be based on user input, the list (hopefully) won't be very big, so the speed gain probably isn't appreciable. @Shapper - get Firebug and use Firefox for debugging, it will tell you immediately that you have an error in your code: you define levelCsv = [] but then use levelsCsv for the array.push() Once you get it working you can try seasoups suggestion for a speed improvement if you like (or simply for your own edification); it will definitely benefit you in future if you work with larger lists or blocks of html. An even more important performance gain can be had by not doing string concatenation (I put a caveat about this in the code comment's also), but build an array of your html and then join the array; it's siginficantly faster. Check the forum and you'll see examples of this. On Feb 24, 8:23 am, seasoup seas...@gmail.com wrote: Hi Miguel, not sure if it will solve your problem, but I find it is much faster to create a complete html string and then append it instead of doing lots of appends, which are slow. //this handles the li content var li = $('li').addClass('Themes').html(t[0].text+'br /' +friendlyLevels(t[1])+'br /' +(t[2]==''?'':t[2]+'br /') +'a href=#Remove class=RemoveRemove/a' ).appendTo(ol); //now the inputs, this could also be done in another loop with an array of names, if it gets longer; and the brackets in the name are still a bad idea $('input').attr({'type':'hidden','name':'Themes['+i +'].Subject'}).val(t[0].value).appendTo(li); $('input').attr({'type':'hidden','name':'Themes['+i +'].LevelCsv'}).val(t[1].join()).appendTo(li); $('input').attr({'type':'hidden','name':'Themes['+i +'].Note'}).val(t[2]).appendTo(li); is faster as var html = 'li class=Themes + t[0].text + br / + friendlyLevels (t[1]) + 'br /' + (t[2]==''?'':t[2]+'br /') + 'a href=#Remove class=RemoveRemove/a + 'input type=hidden name=Themes[' + i + '].Subject value=' + t [0].value + ' + 'input type=hidden name=Themes[' + i + '].LevelCsv value=' + t[1].join() + ' + 'input type=hidden name=Themes[' + i + '].Note value=' + t [2].value + '; $(ol).append(html); // or $(html).appendTo(ol); On Feb 24, 7:33 am, shapper mdmo...@gmail.com wrote: Hi, I think I did that ... I have this example working with Subjects and FriendlyLevels function to add the e correctly:http://www.27lamps.com/Beta/List/List4.html Then I tried to do the same but for levels:http://www
[jQuery] Re: CheckBox - Select and Deselect
Basically I have 8 roles. I need to be able to select one or many. However in 4 of them one can only be selected. I could separate it but since it's all for the same thing ... ... this is why I am not using radio .. I need to be able to select more than one. It is working Thank You, Miguel On Feb 23, 9:38 pm, MorningZ morni...@gmail.com wrote: Easier/makes-more-sense: - Why not use a radio box group then? Otherwise: - Using jQuery to mimic functionality w/ CheckBox input type=checkbox id=A / input type=checkbox id=B / input type=checkbox id=C / input type=checkbox id=D / $(document).ready(function() { $(#A, #B, #C, #D).change(function() { var ThisID = this.id; $(#A, #B, #C, #D).each(function() { if (this.id != ThisID) { this.checked = false; } }) }); }) On Feb 23, 4:18 pm, shapper mdmo...@gmail.com wrote: Hello, I have 8 inputs of type checkbox. On 4 of them (A, B, C and D) I want to deselect the other three when one is selected. For example, if I select A I want B, C and D to be deselected. If I select C I want A, B and D to be deselected. Is it possible to create this functionality? Thanks, Miguel
[jQuery] JQuery Events
Hello, I have the following: $('#Professor').click(function(){ if ( this.checked ) { $('#ProfessorField').show(); $('#SubscriptionsField').show(); } else { $('#ProfessorField').hide(); $('#SubscriptionsField').hide(); } }) Basically on a form I am hiding/showing a few fieldsets when a checkbox is selected or unselected. However, when I submit the form and there are errors, the page is displayed again with the error messages. The problem is that the fields get visible independently of the checkbox Professor value. I don't know why ... So I added the following: $('#Professor').load(function(){ if ( this.checked ) { $('#ProfessorField').show(); $('#SubscriptionsField').show(); } else { $('#ProfessorField').hide(); $('#SubscriptionsField').hide(); } }) Still does not work ... any idea why? And since the code is the same can't I join the two events? Thanks, Miguel
[jQuery] Re: Order Items. Please help me. Thank You.
Hello, I tried to make the change: levels.each(function(){ levelsCsv.push({'text':this.value,'value':$(this).next().text()}) }) But I get an error on Firebug: levels.each is not a function Am I doing something wrong? I also made a change on buildThemesList to use text and also to fix the problem on your code that adds e only when there are 3 items. It should be also applied when there are 2: $.each(themes,function(i,t){ var li = $('li').addClass('Themes').html(t[0].text+'br /' +friendlyLevels(t[1].text)+'br /' +(t[2]==''?'':t[2]+'br /') +'a href=#Remove class=RemoveRemover/a' ).appendTo(ol); function friendlyLevels(levels) { if (levels.length 2) return levels.join(''); var first = levels.slice(0, -1), last = levels.slice(-1); var friendly = first.join(', '); if (last) { friendly += ' e ' + last; } return friendly; } I am not completely sure that I am doing this right because I get the error before. Thank You, Miguel On Feb 20, 5:02 pm, mkmanning michaell...@gmail.com wrote: levels.text = $('input[name=Levels]:checked + label'); levels.value = $('input[name=Levels]:checked'); Those don't get you the right values for the levels object, they both return a jQuery object. Accessing the levels object as this.value won't work either. Try this: levels.each(function(){ levelsCsv.push({'text':this.value,'value':$(this).next().text()}) }) On Feb 20, 5:22 am, shapper mdmo...@gmail.com wrote: Hi, I followed your tips but I still have a few problems. The subject is working fine but when I do the same to the levels it does not work. I think the problem, but I am not sure, is in: levels.each(function(){ levelCsv.push(this.value);//array to hold the levels }); I changed everything else. I updated my example:http://www.27lamps.com/Beta/List/List3.html Other problem I notice is that when two levels are added the word e is not added between the both. Only when 3 levels are added. On my first example I had a function that was doing it:http://www.27lamps.com/Beta/List/List.html I just don't know how to integrate this on your code. I don't need to use my FriendlyLevels example. I just need to have the e every time there is more then 1 level. How can I do it? Thank You, Miguel - The subject is working fine. - On Feb 20, 1:50 am, mkmanning michaell...@gmail.com wrote: You could modify the subject variable being put into the array to make it an object: subject = {} then add the option's value and text to it: subject.value = $('#Subject option:selected').val(); subject.text = $('#Subject option:selected').text(); or in one line to replace what's there now: subject = {'text':$('#Subject option:selected').text(),'value':$ ('#Subject option:selected').val()} then put it in the array the same way: temptheme.push(subject) To access it later when rebuilding just get the attributes of the object: var li = $('li').addClass('Themes').html(t[0].text+'br /' etc... for the display $('input').attr({'type':'hidden','name':'Themes['+i+'].Subject'}).val (t[0].value).appendTo(li); etc for the value Use the same object structure for storing the checkbox names/values On Feb 19, 4:36 pm, shapper mdmo...@gmail.com wrote: Hi Michaell, Sorry for the delay but when I started using JQuery 1.3 I solved this problem but I got a few others on my application. Anyway, there is just something else that I am not able to solve. When I add a theme I need to: 1. For the Select (Subject), add the selected value to hidden input but the text to the visible text. 2. For the CheckBoxes (Levels) add LevelsCsv (formed with values) to the hidden inputs. But the visible text should use the text in the labels associated to which check box ... I had something like that in my code: 1. For the subject I add something like: $subject = $('#Subject option:selected'); $theme.append($subject.text()).append('br /'); And on the hidden input I was using $subject.val() 2. For the levels I was using: $levelsTexts = $('input[name=Levels]:checked + label'); $levelsValues = $('input[name=Levels]:checked'); So the text goes into the visible part of the theme and the value goes to the hidden inputs. See? I have been trying to add this to your code but I haven't be able. I added a new version of the List where the values and texts are different in the Select. And where each CheckBox has the associated label with the text in it. http://www.27lamps.com/Beta/List/List3.html Could you, please, help me out? Thank You, Miguel On Feb 18, 5:33 pm, mkmanning michaell...@gmail.com wrote: The problem is with the version of jQuery you're using. Update
[jQuery] Re: Order Items. Please help me. Thank You.
P.S: I updated my example as usually: http://www.27lamps.com/Beta/List/List3.html On Feb 20, 5:02 pm, mkmanning michaell...@gmail.com wrote: levels.text = $('input[name=Levels]:checked + label'); levels.value = $('input[name=Levels]:checked'); Those don't get you the right values for the levels object, they both return a jQuery object. Accessing the levels object as this.value won't work either. Try this: levels.each(function(){ levelsCsv.push({'text':this.value,'value':$(this).next().text()}) }) On Feb 20, 5:22 am, shapper mdmo...@gmail.com wrote: Hi, I followed your tips but I still have a few problems. The subject is working fine but when I do the same to the levels it does not work. I think the problem, but I am not sure, is in: levels.each(function(){ levelCsv.push(this.value);//array to hold the levels }); I changed everything else. I updated my example:http://www.27lamps.com/Beta/List/List3.html Other problem I notice is that when two levels are added the word e is not added between the both. Only when 3 levels are added. On my first example I had a function that was doing it:http://www.27lamps.com/Beta/List/List.html I just don't know how to integrate this on your code. I don't need to use my FriendlyLevels example. I just need to have the e every time there is more then 1 level. How can I do it? Thank You, Miguel - The subject is working fine. - On Feb 20, 1:50 am, mkmanning michaell...@gmail.com wrote: You could modify the subject variable being put into the array to make it an object: subject = {} then add the option's value and text to it: subject.value = $('#Subject option:selected').val(); subject.text = $('#Subject option:selected').text(); or in one line to replace what's there now: subject = {'text':$('#Subject option:selected').text(),'value':$ ('#Subject option:selected').val()} then put it in the array the same way: temptheme.push(subject) To access it later when rebuilding just get the attributes of the object: var li = $('li').addClass('Themes').html(t[0].text+'br /' etc... for the display $('input').attr({'type':'hidden','name':'Themes['+i+'].Subject'}).val (t[0].value).appendTo(li); etc for the value Use the same object structure for storing the checkbox names/values On Feb 19, 4:36 pm, shapper mdmo...@gmail.com wrote: Hi Michaell, Sorry for the delay but when I started using JQuery 1.3 I solved this problem but I got a few others on my application. Anyway, there is just something else that I am not able to solve. When I add a theme I need to: 1. For the Select (Subject), add the selected value to hidden input but the text to the visible text. 2. For the CheckBoxes (Levels) add LevelsCsv (formed with values) to the hidden inputs. But the visible text should use the text in the labels associated to which check box ... I had something like that in my code: 1. For the subject I add something like: $subject = $('#Subject option:selected'); $theme.append($subject.text()).append('br /'); And on the hidden input I was using $subject.val() 2. For the levels I was using: $levelsTexts = $('input[name=Levels]:checked + label'); $levelsValues = $('input[name=Levels]:checked'); So the text goes into the visible part of the theme and the value goes to the hidden inputs. See? I have been trying to add this to your code but I haven't be able. I added a new version of the List where the values and texts are different in the Select. And where each CheckBox has the associated label with the text in it. http://www.27lamps.com/Beta/List/List3.html Could you, please, help me out? Thank You, Miguel On Feb 18, 5:33 pm, mkmanning michaell...@gmail.com wrote: The problem is with the version of jQuery you're using. Update to 1.3 (and don't include a space in the URI). Try your code with the Google js api and it will work (I just did, even with the duplicate jQuery wrapper functions). On Feb 18, 9:28 am, shapper mdmo...@gmail.com wrote: Yes, I tried that to but the problem persists. I updated the new version:http://www.27lamps.com/Beta/List/List2.html I am able to add 1 theme to the list ... Then all the other themes I add are not added to the list ... But I think they are being added to the themes array. The index also does not change ... ... But the index input is on the Html code. I just can't find the problem. Thanks, Miguel On Feb 18, 5:21 pm, mkmanning michaell...@gmail.com wrote: if you're using the ready function, remove the inner (function($) { ... })(jQuery); wrapper On Feb 18, 9:13 am, shapper mdmo...@gmail.com wrote: Hi, I would like
[jQuery] CheckBox - Select and Deselect
Hello, I have 8 inputs of type checkbox. On 4 of them (A, B, C and D) I want to deselect the other three when one is selected. For example, if I select A I want B, C and D to be deselected. If I select C I want A, B and D to be deselected. Is it possible to create this functionality? Thanks, Miguel
[jQuery] Re: Order Items. Please help me. Thank You.
Hi, I followed your tips but I still have a few problems. The subject is working fine but when I do the same to the levels it does not work. I think the problem, but I am not sure, is in: levels.each(function(){ levelCsv.push(this.value);//array to hold the levels }); I changed everything else. I updated my example: http://www.27lamps.com/Beta/List/List3.html Other problem I notice is that when two levels are added the word e is not added between the both. Only when 3 levels are added. On my first example I had a function that was doing it: http://www.27lamps.com/Beta/List/List.html I just don't know how to integrate this on your code. I don't need to use my FriendlyLevels example. I just need to have the e every time there is more then 1 level. How can I do it? Thank You, Miguel - The subject is working fine. - On Feb 20, 1:50 am, mkmanning michaell...@gmail.com wrote: You could modify the subject variable being put into the array to make it an object: subject = {} then add the option's value and text to it: subject.value = $('#Subject option:selected').val(); subject.text = $('#Subject option:selected').text(); or in one line to replace what's there now: subject = {'text':$('#Subject option:selected').text(),'value':$ ('#Subject option:selected').val()} then put it in the array the same way: temptheme.push(subject) To access it later when rebuilding just get the attributes of the object: var li = $('li').addClass('Themes').html(t[0].text+'br /' etc... for the display $('input').attr({'type':'hidden','name':'Themes['+i+'].Subject'}).val (t[0].value).appendTo(li); etc for the value Use the same object structure for storing the checkbox names/values On Feb 19, 4:36 pm, shapper mdmo...@gmail.com wrote: Hi Michaell, Sorry for the delay but when I started using JQuery 1.3 I solved this problem but I got a few others on my application. Anyway, there is just something else that I am not able to solve. When I add a theme I need to: 1. For the Select (Subject), add the selected value to hidden input but the text to the visible text. 2. For the CheckBoxes (Levels) add LevelsCsv (formed with values) to the hidden inputs. But the visible text should use the text in the labels associated to which check box ... I had something like that in my code: 1. For the subject I add something like: $subject = $('#Subject option:selected'); $theme.append($subject.text()).append('br /'); And on the hidden input I was using $subject.val() 2. For the levels I was using: $levelsTexts = $('input[name=Levels]:checked + label'); $levelsValues = $('input[name=Levels]:checked'); So the text goes into the visible part of the theme and the value goes to the hidden inputs. See? I have been trying to add this to your code but I haven't be able. I added a new version of the List where the values and texts are different in the Select. And where each CheckBox has the associated label with the text in it. http://www.27lamps.com/Beta/List/List3.html Could you, please, help me out? Thank You, Miguel On Feb 18, 5:33 pm, mkmanning michaell...@gmail.com wrote: The problem is with the version of jQuery you're using. Update to 1.3 (and don't include a space in the URI). Try your code with the Google js api and it will work (I just did, even with the duplicate jQuery wrapper functions). On Feb 18, 9:28 am, shapper mdmo...@gmail.com wrote: Yes, I tried that to but the problem persists. I updated the new version:http://www.27lamps.com/Beta/List/List2.html I am able to add 1 theme to the list ... Then all the other themes I add are not added to the list ... But I think they are being added to the themes array. The index also does not change ... ... But the index input is on the Html code. I just can't find the problem. Thanks, Miguel On Feb 18, 5:21 pm, mkmanning michaell...@gmail.com wrote: if you're using the ready function, remove the inner (function($) { ... })(jQuery); wrapper On Feb 18, 9:13 am, shapper mdmo...@gmail.com wrote: Hi, I would like to include the script on the head of the document and using an external JS file. So I inserted it inside the Document.Ready function. I upload a new example showing the problem I have: http://www.27lamps.com/Beta/List/List2.html In this example I didn't use the external JS file. However I placed the code inside the Document.Ready and on the head of the document. When I use the external JS file I copy it just like that to the file and add the include. Anyway, try to add a theme. The first is added but the second not. Or better, I think it is added to the list but not to the page ... Could you tell me what am I doing wrong? Thanks, Miguel On Feb 18, 4:49 pm
[jQuery] Re: Order Items. Please help me. Thank You.
Hi Michaell, Sorry for the delay but when I started using JQuery 1.3 I solved this problem but I got a few others on my application. Anyway, there is just something else that I am not able to solve. When I add a theme I need to: 1. For the Select (Subject), add the selected value to hidden input but the text to the visible text. 2. For the CheckBoxes (Levels) add LevelsCsv (formed with values) to the hidden inputs. But the visible text should use the text in the labels associated to which check box ... I had something like that in my code: 1. For the subject I add something like: $subject = $('#Subject option:selected'); $theme.append($subject.text()).append('br /'); And on the hidden input I was using $subject.val() 2. For the levels I was using: $levelsTexts = $('input[name=Levels]:checked + label'); $levelsValues = $('input[name=Levels]:checked'); So the text goes into the visible part of the theme and the value goes to the hidden inputs. See? I have been trying to add this to your code but I haven't be able. I added a new version of the List where the values and texts are different in the Select. And where each CheckBox has the associated label with the text in it. http://www.27lamps.com/Beta/List/List3.html Could you, please, help me out? Thank You, Miguel On Feb 18, 5:33 pm, mkmanning michaell...@gmail.com wrote: The problem is with the version of jQuery you're using. Update to 1.3 (and don't include a space in the URI). Try your code with the Google js api and it will work (I just did, even with the duplicate jQuery wrapper functions). On Feb 18, 9:28 am, shapper mdmo...@gmail.com wrote: Yes, I tried that to but the problem persists. I updated the new version:http://www.27lamps.com/Beta/List/List2.html I am able to add 1 theme to the list ... Then all the other themes I add are not added to the list ... But I think they are being added to the themes array. The index also does not change ... ... But the index input is on the Html code. I just can't find the problem. Thanks, Miguel On Feb 18, 5:21 pm, mkmanning michaell...@gmail.com wrote: if you're using the ready function, remove the inner (function($) { ... })(jQuery); wrapper On Feb 18, 9:13 am, shapper mdmo...@gmail.com wrote: Hi, I would like to include the script on the head of the document and using an external JS file. So I inserted it inside the Document.Ready function. I upload a new example showing the problem I have: http://www.27lamps.com/Beta/List/List2.html In this example I didn't use the external JS file. However I placed the code inside the Document.Ready and on the head of the document. When I use the external JS file I copy it just like that to the file and add the include. Anyway, try to add a theme. The first is added but the second not. Or better, I think it is added to the list but not to the page ... Could you tell me what am I doing wrong? Thanks, Miguel On Feb 18, 4:49 pm, mkmanning michaell...@gmail.com wrote: Scripts block other assets from downloading, so the most appropriate place for them (most of the time), is at the close of the body. This allows your page to render, and then allows you to add behavior as progressive enhancement. It's generally good practice; Google progressive enhancement/graceful degradation for more on this. You can still include your script, just include it at the close of the body. Wrap it in a domready function if you like, I usually do that; one consequence of including your scripts at the end of the page is the DOM has been rendered already--which is why mine works :). If you want to keep the script external AND in the head, then you'll have to wrap the code in a domready function. On Feb 18, 8:25 am, shapper mdmo...@gmail.com wrote: Hi, I was trying to integrate your code on my web application and the following happens: I am able to add a theme. But when I try to add a second theme I get the following error: [Exception... 'type property can't be changed' when calling method: [nsIDOMEventListener::handleEvent] nsresult: 0x8057001e (NS_ERROR_XPC_JS_THREW_STRING) location: unknown data: no] data()()JQuery-1.2.6.js (line 696) remove()()JQuery-1.2.6.js (line 1929) (?)()()JQuery-1.2.6.js (line 1330) each()()JQuery-1.2.6.js (line 762) each()()JQuery-1.2.6.js (line 155) remove()()JQuery-1.2.6.js (line 1329) each()()JQuery-1.2.6.js (line 751) each()()JQuery-1.2.6.js (line 155) (?)()()JQuery-1.2.6.js (line 1348) (?)()()JQuery.L...-1.0.3.js (line 178) empty()()JQuery-1.2.6.js (line 1340) each()()JQuery-1.2.6.js (line 751) each()()JQuery-1.2.6.js (line 155) (?)()()JQuery-1.2.6.js (line 1348) (?)()()JQuery.L...-1.0.3.js (line 178
[jQuery] Hide/Show when Check Box is selected
Hello, On a form how can I Show a fieldset when a checkbox is Selected and Hide the same fieldset when the same checkbox is unselected? Thanks, Miguel
[jQuery] Re: Order Items. Please help me. Thank You.
UI $('#Index').val(themes.length); } })(jQuery); Also, syntax like var valid = new Boolean(true); can just be var valid = true; Hope this gives you some ideas; I'll leave it to you to optimize (or ignore) it :) On Feb 17, 10:03 pm, Ricardo Tomasi ricardob...@gmail.com wrote: That's because you have that empty li style=display:none/li. Is it really necessary? just decrement the index to start at 0: $('#Themes li').each(function(index){ index--; $('input:hidden', this).each(function(){ var fixName = $(this).attr('name').replace(/\[\d\]/, '['+index +']'); $(this).attr('name', fixName); }); }); cheers, - ricardo On Feb 17, 10:56 pm, shapper mdmo...@gmail.com wrote: I added an input which shows the number of items in the list ... The problem is that I am not able to reorder the list so it is 0 based ... Any idea? Thanks, Miguel On Feb 18, 1:48 am, shapper mdmo...@gmail.com wrote: I have been trying to make this work but no success ... ... in fact the inputs get undefined. I am not sure if I am using your function on the right way. The function should be called, I think, after adding or removing an item to reorder the ids. Anyway, I created an example:http://www.27lamps.com/Beta/List/List.html Please, not that you have to select a subject and at least one level to add it to the list. Could someone, please, help me out with this? Basically, every time I add or remove an item I need to reorder the names of the input fields. Please check my original message on this post. It explains the situation. Thanks, Miguel On Feb 12, 4:36 am, Ricardo Tomasi ricardob...@gmail.com wrote: Probably not the most efficient function, but should work: $('#ThemesList li').each(function(index){ $('input:hidden', this).each(function(){ var fixName = $(this).attr('name').replace(/\[\d\]/, '['+index +']'); $(this).attr('name', fixName); }); }); - ricardo On Feb 11, 7:19 pm, shapper mdmo...@gmail.com wrote: Hello, I am adding and removing a items from a list, using JQuery, which is rendered has follows: ol id=ThemesList li input type=hidden name=Themes[0].Subject value=A / input type=hidden name=Themes[0].Levels value=L1,L2 / input type=hidden name=Themes[0].Description value=Paper / /li li input type=hidden name=Themes[2].Subject value=B / input type=hidden name=Themes[2].Levels value=L1,L5 / /li li input type=hidden name=Themes[5].Subject value=D / input type=hidden name=Themes[5].Levels value=L2,L4 / input type=hidden name=Themes[5].Description value=Book / /li /ol Every time I add or remove a Theme I need to be sure that the list is ordered (name) starting with Themes[0]. So basically I need to loop through each list item in list ThemesList. - In first list item all HIDDEN inputs names should start with Themes [0] - In second list item all HIDDEN inputs names should start with Themes [1] ... So in this example, Themes[2]. ... would become Themes[1]. ... and Themes[5]. ... would become Themes[2]. ... Could someone please help me out? I have no idea how to do this. Thanks, Miguel
[jQuery] Re: Order Items. Please help me. Thank You.
Hi, I would like to include the script on the head of the document and using an external JS file. So I inserted it inside the Document.Ready function. I upload a new example showing the problem I have: http://www.27lamps.com/Beta/List/List2.html In this example I didn't use the external JS file. However I placed the code inside the Document.Ready and on the head of the document. When I use the external JS file I copy it just like that to the file and add the include. Anyway, try to add a theme. The first is added but the second not. Or better, I think it is added to the list but not to the page ... Could you tell me what am I doing wrong? Thanks, Miguel On Feb 18, 4:49 pm, mkmanning michaell...@gmail.com wrote: Scripts block other assets from downloading, so the most appropriate place for them (most of the time), is at the close of the body. This allows your page to render, and then allows you to add behavior as progressive enhancement. It's generally good practice; Google progressive enhancement/graceful degradation for more on this. You can still include your script, just include it at the close of the body. Wrap it in a domready function if you like, I usually do that; one consequence of including your scripts at the end of the page is the DOM has been rendered already--which is why mine works :). If you want to keep the script external AND in the head, then you'll have to wrap the code in a domready function. On Feb 18, 8:25 am, shapper mdmo...@gmail.com wrote: Hi, I was trying to integrate your code on my web application and the following happens: I am able to add a theme. But when I try to add a second theme I get the following error: [Exception... 'type property can't be changed' when calling method: [nsIDOMEventListener::handleEvent] nsresult: 0x8057001e (NS_ERROR_XPC_JS_THREW_STRING) location: unknown data: no] data()()JQuery-1.2.6.js (line 696) remove()()JQuery-1.2.6.js (line 1929) (?)()()JQuery-1.2.6.js (line 1330) each()()JQuery-1.2.6.js (line 762) each()()JQuery-1.2.6.js (line 155) remove()()JQuery-1.2.6.js (line 1329) each()()JQuery-1.2.6.js (line 751) each()()JQuery-1.2.6.js (line 155) (?)()()JQuery-1.2.6.js (line 1348) (?)()()JQuery.L...-1.0.3.js (line 178) empty()()JQuery-1.2.6.js (line 1340) each()()JQuery-1.2.6.js (line 751) each()()JQuery-1.2.6.js (line 155) (?)()()JQuery-1.2.6.js (line 1348) (?)()()JQuery.L...-1.0.3.js (line 178) buildThemesList()Create (line 453) (?)()()Create (line 450) handle()()JQuery-1.2.6.js (line 2093) (?)()()JQuery-1.2.6.js (line 1875) [Break on this error] jQuery.cache[ id ][ name ] : Any idea why? And a few questions: 1. Shouldn't I place the code inside Document.Ready? I followed your example and didn't place it inside it but I don't understand why ... 2. Why do you place the script after the body? I am placing the script inside a js file and then I include it in the head of the document. Thanks, Miguel On Feb 18, 7:13 am, mkmanning michaell...@gmail.com wrote: Here's a wholly different approach for consideration. Rather than try and keep track of LI elements and regex their names with the current index, just use an array placeholder and rebuild the list. Chances are if the user is required to add items, the list isn't going to get unmanageably huge (at least I'd hope not from a usability standpoint). Below is a refactored example, and you can see it live here:http://actingthemaggot.com/test/add_theme.html Refactored (uses markup fromhttp://www.27lamps.com/Beta/List/List.html): (function($) { var themes = [], //this will be an array of arrays to keep track, we can use its indexing to rebuild the themes list, and it can be serialized if we want to post the data ol = $('#Themes').bind('click',function(e){//event delegation for removing themes, livequery's fine, but this works too e = $(e.target); if(e.is('a')){ var li_index = $(this).children('li').index(e.parents('li')); themes =$.grep(themes, function(n,i){ return (i != li_index); }); buildThemesList(); } return false; }); //Add theme $('#AddTheme').click(function(){ var levels = $('input:checkbox:checked'), subject = $('#Subject').val (), temptheme = []; //validate before we go any further to avoid unnecessary operations if(levels.length==0 || subject == ''){ return false; } //process subject temptheme.push(subject); //process levels var levelCsv = []; //array to hold the levels
[jQuery] Re: Order Items. Please help me. Thank You.
Yes, I tried that to but the problem persists. I updated the new version: http://www.27lamps.com/Beta/List/List2.html I am able to add 1 theme to the list ... Then all the other themes I add are not added to the list ... But I think they are being added to the themes array. The index also does not change ... ... But the index input is on the Html code. I just can't find the problem. Thanks, Miguel On Feb 18, 5:21 pm, mkmanning michaell...@gmail.com wrote: if you're using the ready function, remove the inner (function($) { ... })(jQuery); wrapper On Feb 18, 9:13 am, shapper mdmo...@gmail.com wrote: Hi, I would like to include the script on the head of the document and using an external JS file. So I inserted it inside the Document.Ready function. I upload a new example showing the problem I have: http://www.27lamps.com/Beta/List/List2.html In this example I didn't use the external JS file. However I placed the code inside the Document.Ready and on the head of the document. When I use the external JS file I copy it just like that to the file and add the include. Anyway, try to add a theme. The first is added but the second not. Or better, I think it is added to the list but not to the page ... Could you tell me what am I doing wrong? Thanks, Miguel On Feb 18, 4:49 pm, mkmanning michaell...@gmail.com wrote: Scripts block other assets from downloading, so the most appropriate place for them (most of the time), is at the close of the body. This allows your page to render, and then allows you to add behavior as progressive enhancement. It's generally good practice; Google progressive enhancement/graceful degradation for more on this. You can still include your script, just include it at the close of the body. Wrap it in a domready function if you like, I usually do that; one consequence of including your scripts at the end of the page is the DOM has been rendered already--which is why mine works :). If you want to keep the script external AND in the head, then you'll have to wrap the code in a domready function. On Feb 18, 8:25 am, shapper mdmo...@gmail.com wrote: Hi, I was trying to integrate your code on my web application and the following happens: I am able to add a theme. But when I try to add a second theme I get the following error: [Exception... 'type property can't be changed' when calling method: [nsIDOMEventListener::handleEvent] nsresult: 0x8057001e (NS_ERROR_XPC_JS_THREW_STRING) location: unknown data: no] data()()JQuery-1.2.6.js (line 696) remove()()JQuery-1.2.6.js (line 1929) (?)()()JQuery-1.2.6.js (line 1330) each()()JQuery-1.2.6.js (line 762) each()()JQuery-1.2.6.js (line 155) remove()()JQuery-1.2.6.js (line 1329) each()()JQuery-1.2.6.js (line 751) each()()JQuery-1.2.6.js (line 155) (?)()()JQuery-1.2.6.js (line 1348) (?)()()JQuery.L...-1.0.3.js (line 178) empty()()JQuery-1.2.6.js (line 1340) each()()JQuery-1.2.6.js (line 751) each()()JQuery-1.2.6.js (line 155) (?)()()JQuery-1.2.6.js (line 1348) (?)()()JQuery.L...-1.0.3.js (line 178) buildThemesList()Create (line 453) (?)()()Create (line 450) handle()()JQuery-1.2.6.js (line 2093) (?)()()JQuery-1.2.6.js (line 1875) [Break on this error] jQuery.cache[ id ][ name ] : Any idea why? And a few questions: 1. Shouldn't I place the code inside Document.Ready? I followed your example and didn't place it inside it but I don't understand why ... 2. Why do you place the script after the body? I am placing the script inside a js file and then I include it in the head of the document. Thanks, Miguel On Feb 18, 7:13 am, mkmanning michaell...@gmail.com wrote: Here's a wholly different approach for consideration. Rather than try and keep track of LI elements and regex their names with the current index, just use an array placeholder and rebuild the list. Chances are if the user is required to add items, the list isn't going to get unmanageably huge (at least I'd hope not from a usability standpoint). Below is a refactored example, and you can see it live here:http://actingthemaggot.com/test/add_theme.html Refactored (uses markup fromhttp://www.27lamps.com/Beta/List/List.html): (function($) { var themes = [], //this will be an array of arrays to keep track, we can use its indexing to rebuild the themes list, and it can be serialized if we want to post the data ol = $('#Themes').bind('click',function(e){//event delegation for removing themes, livequery's fine, but this works too e = $(e.target); if(e.is('a')){ var li_index = $(this).children('li').index(e.parents('li')); themes =$.grep(themes
[jQuery] Select Box. Anyone?
Hello, I am looking for a Select Box replacement so I can style an HTML Select. I need something that works across browsers. Something like this is very common on other frameworks but I haven't found anything for JQuery. Could someone, please, suggest me one? Thanks, Miguel
[jQuery] Re: Order Items. Please help me. Thank You.
I have been trying to make this work but no success ... ... in fact the inputs get undefined. I am not sure if I am using your function on the right way. The function should be called, I think, after adding or removing an item to reorder the ids. Anyway, I created an example: http://www.27lamps.com/Beta/List/List.html Please, not that you have to select a subject and at least one level to add it to the list. Could someone, please, help me out with this? Basically, every time I add or remove an item I need to reorder the names of the input fields. Please check my original message on this post. It explains the situation. Thanks, Miguel On Feb 12, 4:36 am, Ricardo Tomasi ricardob...@gmail.com wrote: Probably not the most efficient function, but should work: $('#ThemesList li').each(function(index){ $('input:hidden', this).each(function(){ var fixName = $(this).attr('name').replace(/\[\d\]/, '['+index +']'); $(this).attr('name', fixName); }); }); - ricardo On Feb 11, 7:19 pm, shapper mdmo...@gmail.com wrote: Hello, I am adding and removing a items from a list, using JQuery, which is rendered has follows: ol id=ThemesList li input type=hidden name=Themes[0].Subject value=A / input type=hidden name=Themes[0].Levels value=L1,L2 / input type=hidden name=Themes[0].Description value=Paper / /li li input type=hidden name=Themes[2].Subject value=B / input type=hidden name=Themes[2].Levels value=L1,L5 / /li li input type=hidden name=Themes[5].Subject value=D / input type=hidden name=Themes[5].Levels value=L2,L4 / input type=hidden name=Themes[5].Description value=Book / /li /ol Every time I add or remove a Theme I need to be sure that the list is ordered (name) starting with Themes[0]. So basically I need to loop through each list item in list ThemesList. - In first list item all HIDDEN inputs names should start with Themes [0] - In second list item all HIDDEN inputs names should start with Themes [1] ... So in this example, Themes[2]. ... would become Themes[1]. ... and Themes[5]. ... would become Themes[2]. ... Could someone please help me out? I have no idea how to do this. Thanks, Miguel
[jQuery] Re: Order Items. Please help me. Thank You.
I added an input which shows the number of items in the list ... The problem is that I am not able to reorder the list so it is 0 based ... Any idea? Thanks, Miguel On Feb 18, 1:48 am, shapper mdmo...@gmail.com wrote: I have been trying to make this work but no success ... ... in fact the inputs get undefined. I am not sure if I am using your function on the right way. The function should be called, I think, after adding or removing an item to reorder the ids. Anyway, I created an example:http://www.27lamps.com/Beta/List/List.html Please, not that you have to select a subject and at least one level to add it to the list. Could someone, please, help me out with this? Basically, every time I add or remove an item I need to reorder the names of the input fields. Please check my original message on this post. It explains the situation. Thanks, Miguel On Feb 12, 4:36 am, Ricardo Tomasi ricardob...@gmail.com wrote: Probably not the most efficient function, but should work: $('#ThemesList li').each(function(index){ $('input:hidden', this).each(function(){ var fixName = $(this).attr('name').replace(/\[\d\]/, '['+index +']'); $(this).attr('name', fixName); }); }); - ricardo On Feb 11, 7:19 pm, shapper mdmo...@gmail.com wrote: Hello, I am adding and removing a items from a list, using JQuery, which is rendered has follows: ol id=ThemesList li input type=hidden name=Themes[0].Subject value=A / input type=hidden name=Themes[0].Levels value=L1,L2 / input type=hidden name=Themes[0].Description value=Paper / /li li input type=hidden name=Themes[2].Subject value=B / input type=hidden name=Themes[2].Levels value=L1,L5 / /li li input type=hidden name=Themes[5].Subject value=D / input type=hidden name=Themes[5].Levels value=L2,L4 / input type=hidden name=Themes[5].Description value=Book / /li /ol Every time I add or remove a Theme I need to be sure that the list is ordered (name) starting with Themes[0]. So basically I need to loop through each list item in list ThemesList. - In first list item all HIDDEN inputs names should start with Themes [0] - In second list item all HIDDEN inputs names should start with Themes [1] ... So in this example, Themes[2]. ... would become Themes[1]. ... and Themes[5]. ... would become Themes[2]. ... Could someone please help me out? I have no idea how to do this. Thanks, Miguel
[jQuery] Re: Increment Value. What am I doing wrong?
You mean the following: $index = $('#Index'); parseInt($index.val())--; This still gives me the same error. Could someone, please, tell me how to do this? Thanks, Miguel On Feb 11, 6:38 am, Ralph Whitbeck ralph.whitb...@gmail.com wrote: Karl is right, you need to convert it from a string first. shapper wrote: Hello, I have an input on my page as follows: input id=Index name=Index type=hidden value=0 / I am trying to increase and decrease the value of the input as follows: $index = $('#Index'); $index.val()--; I always get an error: invalid assignment left-hand side What am I doing wrong? Thanks, Miguel
[jQuery] Re: Increment Value. What am I doing wrong?
Hi everybody, This is not working. Let me explain it better. I have the input: input id=Index name=Index type=hidden value=0 / In JQuery I need to get the value of this input and use it as a string. This is done: $index = $('#Index'); And then I use $index.val() But, and here is the problem, I need to incremente this value by 1 and updated the value of the input with this new value. On Feb 11, 6:23 pm, Ricardo Tomasi ricardob...@gmail.com wrote: Increment/decrement is for variables. You can't use it directly on a number. Try '3--'. Make it simple, if you use subtraction the type conversion is done for you: $index = $('#Index'); val = $index.val()-1; On Feb 11, 2:37 pm, shapper mdmo...@gmail.com wrote: You mean the following: $index = $('#Index'); parseInt($index.val())--; This still gives me the same error. Could someone, please, tell me how to do this? Thanks, Miguel On Feb 11, 6:38 am, Ralph Whitbeck ralph.whitb...@gmail.com wrote: Karl is right, you need to convert it from a string first. shapper wrote: Hello, I have an input on my page as follows: input id=Index name=Index type=hidden value=0 / I am trying to increase and decrease the value of the input as follows: $index = $('#Index'); $index.val()--; I always get an error: invalid assignment left-hand side What am I doing wrong? Thanks, Miguel
[jQuery] Order Items. Please help me. Thank You.
Hello, I am adding and removing a items from a list, using JQuery, which is rendered has follows: ol id=ThemesList li input type=hidden name=Themes[0].Subject value=A / input type=hidden name=Themes[0].Levels value=L1,L2 / input type=hidden name=Themes[0].Description value=Paper / /li li input type=hidden name=Themes[2].Subject value=B / input type=hidden name=Themes[2].Levels value=L1,L5 / /li li input type=hidden name=Themes[5].Subject value=D / input type=hidden name=Themes[5].Levels value=L2,L4 / input type=hidden name=Themes[5].Description value=Book / /li /ol Every time I add or remove a Theme I need to be sure that the list is ordered (name) starting with Themes[0]. So basically I need to loop through each list item in list ThemesList. - In first list item all HIDDEN inputs names should start with Themes [0] - In second list item all HIDDEN inputs names should start with Themes [1] ... So in this example, Themes[2]. ... would become Themes[1]. ... and Themes[5]. ... would become Themes[2]. ... Could someone please help me out? I have no idea how to do this. Thanks, Miguel
[jQuery] Re: Order Items. Please help me. Thank You.
Themes[0].Subject is the actual name ... It is so to be read by an MVS framework into a List. Basically when the page loads some items are already there rendered on the server. They are always with the correct order. However, when I add / remove items to that list the order might change ... So I should add and remove all items? How can I do this? And why? I am posting my entire code: // Cancel button $('#Cancel').click(function() { location.href = '/Account/ List'; }); // Themes // Remove theme $('.Remove').livequery('click', function(event) { $(this).parent().remove(); }); // Add theme $('#AddTheme').bind('click', function(){ // Define index $index = $('#Index'); // Set valid var valid = new Boolean(true); // Define fields $description = $('#Description'); $levels = $('input[name=Levels]:checked + label'); $levelsTypes = $('input[name=Levels]:checked'); $subject = $('#Subject option:selected'); // Map levels levels = $levels.map(function() { return $(this).text(); }).get (); levelsTypes = $levelsTypes.map(function() { return $(this).val (); }).get(); // Validate if (!$subject.val()) { valid = false; } if (!levels.length) { valid = false; } // Validate if (valid) { // Define theme $theme = $('li class=Themes/li').appendTo ('#ThemesOnTutor'); // Add fields $theme.append($subject.text()).append('br /'); $theme.append(FriendlyLevels(levels) + 'br /'); if ($description.val()) {$theme.append($description.val ()).append('br /');} // Add button $theme.append('a href=#Remove class=RemoveRemover/ a'); // Add inputs $theme.append('input type=hidden name=Themes.Index value = ' + $index.val() + ' /'); $theme.append('input type=hidden name=Themes[' + $index.val() + '].Subject value = ' + $subject.val() + ' /'); $theme.append('input type=hidden name=Themes[' + $index.val() + '].LevelsCsv value = ' + levelsTypes.join(,) + ' / '); $theme.append('input type=hidden name=Themes[' + $index.val() + '].Description value = ' + $description.val() + ' / '); // Increment index $index.val(+$index.val() + 1); } }); // FriendlyLevels function FriendlyLevels(levels) { if (levels.length 2) return levels.join(''); var first = levels.slice(0, -1), last = levels.slice(-1); var friendly = first.join(', '); if (last) { friendly += ' e ' + last; } return friendly; } // FriendlyLevels On Feb 11, 9:47 pm, seasoup seas...@gmail.com wrote: You could remove the entire list everytime and regenerate it from javascript. Is Themes[0].Subject the actual name, or are you trying to refer to a javascript object in an array with the attribute 'Subject' which contains the name you are looking for? If it is the latter, this won't work. you'll need to create the html in javascript and append it into the page. $('liinput type=hidden name=' + Themes[0].Subject + ' value=A/li').appendTo($('#ThemesList')); I'm actually not sure if jQuery handles appending a list item to a list properly. Probaby does. On Feb 11, 1:19 pm, shapper mdmo...@gmail.com wrote: Hello, I am adding and removing a items from a list, using JQuery, which is rendered has follows: ol id=ThemesList li input type=hidden name=Themes[0].Subject value=A / input type=hidden name=Themes[0].Levels value=L1,L2 / input type=hidden name=Themes[0].Description value=Paper / /li li input type=hidden name=Themes[2].Subject value=B / input type=hidden name=Themes[2].Levels value=L1,L5 / /li li input type=hidden name=Themes[5].Subject value=D / input type=hidden name=Themes[5].Levels value=L2,L4 / input type=hidden name=Themes[5].Description value=Book / /li /ol Every time I add or remove a Theme I need to be sure that the list is ordered (name) starting with Themes[0]. So basically I need to loop through each list item in list ThemesList. - In first list item all HIDDEN inputs names should start with Themes [0] - In second list item all HIDDEN inputs names should start with Themes [1] ... So in this example, Themes[2]. ... would become Themes[1]. ... and Themes[5]. ... would become Themes[2]. ... Could someone please help me out? I have no idea how to do this. Thanks, Miguel
[jQuery] Increment Value. What am I doing wrong?
Hello, I have an input on my page as follows: input id=Index name=Index type=hidden value=0 / I am trying to increase and decrease the value of the input as follows: $index = $('#Index'); $index.val()--; I always get an error: invalid assignment left-hand side What am I doing wrong? Thanks, Miguel
[jQuery] Numbering ... Could someone please help me out with this?
Hi, I am adding list items to a list as follows: $('#AddTheme').bind('click', function(){ // Other code $theme = $('li class=Themes/li').appendTo ('#Themes'); $theme.append('input type=hidden name=Themes[0].Subject value = ' + $subject.val() + ' /'); $theme.append('input type=hidden name=Themes [0].LevelsCsv value = ' + levelsTypes.join(,) + ' /'); $theme.append('input type=hidden name=Themes [0].Description value = ' + description.val() + ' /'); }); Basically, every time I add a new item I want to give the next number to Themes[0], i.e., Themes[1]. If I add 3 themes I will have Themes[0], Themes[1], Themes[2] Basically, I need to have at all times themes numbered as 0, 1, 2, ... Could someone please help me out? Thanks, Miguel Just in case, here is my entire code fully commented: $('#Cancel').click(function() { location.href = '/Account/ List'; }); // Themes // Define remove event $('.Remove').livequery('click', function(event) { $(this).parent().remove(); }); // Bind add button $('#AddTheme').bind('click', function(){ // Define valid var valid = new Boolean(true); // Define fields $description = $('#Description'); $levels = $('input[name=Levels]:checked + label'); $levelsTypes = $('input[name=Levels]:checked'); $subject = $('#Subject option:selected'); // Map levels levels = $levels.map(function() { return $(this).text(); }).get (); levelsTypes = $levelsTypes.map(function() { return $(this).val (); }).get(); // Check subject if (!$subject.val()) { valid = false; } // Check levels if (!levels.length) { valid = false; } // Check boolean if (valid) { // Define theme $theme = $('li class=Themes/li').appendTo ('#Themes'); // Add fields $theme.append($subject.text()).append('br /'); $theme.append( Levels(levels) + 'br /' ); if ($description.val()) { $theme.append($description.val ()).append('br /'); } // Add button $theme.append('a href=#Remove class=RemoveRemover/ a'); // Add inputs $theme.append('input type=hidden name=Themes[0].Subject value = ' + $subject.val() + ' /'); $theme.append('input type=hidden name=Themes [0].LevelsCsv value = ' + levelsTypes.join(,) + ' /'); $theme.append('input type=hidden name=Themes [0].Description value = ' + description.val() + ' /'); // Add input //$theme.append(' input type=hidden name=Themes value = ' + theme + ' /'); } }); // Levels function Levels(levels) { // Check levels if (levels.length 2) return levels.join(''); // Define first var first = levels.slice(0, -1), last = levels.slice(-1); // Define result var result = first.join(', '); // Check last if (last) { result += ' and ' + last; } // Return results return result; } // Levels
[jQuery] Re: Validate does not work in IE7
Please, anyone? On Dec 8, 12:42 am, shapper [EMAIL PROTECTED] wrote: Hello, I am using JQuery and Validate. It works fine in Firefox 3 but it does not work in IE7. Here is an example:http://www.27lamps.com/Beta/Form/Form.html Am I doing something wrong or is there a bug? Thanks, Miguel
[jQuery] Validate does not work in IE7
Hello, I am using JQuery and Validate. It works fine in Firefox 3 but it does not work in IE7. Here is an example: http://www.27lamps.com/Beta/Form/Form.html Am I doing something wrong or is there a bug? Thanks, Miguel
[jQuery] Remove comma
Hello, I have the following code: $levels = $('input[name=Levels]:checked + label'); levels = $levels.map(function() { return $(this).text(); }).get(); $theme.append(levels.join(, )).append('br /'); How can I replace the last comma in levels by and ? I tried: levels.join(, ).replace(/, $/,'and ') This is not working. Could someone, please, help me? Thanks, Miguel
[jQuery] Re: Remove comma
Hi, I tried to use as follows: $theme.append(commasAnd(levels.join(,))).append('br /'); I get an error. This is the message I got in Firebug: first.join is not a function commasAnd(London,Lisbon)Base.js (line 24) (?)()()Account.js (line 86) handle()()JQuery%2...1.2.6).js (line 2093) (?)()()JQuery%2...1.2.6).js (line 1875) [Break on this error] var result = first.join(', '); What am I doing wrong? Thanks, Miguel On Nov 22, 7:08 pm, Michael Geary [EMAIL PROTECTED] wrote: I suggest not trying to use a regular expression at all, but just some straight-up array manipulation. It makes it easier to handle all the special cases involved here. Paste this code into the multiline Firebug console (orange up arrow in the bottom right of the Firebug panel) and hit Ctrl+Enter to run it: function commasAnd( array ) { if( array.length 2 ) return array.join(''); var first = array.slice( 0, -1 ), last = array.slice( -1 ); var result = first.join(', '); if( last ) { if( first.length 1 ) result += ','; result += ' and ' + last; } return result; } function test( array ) { console.log( '' + commasAnd(array) + '' ); } test([]); test([ 'a' ]); test([ 'a', 'b' ]); test([ 'a', 'b', 'c' ]); test([ 'a', 'b', 'c', 'd' ]); It should display: a a and b a, b, and c a, b, c, and d I took the liberty of following the English usage that is traditionally considered correct: a, b, and c, not a, b and c. If you prefer a, b and c, you can remove the line with the first.length 1 test. -Mike From: ricardobeat I'm not very good with regexes but this should do, just make sure you always have a space after the comma: levels.join(',').replace(/(\,)(.[^,]*)$/,' and$2') I'm sure someone else can come up with a much more elegant expression! - ricardo On Nov 22, 3:10 pm, shapper [EMAIL PROTECTED] wrote: Hello, I have the following code: $levels = $('input[name=Levels]:checked + label'); levels = $levels.map(function() { return $(this).text(); }).get(); $theme.append(levels.join(, )).append('br /'); How can I replace the last comma in levels by and ? I tried: levels.join(, ).replace(/, $/,'and ') This is not working. Could someone, please, help me? Thanks, Miguel
[jQuery] Re: Remove comma
Thank You Michael. It is working fine. Thanks. On Nov 22, 8:44 pm, Michael Geary [EMAIL PROTECTED] wrote: The commasAnd() function I wrote takes an array argument. You're passing it levels.join(,) - which is a string, not an array. Don't do the .join() yourself - commasAnd() does that for you. Also you can simplify your code by doing a single .append() instead of two: $theme.append( commasAnd(levels) + 'br /' ); -Mike From: shapper Hi, I tried to use as follows: $theme.append(commasAnd(levels.join(,))).append('br /'); I get an error. This is the message I got in Firebug: first.join is not a function commasAnd(London,Lisbon)Base.js (line 24) (?)()()Account.js (line 86) handle()()JQuery%2...1.2.6).js (line 2093) (?)()()JQuery%2...1.2.6).js (line 1875) [Break on this error] var result = first.join(', '); What am I doing wrong? Thanks, Miguel On Nov 22, 7:08 pm, Michael Geary [EMAIL PROTECTED] wrote: I suggest not trying to use a regular expression at all, but just some straight-up array manipulation. It makes it easier to handle all the special cases involved here. Paste this code into the multiline Firebug console (orange up arrow in the bottom right of the Firebug panel) and hit Ctrl+Enter to run it: function commasAnd( array ) { if( array.length 2 ) return array.join(''); var first = array.slice( 0, -1 ), last = array.slice( -1 ); var result = first.join(', '); if( last ) { if( first.length 1 ) result += ','; result += ' and ' + last; } return result; } function test( array ) { console.log( '' + commasAnd(array) + '' ); } test([]); test([ 'a' ]); test([ 'a', 'b' ]); test([ 'a', 'b', 'c' ]); test([ 'a', 'b', 'c', 'd' ]); It should display: a a and b a, b, and c a, b, c, and d I took the liberty of following the English usage that is traditionally considered correct: a, b, and c, not a, b and c. If you prefer a, b and c, you can remove the line with the first.length 1 test. -Mike From: ricardobeat I'm not very good with regexes but this should do, just make sure you always have a space after the comma: levels.join(',').replace(/(\,)(.[^,]*)$/,' and$2') I'm sure someone else can come up with a much more elegant expression! - ricardo On Nov 22, 3:10 pm, shapper [EMAIL PROTECTED] wrote: Hello, I have the following code: $levels = $('input[name=Levels]:checked + label'); levels = $levels.map(function() { return $(this).text(); }).get(); $theme.append(levels.join(, )).append('br /'); How can I replace the last comma in levels by and ? I tried: levels.join(, ).replace(/, $/,'and ') This is not working. Could someone, please, help me? Thanks, Miguel
[jQuery] Validate and Ajax. Could someone, please, help me?
Hello, On a form I am remote validation for an email. However, to this validation, I also need to provide the inserted username which is on another text box. I am using the following: $().ajaxSend(function(event, XMLHttpRequest, ajaxOptions) { ajaxOptions.data.username = $(#Username).val(); }); I get an error on Firebug saying: ajaxOptions.data is null (?)()()Account.js (line 30) handle()()JQuery%2...1.2.6).js (line 2093) (?)()()JQuery%2...1.2.6).js (line 1875) trigger()()JQuery%2...1.2.6).js (line 2034) trigger()()JQuery%2...1.2.6).js (line 2267) each()()JQuery%2...1.2.6).js (line 762) each()()JQuery%2...1.2.6).js (line 155) trigger()()JQuery%2...1.2.6).js (line 2266) trigger()()JQuery%2...1.2.6).js (line 2002) ajax()()JQuery%2...1.2.6).js (line 2748) ajax()()Validate...0(1.4).js (line 1057) remote()()Validate...0(1.4).js (line 902) check()()Validate...0(1.4).js (line 468) element()()Validate...0(1.4).js (line 321) onfocusout()()Validate...0(1.4).js (line 214) delegate()Validate...0(1.4).js (line 289) delegate()()Validate...0(1.4).js (line 1097) handle()()JQuery%2...1.2.6).js (line 2093) handler()()Validate...0(1.4).js (line 1088) [Break on this error] ajaxOptions.data.username = $(#Username).val (); The input id is Username. It is correct. I confirmed it! What am I doing wrong? And how can I add the username ONLY to this validate? I have one more request on the page and I don't want to add the username also to it ... ... I am afraid that I will get an error. I have been trying to solve this but I am stuck. Could someone please help me? Thanks, Miguel
[jQuery] Re: Validate. Can I validate using 2 values?
Please, could you tell me how to do that? I would like to add the username only to this validate requests and not to all requests on my page ... If I add it to all requests on my pages will I not need to have username as input of all the other JSON methods even if I don't use it, Could someone, please advice me on this ... I really don't know what should I do. Thanks, Miguel On Nov 18, 2:50 pm, shapper [EMAIL PROTECTED] wrote: Hi Miguel, Could you, please, show me your JQuery validate code to do that? Thanks, Miguel On Nov 18, 6:08 am, Daniel [EMAIL PROTECTED] wrote: For my case , I get the user value from the field and add it as a parameter into the remote's url . Sth like this : / checkpassuser=userid Daniel. On Nov 17, 5:07 am, shapper [EMAIL PROTECTED] wrote: In this case I have only the validate request for the password field that also sends the username for the test ... But if I would have various requests, from validate or others, shouldn't I add the username only to the password validate request? Is this possible? Thanks, Miguel On Nov 16, 6:45 pm, Jörn Zaefferer [EMAIL PROTECTED] wrote: This would add the username to all requests: $().ajaxSend(function(event, XMLHttpRequest, ajaxOptions) { ajaxOptions.data.username = $(#username).val(); }); Jörn On Sun, Nov 16, 2008 at 7:18 PM, shapper [EMAIL PROTECTED] wrote: Sorry, is there any example using validate for this? To be honest I am completely lost on how to do this ... Thank You, Miguel On Nov 16, 10:39 am, Jörn Zaefferer [EMAIL PROTECTED] wrote: I mean $().ajaxSend(function() { }); Jörn On Sun, Nov 16, 2008 at 1:24 AM, shapper [EMAIL PROTECTED] wrote: Hi Jorn, You mean using: $.ajax({ beforeSend: function(){ } }); And in before send get the value of the text box and add it to the ajax validate request of the validate? But how can I link it to the Validate email validation? Thanks, Miguel On Nov 15, 2:21 pm, Alexsandro_xpt [EMAIL PROTECTED] wrote: And about form submit before to validate e-mail field? Do you know something about that? Thanks Alexsandro On 13 nov, 14:00, Jörn Zaefferer [EMAIL PROTECTED] wrote: The plugin doesn't support that. As a workaround, you can use jQuery's ajaxSend callback to add additional data to the request:http://docs.jquery.com/Ajax/ajaxSend#callback Jörn On Thu, Nov 13, 2008 at 3:35 PM, shapper [EMAIL PROTECTED] wrote: Hello, I am using the following to validate an email field: Email: { email: true, remote: /Account/FindEmail, required: true } I am checking if there is already an account with that email. In my form I also have an input where the user inserts its username. When validating the email I need to send also the Username an not only the email. Can I do this? Thanks, Miguel
[jQuery] Selector a. How can I do this?
Hello, Can I select all anchors which link is an email address? For example: a href=mailto:[EMAIL PROTECTED]bla/a Is there a way to do this without adding a class to the anchor? Thanks, Miguel
[jQuery] Validate. Only on button click.
Hello, Is it possible to validate a form only on button click and not as the user types? Thanks, Miguel
[jQuery] Re: Validate. Can I validate using 2 values?
Hi Miguel, Could you, please, show me your JQuery validate code to do that? Thanks, Miguel On Nov 18, 6:08 am, Daniel [EMAIL PROTECTED] wrote: For my case , I get the user value from the field and add it as a parameter into the remote's url . Sth like this : / checkpassuser=userid Daniel. On Nov 17, 5:07 am, shapper [EMAIL PROTECTED] wrote: In this case I have only the validate request for the password field that also sends the username for the test ... But if I would have various requests, from validate or others, shouldn't I add the username only to the password validate request? Is this possible? Thanks, Miguel On Nov 16, 6:45 pm, Jörn Zaefferer [EMAIL PROTECTED] wrote: This would add the username to all requests: $().ajaxSend(function(event, XMLHttpRequest, ajaxOptions) { ajaxOptions.data.username = $(#username).val(); }); Jörn On Sun, Nov 16, 2008 at 7:18 PM, shapper [EMAIL PROTECTED] wrote: Sorry, is there any example using validate for this? To be honest I am completely lost on how to do this ... Thank You, Miguel On Nov 16, 10:39 am, Jörn Zaefferer [EMAIL PROTECTED] wrote: I mean $().ajaxSend(function() { }); Jörn On Sun, Nov 16, 2008 at 1:24 AM, shapper [EMAIL PROTECTED] wrote: Hi Jorn, You mean using: $.ajax({ beforeSend: function(){ } }); And in before send get the value of the text box and add it to the ajax validate request of the validate? But how can I link it to the Validate email validation? Thanks, Miguel On Nov 15, 2:21 pm, Alexsandro_xpt [EMAIL PROTECTED] wrote: And about form submit before to validate e-mail field? Do you know something about that? Thanks Alexsandro On 13 nov, 14:00, Jörn Zaefferer [EMAIL PROTECTED] wrote: The plugin doesn't support that. As a workaround, you can use jQuery's ajaxSend callback to add additional data to the request:http://docs.jquery.com/Ajax/ajaxSend#callback Jörn On Thu, Nov 13, 2008 at 3:35 PM, shapper [EMAIL PROTECTED] wrote: Hello, I am using the following to validate an email field: Email: { email: true, remote: /Account/FindEmail, required: true } I am checking if there is already an account with that email. In my form I also have an input where the user inserts its username. When validating the email I need to send also the Username an not only the email. Can I do this? Thanks, Miguel
[jQuery] Validate. True and False
Hello, On a Register form I am using remote validation to check if the username already exists. But on a RecoverPassword form the error will be if the user is not found. Basically, in both cases the remote method is the same: UserExists returns true if the username exists or false otherwise. But in Register form the error message is displayed UserExists returns true and in RecoverPassword the error is displayed if UserExists returns false. Do I need to create to methods or is there a way, in Jquery validate method, a way to switch from true to false as the rule to display the error message? How should I do it? Thanks, Miguel
[jQuery] Validate. CheckBoxes. Is this possible?
Hello, I have a group of 8 CheckBoxes and I am validating so the user selects at least on of the CheckBoxes. It is working fine but now I would like a new rule that: - Requires that one of the first 3 checkboxes to be selected ... and only one! Is this possible? Thanks, Miguel
[jQuery] Re: Validate. Can I validate using 2 values?
Sorry, is there any example using validate for this? To be honest I am completely lost on how to do this ... Thank You, Miguel On Nov 16, 10:39 am, Jörn Zaefferer [EMAIL PROTECTED] wrote: I mean $().ajaxSend(function() { }); Jörn On Sun, Nov 16, 2008 at 1:24 AM, shapper [EMAIL PROTECTED] wrote: Hi Jorn, You mean using: $.ajax({ beforeSend: function(){ } }); And in before send get the value of the text box and add it to the ajax validate request of the validate? But how can I link it to the Validate email validation? Thanks, Miguel On Nov 15, 2:21 pm, Alexsandro_xpt [EMAIL PROTECTED] wrote: And about form submit before to validate e-mail field? Do you know something about that? Thanks Alexsandro On 13 nov, 14:00, Jörn Zaefferer [EMAIL PROTECTED] wrote: The plugin doesn't support that. As a workaround, you can use jQuery's ajaxSend callback to add additional data to the request:http://docs.jquery.com/Ajax/ajaxSend#callback Jörn On Thu, Nov 13, 2008 at 3:35 PM, shapper [EMAIL PROTECTED] wrote: Hello, I am using the following to validate an email field: Email: { email: true, remote: /Account/FindEmail, required: true } I am checking if there is already an account with that email. In my form I also have an input where the user inserts its username. When validating the email I need to send also the Username an not only the email. Can I do this? Thanks, Miguel
[jQuery] Re: Validate. Can I validate using 2 values?
In this case I have only the validate request for the password field that also sends the username for the test ... But if I would have various requests, from validate or others, shouldn't I add the username only to the password validate request? Is this possible? Thanks, Miguel On Nov 16, 6:45 pm, Jörn Zaefferer [EMAIL PROTECTED] wrote: This would add the username to all requests: $().ajaxSend(function(event, XMLHttpRequest, ajaxOptions) { ajaxOptions.data.username = $(#username).val(); }); Jörn On Sun, Nov 16, 2008 at 7:18 PM, shapper [EMAIL PROTECTED] wrote: Sorry, is there any example using validate for this? To be honest I am completely lost on how to do this ... Thank You, Miguel On Nov 16, 10:39 am, Jörn Zaefferer [EMAIL PROTECTED] wrote: I mean $().ajaxSend(function() { }); Jörn On Sun, Nov 16, 2008 at 1:24 AM, shapper [EMAIL PROTECTED] wrote: Hi Jorn, You mean using: $.ajax({ beforeSend: function(){ } }); And in before send get the value of the text box and add it to the ajax validate request of the validate? But how can I link it to the Validate email validation? Thanks, Miguel On Nov 15, 2:21 pm, Alexsandro_xpt [EMAIL PROTECTED] wrote: And about form submit before to validate e-mail field? Do you know something about that? Thanks Alexsandro On 13 nov, 14:00, Jörn Zaefferer [EMAIL PROTECTED] wrote: The plugin doesn't support that. As a workaround, you can use jQuery's ajaxSend callback to add additional data to the request:http://docs.jquery.com/Ajax/ajaxSend#callback Jörn On Thu, Nov 13, 2008 at 3:35 PM, shapper [EMAIL PROTECTED] wrote: Hello, I am using the following to validate an email field: Email: { email: true, remote: /Account/FindEmail, required: true } I am checking if there is already an account with that email. In my form I also have an input where the user inserts its username. When validating the email I need to send also the Username an not only the email. Can I do this? Thanks, Miguel
[jQuery] Validate. CheckBoxes
Hello, I have a list of CheckBoxes: A, B, C, D and E. A, B and C should obey a relation that only one of this three can be selected. So I select A and D and then C, A will be unchecked. D and E don't have any relation. Does anyone knows a plugin that does this? Thanks, Miguel
[jQuery] Validate. Can I validate using 2 values?
Hello, I am using the following to validate an email field: Email: { email: true, remote: /Account/FindEmail, required: true } I am checking if there is already an account with that email. In my form I also have an input where the user inserts its username. When validating the email I need to send also the Username an not only the email. Can I do this? Thanks, Miguel
[jQuery] Show/Hide. Could someone, please, help me with this?
Hello, I have a form as following: form id=MyForm fieldset legendPersonal Data/legend /fieldset fieldset legendOptions/legend /fieldset /form I would like to hide/show each fieldset when its legend is clicked ... ... or even better, adding a small icon on legend or somewhere in fieldset to toogle visibility. How can I do this with JQuery? Thanks, Miguel
[jQuery] Validate. Check Boxes
Hello, I have 5 check boxes all with the same name forming a group. Is it possible to use validate so I require at least one checkbox to be checked? Thanks, Miguel
[jQuery] Re: Validate. Can validate plugin do this?
Hi, Does anyone knows if it is possible? I would prefer to use Validate plugin but if not possible I will include the validation in my own code. Thanks, Miguel On Oct 28, 3:00 pm, shapper [EMAIL PROTECTED] wrote: On Oct 28, 8:49 am, Jörn Zaefferer [EMAIL PROTECTED] wrote: No idea, I'd need a testpage to look at. jsbin.com is quite useful for that. Jörn Hi Jörn, If you don't mind I prefer to upload an example to my server. It is easier because the code is not so simple. http://www.27lamps.com/Beta/Validate/Validate.html Basically, when the button Add is clicked the select Subject requires a value and the checkboxes Levels should also required a at least one checked. Let me know if I can pull this with your plugin. If you notice I am already using your plugin for Name and Blog inputs on Create click. Thanks, Miguel
[jQuery] Empty
Hi, I have the following on a JQuery Code: $('li class=DynamicList/li').appendTo('#Themes') .append(subject) .append('br /') .append(levels) .append('br /') How can I add .append(subject) .append('br /') only if subject is not empty and .append(levels) .append('br /') only if levels is not empty? Levels and Subject are declared as: var subject = [], levels = []; Thanks, Miguel
[jQuery] Exists
Hello, I have the following: if (subject == '---') { if(!$('label[for=Subject,class=Error]').length) { $('#Subject').parent().after('label for=Subject generated=true class=ErrorRequired field/label'); } } I need to check if a label with for=Subject and class=Error exists: if(!$('label[for=Subject,class=Error]').length) This is not working. What am I doing wrong? Thanks, Miguel
[jQuery] Re: Validate. Can validate plugin do this?
On Oct 28, 8:49 am, Jörn Zaefferer [EMAIL PROTECTED] wrote: No idea, I'd need a testpage to look at. jsbin.com is quite useful for that. Jörn Hi Jörn, If you don't mind I prefer to upload an example to my server. It is easier because the code is not so simple. http://www.27lamps.com/Beta/Validate/Validate.html Basically, when the button Add is clicked the select Subject requires a value and the checkboxes Levels should also required a at least one checked. Let me know if I can pull this with your plugin. If you notice I am already using your plugin for Name and Blog inputs on Create click. Thanks, Miguel
[jQuery] Is array empty?
Hello, I have the folllowing: var levels = []; $levels = $('input[name=Levels]:checked + label'); levels = $levels.map(function() { return $ (this).text(); }).get(); How can I check if levels array is empty? I tried levels, levels.val(), etc but I was not able to make this work. Thanks, Miguel
[jQuery] Re: Validate. Not working with Radio input
I found it! I had the form inside a div both with same id ... Thanks, Miguel On Oct 27, 8:48 am, Jörn Zaefferer [EMAIL PROTECTED] wrote: Can't reproduce the problem:http://jsbin.com/iwofu/edit Jörn On Sun, Oct 26, 2008 at 6:32 PM, shapper [EMAIL PROTECTED] wrote: Please, anyone? On Oct 24, 6:00 pm, shapper [EMAIL PROTECTED] wrote: Hello, I am trying to validate a form with radio inputs. I want to the form to be submitted only if an option was selected: form action=/Poll/Vote/1 class=Poll id=Poll method=post fieldset label for=OptionsArrayDo you like to travel?/label input type=radio name=OptionsArray id=1 value=1 class=Radio / label for=1Yes/label input type=radio name=OptionsArray id=2 value=2 class=Radio / label for=2No/label input id=Submit name=Submit type=submit value=Vote / /fieldset /form I used: $(#Poll).each(function() { $(this).validate({ errorClass: Error, errorElement: label, rules: { OptionsArray: { required: true } }, messages: { OptionsArray: { required: You didn't choose your vote } } }); }); The form is submitted even if I don't choose an option! If I select an option I get an error on Firebug: validator.settings[on + even... + event.type].call(validator, this[0]); Could someone tell me what am I doing wrong? Thank you, Miguel
[jQuery] Validate. Can validate plugin do this?
Hello, I have a form with 20 elements a Submit Button and a Validate. It works fine ... Inside this form I added the following: - a select, an input and 3 checkboxes all with same name; - a button named Add; - an ordered list. When the Add button is clicked the values of the select, input and checkboxes are added to the list as list item. Note: When the Add button is clicked it does not submit the entire form $('#Add').bind('click', function(){ // logic done here } Can I add validation functionality to Add button using the validate plugin? The select and the input should be required. Note: when the entire form is submitted these fields can be empty Thanks, Miguel
[jQuery] Add label
Hello, I need to check if an input, #Message, value is empty. If it is I need to add the following after it: label for=Message generated=true class=WelcomeWelcome Text/ label How can I do this? Thanks, Miguel
[jQuery] Selector
Hello, I have the following: levels = $('input:checked + label'). ... Can I select only the inputs checked but which name is Level? Thanks, Miguel
[jQuery] Re: Validate. Can validate plugin do this?
The values of the select, the input and the names of the selected checkboxes are added to a string and added to the unordered list as: liInput Values/li If the select is empty and the input is empy I want to display the error message and the items not added. Here is my code: // Define remove event $('.Remove').livequery('click', function(event) { $(this).parent().remove(); }); // Create fields var subject = [], note = [], levels = []; // Bind add button $('#AddTheme').bind('click', function(){ // Define fields subject = $('#Subject option:selected').text(); note = $('#Note').val(); levels = $('input:checked + label').map(function() { return $(this).text(); }).get().join(, ); // Define data var data = subject + '.' + note + '.' + levels; // Append theme $('li class=DynamicList/li').appendTo('#Themes') .append(subject) .append('br /') .append(levels) .append('br /') .append(note) .append('br /') .append(' a href=#Remove class=RemoveRemove/a') .append(' input type=hidden name=Themes value = ' + data + ' /'); }); I can integrate the validation in my script but since I am using Validate if it would be possible I would handle the validation all in the same way. Thanks, Miguel On Oct 27, 10:11 pm, Jörn Zaefferer [EMAIL PROTECTED] wrote: Whats supposed to happen when you click the add button? Jörn On Mon, Oct 27, 2008 at 10:54 PM, shapper [EMAIL PROTECTED] wrote: Hello, I have a form with 20 elements a Submit Button and a Validate. It works fine ... Inside this form I added the following: - a select, an input and 3 checkboxes all with same name; - a button named Add; - an ordered list. When the Add button is clicked the values of the select, input and checkboxes are added to the list as list item. Note: When the Add button is clicked it does not submit the entire form $('#Add').bind('click', function(){ // logic done here } Can I add validation functionality to Add button using the validate plugin? The select and the input should be required. Note: when the entire form is submitted these fields can be empty Thanks, Miguel
[jQuery] Re: Selector
Thanks! On Oct 27, 11:36 pm, Ryura [EMAIL PROTECTED] wrote: evels = $('input[name=Level]:checked + label'); Should do it for you. On Oct 27, 7:13 pm, shapper [EMAIL PROTECTED] wrote: Hello, I have the following: levels = $('input:checked + label'). ... Can I select only the inputs checked but which name is Level? Thanks, Miguel
[jQuery] Re: Validate. Not working with Radio input
Please, anyone? On Oct 24, 6:00 pm, shapper [EMAIL PROTECTED] wrote: Hello, I am trying to validate a form with radio inputs. I want to the form to be submitted only if an option was selected: form action=/Poll/Vote/1 class=Poll id=Poll method=post fieldset label for=OptionsArrayDo you like to travel?/label input type=radio name=OptionsArray id=1 value=1 class=Radio / label for=1Yes/label input type=radio name=OptionsArray id=2 value=2 class=Radio / label for=2No/label input id=Submit name=Submit type=submit value=Vote / /fieldset /form I used: $(#Poll).each(function() { $(this).validate({ errorClass: Error, errorElement: label, rules: { OptionsArray: { required: true } }, messages: { OptionsArray: { required: You didn't choose your vote } } }); }); The form is submitted even if I don't choose an option! If I select an option I get an error on Firebug: validator.settings[on + even... + event.type].call(validator, this[0]); Could someone tell me what am I doing wrong? Thank you, Miguel
[jQuery] Re: Validate. Password Bug?
You mean using: $.validator.addMethod('password', function (value, element) { return this.optional(element.value) || /^([a-zA-Z0-9]{8,24}) $/.test(value); }, 'Use 8 to 24 letters or numbers only'); I have tried it before and I got the following error in Firebug: element.nodeName is undefined switch (element.nodeName.toLowerCase()) { What am I doing wrong? Thanks, Miguel On Oct 25, 3:47 pm, Jörn Zaefferer [EMAIL PROTECTED] wrote: Its not a bug, but could be considered bad design. The first argument, value, is the trimmed value. Using element.value should fix the issue. Jörn On Fri, Oct 24, 2008 at 10:50 PM, shapper [EMAIL PROTECTED] wrote: Hello, I am validating a password field as follows: $.validator.addMethod('password', function (value, element) { return this.optional(element) || /^([a-zA-Z0-9]{8,24}) $/.test(value); }, 'Use 8 to 24 letters or numbers only'); I write 8 numbers and letters. The message disappears. Fine ... Then I write a few spaces and the message do not fire even when I submit the form. Then I write a few letters or numbers after the empty spaces and the message fires again ... Is this a bug? Thanks, Miguel
[jQuery] Re: Get label text
I wrote alert(levels) to check and I get: [object Object] Does anyone knows how to get the values and join in CSV format? Thank You, Miguel On Oct 24, 1:47 am, shapper [EMAIL PROTECTED] wrote: yes, I have: var levels = []; levels = $('input:checked + label').map(function() { return $(this).text(); }); ... .append(levels.join(',')) Still having the same error ... On Oct 24, 1:04 am, William [EMAIL PROTECTED] wrote: Perhaps use .append(labels.join(',')) Note that the snippet from Klaus uses var *labels*, so trying to use the Array.join method of *levels* (probably undefined) will likely not work ;) On Oct 23, 2:58 pm, shapper [EMAIL PROTECTED] wrote: But I can join the labels can't I? I tried: .append(levels.join(', ')) to added it to an element and I get the error in Firebug: levels.join is not a function Am I doing something wrong? Thanks, Miguel On Oct 23, 9:57 pm, Klaus Hartl [EMAIL PROTECTED] wrote: You could try this (untested): var labels = $('input:checked + label').map(function() { return $(this).text(); }); That should give you an array with the label's text. --Klaus On 23 Okt., 22:47, shapper [EMAIL PROTECTED] wrote: Hello, This might be a tricky one ... I have been looking into JQuery docs but I can't figure how to make this. I have the following: input type=checkbox name=Roles id=Admin value=Admin / label for=AdminAdministrator/label input type=checkbox name=Roles id=Coll value=Admin / label for=CollCollaborator/label How can I get, NOT the values, of all checked boxes BUT the label inner text of all checked boxes? Example: If Coll checkbox is checked I would get: Collaborator If both checkboxes are checked I would get: Collaborator, Administrator Could someone, please, help me? Thank You, Miguel
[jQuery] Validate. Not working with Radio input
Hello, I am trying to validate a form with radio inputs. I want to the form to be submitted only if an option was selected: form action=/Poll/Vote/1 class=Poll id=Poll method=post fieldset label for=OptionsArrayDo you like to travel?/label input type=radio name=OptionsArray id=1 value=1 class=Radio / label for=1Yes/label input type=radio name=OptionsArray id=2 value=2 class=Radio / label for=2No/label input id=Submit name=Submit type=submit value=Vote / /fieldset /form I used: $(#Poll).each(function() { $(this).validate({ errorClass: Error, errorElement: label, rules: { OptionsArray: { required: true } }, messages: { OptionsArray: { required: You didn't choose your vote } } }); }); The form is submitted even if I don't choose an option! If I select an option I get an error on Firebug: validator.settings[on + even... + event.type].call(validator, this[0]); Could someone tell me what am I doing wrong? Thank you, Miguel
[jQuery] Validate. Password Bug?
Hello, I am validating a password field as follows: $.validator.addMethod('password', function (value, element) { return this.optional(element) || /^([a-zA-Z0-9]{8,24}) $/.test(value); }, 'Use 8 to 24 letters or numbers only'); I write 8 numbers and letters. The message disappears. Fine ... Then I write a few spaces and the message do not fire even when I submit the form. Then I write a few letters or numbers after the empty spaces and the message fires again ... Is this a bug? Thanks, Miguel
[jQuery] Re: My first plugin ... need some help.
Thank you for your help and patience. It is working fine ... just a last question: I need to add an input with hidden value to each list item: ...input type=hidden name=myList value=values / The name of the input should be the name of the list passed. The following is what I have now, but I get an error on Firebug: $('li/li').appendTo(opt.list) .append(str) .append(' a href=#Remove class=RemoveRemover/a') .append(' input type=hidden name=' + opt.list.attr(name) + ' value = ' + str + ' /'); Shouldn't attr get the name of opt.list? How can I get the list name? Thanks, Miguel On Oct 23, 4:38 am, ricardobeat [EMAIL PROTECTED] wrote: Hi there, The '@' for attributes has been deprecated, and you can choose that by class also. Another try (hope google groups won't break it too much): $(document).ready(function() { $.fn.createList = function(opt){ var origin = this.eq(0).parents('form'); //get the parent form element var $fields = this; //save all inputs for later $('.remove') .livequery('click', function(event) { $(this).parent().remove(); }); $(opt.button,origin).bind('click',function(){ var str = [],cstr = []; $fields.not(':checkbox').each(function(){ //iterate over all inputs except checkboxes str.push($(this).val()); //add value to array 1 }).end().filter(':checkbox:checked').each(function(){ // iterate over all checked checkboxes cstr.push($(this).val()); //add value to array 2 }); str.push(cstr.join(', ')); // add commas to array 2 and push the resulting string into array 1 str = str.join('. '); // make array 1 into string, dot separated $('li/li').appendTo(opt.list).append(str).append(' a href=#remove class=removeRemove Item/a'); // etc return false; }); } $ ('input.name,select.country,input.newsletter').createList({ list:'#MyList', button: 'input.sendToList' }) }); On Oct 22, 10:24 pm, shapper [EMAIL PROTECTED] wrote: Hi again, I changed the join to a dot and added [EMAIL PROTECTED] as a selector of my CheckBoxes group. I am trying that the values of the selected checkboxes to be added in a Comma Separated format. This is not working? Could someone, please, help me with this thing? It is the last thing to finish it. Thanks, Miguel On Oct 23, 1:05 am, shapper [EMAIL PROTECTED] wrote: Hi, I solved problem 1 and updated my online example. I still have problems with the checkboxes and the display format ... any idea how to solve? Thanks, Miguel On Oct 23, 12:23 am, shapper [EMAIL PROTECTED] wrote: Hello, I uploaded the updated version:http://www.27lamps.com/Beta/List/List.html#remove There is only two problems: 1. The value of the select is not being added. 2. If i have multiple chekboxes on the same group I would like to add only the values of ones selected. The ideal would be to have the following format: Name. Country. 1st CheckBox selected, 2st CheckBox selected, ... This way I can understand that each dot separates an input and a comma separates the selected values of a check box group. How can I do this? Thanks, Miguel On Oct 22, 2:45 am, shapper [EMAIL PROTECTED] wrote: Hi, I will try it. Sorry, but I am no expert with JQuery and I am just trying to pull this off. I understand that a plugin should have many more options but my intention is to have this plugin so I can use across my projects and with time improve it. It would be easier to make this without being a plugin? I am not really sure how the code would change ... I was looking for such a plugin but I wasn't able to find any ... I think this is really useful. Just select the inputs, the button, the list and the format as the inputs values would be displayed. Then use something like: liBook Type. Book Name. Values of selected CheckBoxes separated by commasinput type=hidden name=myList value=Book Type. Book Name. Values of selected CheckBoxes separated by commas /a href=#removeclass=removeRemove Item/a/li Then I use the hidden inputs to read the info on the server after the form is submitted, parse the info and insert it into the database along with the other form info. Does this makes any sense? Yes, I could use Ajax but the form has a lot more information and these list info should be only saved into the database if the user submits the register form itself. So if i send this info through ajax there will no where to save it since the user didn't register yet. Is this what you meant? Thank You, Miguel On Oct 22, 1:45 am, ricardobeat [EMAIL PROTECTED] wrote: Install the Firebug extension for Firefox so you can debug your code