problem about elements-Collection of common programming errors


  • Morgan Soren
    asp.net-mvc-3 cookies razor hide elements
    ok so im having a hard time hiding some layout sections (divs in my layout page and im using mvc3). I have this js fragment which is basically the main logic: $(‘.contentExpand’).bind(‘click’, function () {$.cookie(‘right_container_visible’, “false”);});//Cookies Functions========================================================//Cookie for showing the right containerif ($.cookie(‘right_container_visible’) === ‘false’) {if ($(‘#RightContainer:visible’)) {$(‘#RightContainer’).hide();}$.cookie(‘rig

  • dreamer
    c range elements
    Given an array of size n. It contains numbers in the range 1 to n. Each number is present at least once except for 2 numbers. Find the missing numbers. eg. an array of size 5 elements are suppose 3,1,4,4,3one approach is static int k; for(i=1;i<=n;i++) {for(j=0;j<n;j++){if(i==a[j])break;}if(j==n){k++;printf(“missing element is”, a[j]);}if(k==2)break;}another solution can be.. for(i=0;i

  • Just Kidding
    vb.net arrays resize elements
    Lets say I want to create an array with 20 elements all set to a default value (let’s say, 0)But later, during runtime, I might want to resize the array. I might make it larger, to support 30 elements. The 10 new elements will have the default value of 0.Or I might want to make my array smaller, to just 5. So I delete the complete the existence of the last 15 elements of the array.Thanks.

  • Jean
    arrays perl push elements
    Is there a shorthand way by which I can push n identical elements to an array ?Can I do this in just one line ?push(@mode_z00,”lib_drx”); push(@mode_z00,”lib_drx”); push(@mode_z00,”lib_drx”); push(@mode_z00,”lib_drx”); push(@mode_z00,”lib_drx”);something like push(@mode_z00,5,”lib_drx”);

  • alan2here
    c++ pointers set elements stdvector
    In the below program a string is added to an empty store. Then the address of this store element is stored in the pointer ‘s1’. Then another string is added and this somehow causes the pointer to the original element to fail.#include <iostream> #include <string> #include <vector>class store2 {public:void add(std::string s) {words.push_back(s); last_added2 = &words.at(words.size() – 1);}std::string* last_added() {return last_added2;}private:std::string* last_added2;std::vect

  • NT_SYSTEM
    c++ vector elements deque
    I’m having trouble with the getFirst() functions , they’re supposed to return the first element of the deque / vector but instead they return fixed values like 45 or 69!For example: I Add(0xFB) … then try to printf(“%d”,p_MsgQueue->getFirst()) Output: 69 ????MessageQueue.h/** Copyright (C) 2011 – 2012 Project Avalance** This program is free software; you can redistribute it and/or modify* it under the terms of the GNU General Public License as published by* the Free Software Foundation; either

  • kris
    jquery input selectors elements
    I have a form with dynamically created form elements.I need to get the value of each element, and send an ajax request to make sure the data is ok (the easy part). I can get each elements value easy enough, but the problem comes in with radio buttons. For example:<input type = ‘radio’ class = ‘form_element’ value = ‘1’> <input type = ‘radio’ class = ‘form_element’ value = ‘1’> <input type = ‘radio’ class = ‘form_element’ value = ‘1’>if i do something like…$(‘.form_element’).e

  • MRAISKY
    javascript add elements
    I am trying to populate a list of images dynamically using javascript. I have the following code, but it is not working. If you see any errors, or know of a better way of doing this, any help will be appreciated. code is as follows:<html xmlns=”http://www.w3.org/1999/xhtml”><head> <script type=”text/javascript”> function generateCarousel(baseval, num_images) {var list_node = document.getElementById(“carousel”);list_node.innerHtml(”); // clear the previous contentsfor (var i =

  • buga
    javascript jquery xml svg elements
    I am trying to get a svg file using jquery/javascript svg example:<svg width=”111″ height=”123″ xmlns=”http://www.w3.org/2000/svg”><g><title>Layer 1</title><rect fill=”#ffffff” stroke=”#000000″ stroke-width=”3″ x=”1.5″ y=”1.5″width=”108.00001″ height=”119.99999″ id=”svg_1″ rescale=”none” move=”Static”/><text text_pos=”midcenter” xml:space=”preserve” text-anchor=”middle” font-family=”Fantasy” font-size=”14″ id=”Actor Role name” y=”68″ x=”55″ stroke-width=”0″ strok

  • eric.itzhak
    javascript select add elements options
    i am trying to create a select element with JS or even edit an existing one yet i seem to be missing something. this is done in Joomla if this matters.this is my code:var option = document.createElement(“option”); var select = document.createElement(“select”);select.setAttribute(“id”, “chooseCat”);for(int i=0;i<LevelNames.Length;i++){option.innerHTML = LevelNames[i];option.setAttribute(“value”,LevelIds[i]);document.getElementById(“cat_chooser”).appendChild(option);document.getElementById(“cat

  • thecoshman
    javascript forms elements
    var loc_name = document.forms[‘create_<?php echo(htmlspecialchars($window_ID)); ?>’].elements[‘location_name’]; alert(loc_name);This just gives me the message ‘undefined’where as…var loc_name = document.forms[‘create_<?php echo(htmlspecialchars($window_ID)); ?>’]; alert(loc_name);Gives me the object form business.Have I just got this all wrong? What is the ‘proper’ way to access this form element. The form element has the correct name and it has an id, the id is similar but not the

  • John
    javascript jquery tabs focus elements
    I want to trigger the same effect than when pressing the tab key on an element that has the focus. Is there any way of doing this? I am trying to make the focus jump to the next element.Thanks!(jQuery is an option)

  • Michael Sazonov
    javascript elements
    I have this function declared: Object.prototype.append = Array.prototype.append = append = function( tag ){ alert( this ) … }It supposed to append “tag” element after a DOM element or an array of objects. Now, when I call it after an array of two elements – everything works well, I get “[object HTMLDivElement,object HTMLDivElement]” thtown by alert for, but when it’s called by a single DOM element IE8 throws that the object does not support this option or method and even the alert is not execu

  • RSid
    python regex list elements deleting
    Apologies if this is a simple question, I’m still pretty new to this, but I’ve spent a while looking for an answer and haven’t found anything. I have a list that looks something like this horrifying mess: [‘Organization name} ‘, ‘> (777) 777-7777} ‘, ‘ class=”lsn-mB6 adr”>1 Address, MA 02114 } ‘, ‘ class=”lsn-serpListRadius lsn-fr”>.2 Miles} MORE INFO YOUR LISTING MAP if (typeof(serps) !== \’undefined\’) serps.arrArticleIds.push(\’4603114\’); ‘, ‘Other organization} ‘, ‘> (555) 555-5

  • Pete
    javascript arrays elements extra
    In PHP, if you do this$var = array(); $var[5000] = 1; echo count($var);It prints 1. In JS it makes the “missing” elements. <script type=”text/javascript”>var fred = [];fred[10] = 1;alert(fred.length); </script>Alerts “11”.Can I prevent this? Is it good for anything? I’m a PHP coder trying to adapt to Javascript.EDIT:I’m working on an app that uses Google Maps v2 and markerManager. The code has been working for ages, but a problem has suddenly arisen in Chrome (17.0.963.56 m) where m

  • kaapa
    design-patterns dom backbone.js reference elements
    I’m currently building a large backbone app, and here is my question. How to cope with DOM elements refernces the best way? Now I simply find all elements which will be accessed in a future (forms and things like that) in my view’s initialize function, and bind them to the view itself. This way I don’t have to search for these elements every time I need to interact with them. But number of this references is growing quite quickly actually. Is it good approach or can I do better? Thanks in advanc

  • DevGav
    jquery attributes jquery-selectors elements attr
    How do you select the attribute of a “root” level element in jQuery?The following doesn’t work (returns undefined):jQuery(document).ready(function() {somehtml = “<a href=’http://example.com’>An example</a>”;theurl = jQuery(‘a’,somehtml).attr(‘href’);alert(theurl);}Any idea what I’m missing? I’m sure it’s something obvious about root level elements …Many thanks in advance, Gav

  • Sp3ct3R
    jquery html elements .post
    I have some pages that i acces by jquery $.post like this:$.post(url, {name: name}, function(data) {var htmldata = $(data);if($(‘#ok’, htmldata).val() == “1”){//some things carried out} });$(‘#ok’, htmldata).val() is allways undefined so where is the problem?UPDATE: htmldata = <input id=\”ok\” type=\”hidden\” value=\”1\” /> and another 2-3 hidden input.

  • frictionlesspulley
    jquery html attributes alert elements
    I’m reading a html document using jQuery. Following is my code. I need to find lang attribute which is an attribute of HTML element. But I have trouble selecting it the way I’m doing. when I process HTML tag its either no value, null or undefined.Can u please help me figure this out?$.get(page, function(response) {alert(response);alert($(response).filter(‘html’).attr(‘lang’)); });?

  • ToddN
    jquery dom if-statement elements
    I am using jQuery on my site and I need to make some jQuery IF statements for IF logged in DO THIS else DO THIS (For instance logging in would change the header text to ‘My Account’). I don’t really know how to read the DOM tree to see what element or node I would be calling. Does anyone have experience with this?On Product Pages I currently have jQuery code starting with:jQuery(function(){ if (typeof(global_Current_ProductCode) !=”undefined”)is there something I could find on my site that is

  • Michelle
    php jquery elements
    I am getting a list of products from the database through a loop. The productId is placed in a hidden input. This input is placed in a div. What i need to do is get the value of a particular through Jquery.below is my codevar t = document.getElementById(‘txtPID’).value;The thing is that the value that I get is the value found in the first input. (the first ProductId found in the page).What can i do to get that particular value in the input using Jquery?

  • lorem monkey
    cakephp cakephp-2.0 elements
    I use the following to render an element in view/users/index.ctp:$this->renderElements(‘users/lmenu’);But when use the same line in the layout default.ctp I get an error:Call to undefined method View::renderElements() How can I display an element in a layout?

  • Highland Mark
    javascript elements attachevent
    I wrote a plugin , but whene Active ,disable Editor and in firebug Mozila below error Is shownelement.dispatchEvent is not a function prototype.js:5457and line 5457 prototype.jsif (document.createEvent)5457: element.dispatchEvent(event);elseelement.fireEvent(event.eventType, event);return Event.extend(event);}but plugin work very good but disable Editor.What is the cause?

  • gotqn
    jquery text elements
    I want to get the text of all elements. I am using this code here:$(‘*’).filter(function() {if(($(this).text().lenght>0)&&($(this).text().lenght<100)){return true;}else{return false;} }).each(function() {console.log($(this).text()); });I have try to show only short text because .text() sometime returns html code but it is not working at all.

Web site is in building