JMRKER's Profile User Rating: -----

Reputation: 129 Stalwart
Group:
Active Members
Active Posts:
832 (0.38 per day)
Joined:
25-October 08
Profile Views:
9,065
Last Active:
User is offline Today, 07:45 PM
Currently:
Offline

Previous Fields

Country:
US
OS Preference:
Who Cares
Favorite Browser:
FireFox
Favorite Processor:
Who Cares
Favorite Gaming Platform:
Who Cares
Your Car:
Who Cares
Dream Kudos:
0

Latest Visitors

Icon   JMRKER has not set their status

Posts I've Made

  1. In Topic: I need to delete min and max values from array

    Posted 16 Oct 2014

    One (of many) possible solution...

    <!DOCTYPE html>
    <html lang="en">
    <head>
    <meta charset="UTF-8" />
    
    <title> HTML5 page </title>
    
    </head>
    <body>
    
    <script type="text/javascript">
    
    Array.prototype.removeMin = function() {
      var p = 0,  min = this[p], arr = [];
      for (var i=0; i<this.length; i++) { arr.push(this[i]);
        if (this[i] < min) { p = i; min = this[i]; }
      }
      arr.splice(p,1);
      return arr;
    }
    Array.prototype.removeMax = function() {
      var p = 0,  max = this[p], arr = [];
      for (var i=0; i<this.length; i++) { arr.push(this[i]);
        if (this[i] > max) { p = i; max = this[i]; }
      }
      arr.splice(p,1);
      return arr;
    }
    var origArray = [5,4,3,2,1,10,9,8,7,6];
    var minRemoved = origArray.removeMin();
    var maxRemoved = origArray.removeMax();
    
    alert('orig: '+origArray+'\n\nmin removed: '+minRemoved+'\n\nmax removed: '+maxRemoved);
    </script>
    
    </body>
    </html>
    


    You could combine the two functions into one, if desired.

    <!DOCTYPE html>
    <html lang="en">
    <head>
    <meta charset="UTF-8" />
    
    <title> HTML5 page </title>
    
    </head>
    <body>
    
    <script type="text/javascript">
    
    Array.prototype.removeMin = function() {
      var p = 0,  min = this[p], arr = [];
      for (var i=0; i<this.length; i++) { arr.push(this[i]);
        if (this[i] < min) { p = i; min = this[i]; }
      }
      arr.splice(p,1);
      return arr;
    }
    Array.prototype.removeMax = function() {
      var p = 0,  max = this[p], arr = [];
      for (var i=0; i<this.length; i++) { arr.push(this[i]);
        if (this[i] > max) { p = i; max = this[i]; }
      }
      arr.splice(p,1);
      return arr;
    }
    Array.prototype.MinMaxRemove = function() {
      var min = this[0], max = this[0], arr = [];
      for (var i=0; i<this.length; i++) { // arr.push(this[i]);
        if (this[i] < min) { min = this[i]; }
        if (this[i] > max) { max = this[i]; }
      }
      for (var i=0; i<this.length; i++) { 
        if (this[i] != min && this[i] != max) { arr.push(this[i]); }
      }
      return arr;
    }
    
    
    var origArray = [5,4,3,2,1,10,9,8,7,6];
    var minRemoved = origArray.removeMin();
    var maxRemoved = origArray.removeMax();
    var minmaxOut  = origArray.MinMaxRemove();
    
    alert('orig: '+origArray+'\n\nmin removed: '+minRemoved+'\n\nmax removed: '+maxRemoved+'\n\nUnique: '+minmaxOut);
    </script>
    
    </body>
    </html>
    
  2. In Topic: Double dropdown list layout (first javascript project)

    Posted 15 Oct 2014

    This part of your code ...

    SList.scontent = {
    078	 "145": '<br> <button type="button" onclick=location="http://www.autoschluessel-online.de/produktkategorie/alfa-romeo/145/">Jetzt suche</button> ',
    079	  "146": '<br> <button type="button" onclick=location="http://www.autoschluessel-online.de/produktkategorie/alfa-romeo/146/">CJetzt suche</button> ',
    080	   "145": '<br> <button type="button" onclick=location="http://www.autoschluessel-online.de/produktkategorie/alfa-romeo/155/">Jetzt suche</button> ',
    081	 
    082	};
    
    

    ... will not work even if you get the display as you desire.
    You have the wrong syntax for the onclick assignment.
  3. In Topic: Jumping to next input field when enter is clicked

    Posted 15 Oct 2014

    View PostXorana, on 14 October 2014 - 03:29 AM, said:

    Hi,

    I have the below code. I want the cursor to jump to the next input field when the user clicks enter.
    It all works, ...???
    [snip]


    How does it work?
    Where does the keycode for the event of the key being pressed get sampled or passed to the 'jump' function?
    How is it supposed to get back to the not-select after the 1st 3 entries when there is no directing to the 1st tabindex?
  4. In Topic: Random Array into Textarea?

    Posted 9 Oct 2014

    A different solution that uses fewer array duplications, ie: uarticle and larticle
    and does not require any of the arrays to be of SAME length, ie: preposition and uarticle

    <!DOCTYPE html>
    <html>
    	<head>
    </head>
    <body>
    <textarea id="textareaID" rows="10" cols="80"></textarea>
    
    <script type="text/javascript">
    Array.prototype.pword = function() { return this[Math.floor ( Math.random() * this.length )];  } 
    String.prototype.capitalize = function() { return this.charAt(0).toUpperCase() + this.slice(1); }
    
    var noun = ["boy ", "girl ", "dog ", "cat ", "bird ", "town ", "car "];
    var verb = ["drove ", "jumped ", "ran ", "walked ", "skipped ", "sauntered ",  "sashayed "];
    var article = ["the ", "a ", "one ", "some ", "any ", "several "];
    var preposition = ["to ", "from ", "over ", "under ", "on ","around ","below ","about "];
    
    for (var i = 1; i <=20; i++)  { <!-- continue to add until <= 20 -->
    
      var rand1 = article.pword();
      var rand2 = noun.pword();
      var rand2a = noun.pword();   		  while (rand2 == rand2a) {rand2a = noun.pword(); }
      var rand3 = verb.pword();
      var rand4 = article.pword();  		  while (rand4 == rand1) {rand4 = article.pword(); }
      var rand5 = preposition.pword();
    
      rand1 = rand1.capitalize();
    
      var msg = rand1 + rand2 + rand3 + rand5 + rand4 + rand2a; 
      msg = msg.replace(/\s$/,'.\n');
      document.getElementById('textareaID').value += msg; 
    }
    </script>
    </body>
    </html>
    
    
  5. In Topic: checkbox input - its value is to be output to another checkbox

    Posted 17 Sep 2014

    Are these exclusive conditions or are they inclusive.
    Are you looking for affirmation that the user has BOTH a bike and a car
    or that they will be using only one mode of transportation at a time?

    If exclusive, consider the use of radio buttons instead.

    What is the output checkbox to look like when either none, one or both checkboxes are chosen?

My Information

Member Title:
D.I.C Addict
Age:
Age Unknown
Birthday:
Birthday Unknown
Gender:
Location:
Florida
Programming Languages:
javascript, perl, java, forth, basic, fortran, assembly (several)

Contact Information

E-mail:
Private
Website URL:
Website URL  http://

Comments

JMRKER has no profile comments yet. Why not say hello?