JavaScript - Issues Referencing The Correct Object
Hi there. I have a table which I would like to be highlighted with the click of a button, but I can't seem to reference it correctly. I can make the <td> clickable and function, but when I try to apply it to the button I can't make it reference the td cell, rather than change the background color of the button.
The function is: function roll(obj){ obj.style.backgroundColor == "pink" ? obj.style.backgroundColor = "#e5e5e5" : obj.style.backgroundColor = "pink"; } Html: <td style="background-color:#e5e5e5;"><img onmousedown="roll(this);" src="images/plus.png" title="Highlight Lot" /></td> Thanks a lot!! :) Similar TutorialsHello, On a simple form, there is a radio button group with two radio buttons, a text box, and a submit button. The first radio button is checked(selected) by default. The text box input has the onChange event handler so that if the text is changed, the second radio button will be checked(selected). The problem is the input radio name contains a hyphen that breaks the JavaScript and the name can not be changed. What is the correct syntax for referencing a hyphenated form input radio name in the onChange event? Here is the form that works correctly with no hyphen in the input radio name: Code: <form name="myFormGood" action="" onsubmit="return false;"> Good Form with no hyphen in radio button name<br> <input name="radio1" type="radio" value="4" checked> First Option<br> <input name="radio1" type="radio" value="5"> Second Option<br><br> Change the text to select the Second Option<br> <input type="text" name="text1" onChange="document.myFormGood.radio1[1].checked = 'true';" size="10" value=" "><br><br> <input type="button" name="submit" value="It Works!"> </form> Here is the form that breaks the JavaScript because it has a hyphen in the input radio name: Code: <form name="myFormBad" action="" onsubmit="return false;"> Bad Form with hyphen in radio button name breaks JavaScript<br> <input name="radio-1" type="radio" value="4" checked> First Option<br> <input name="radio-1" type="radio" value="5"> Second Option<br><br> Change the text to select the Second Option. Nothing Happens.<br> <input type="text" name="text1" onChange="document.myFormBad.radio-1[1].checked = 'true';" size="10" value=" "><br><br> <input type="button" name="submit" value="It Doesn't Work!"> </form> Hi all, I'm wondering if what I'm trying to do here is even possible but I'd appreciate your thoughts on it. Code: <script type="text/javascript"> function test() { var arrays = { one: ['1', '2', '3'], two: ['a', 'b', 'c'] } var foo = 'one'; alert(arrays.(foo)); } test(); </script> I've tried numerous variations of the alert line with evals, brackets and jQuery syntax but always seem to get the error: Code: XML filter is applied to non-XML value ({one:["1", "2", "3"], two:["a", "b", "c"]}) Which makes me think I'm either attempting something stupid or only missing my target slightly. The code will be running within a jQuery project up if that helps in any way. Which of these is the correct way to set the className attribute, or are they both okay? option 1: Code: var t = document.createElement("p"); t.className = "myclass"; option 2: Code: var t = document.createElement("p"); t.setAttribute("class","myclass"); So I'm re-writing my procedural Back Jack program to be Object Oriented so that I can add a split option and some other features and I've run into this weird bug... This is the beginning of the function that assembles the HTML for each card when it is added. hand.prototype.createCardsHTML = function (cardNum) { console.log(this.cards); console.log(this.cards[cardNum]); console.log(this.cards[cardNum].name); if(this.player == "dealer" && cardNum == 0){ this.cards[cardNum].imgHTML = '<img src="images/cards/b2fv.png" alt="dealer pocket" />'; } else{ this.cards[cardNum].imgHTML = '<img src="images/cards/' + this.cards[cardNum].image +'" alt="' + this.cards[cardNum].name + ' of ' + this.cards[cardNum].suit +'s" />'; } attached is a screen shot of the console.log reports, as you can see the object get stored in the array but for whatever reason I can't access it's individual properties. This only occurs when the hit function is called, not when the initial hands are generated. I'm really confused so any help is appreciated. Also here is the entire script (note: it's very long, a bit disorganized and not yet complete) // JavaScript Document // JavaScript Document window.onload = blackJackTable; function blackJackTable () { //set-ables var insCost = 50; var dlrHitsOn = 17; var minBet = 10; var bank = 500; //Utilities var usedCards = new Array(53); var roundOver = true; var allBetsPlaced = false; var dealerWent = false; //var dlrIncrement = 0; //var plrIncrement = 0; //Load Objects loadJSON("data.json"); function loadJSON(url) { var headID = document.getElementsByTagName("head")[0]; var newScript = document.createElement('script'); newScript.type = 'text/javascript'; newScript.src = url; headID.appendChild(newScript); newScript.onreadystatechange= function () { if (this.readyState == 'complete' || this.readyState == 'loaded') startGame(); } newScript.onload= startGame; } function startGame() { //console.log(deck); //construct players function player(playerIdent){ this.lastBet = 0; this.bet = 0; this.playerName = playerIdent; this.hands = new Array(); this.betPlaced = false; this.bank = bank; this.insured = false; } //Construct Hands function hand(playerName, id, bet) { this.total = 0; this.locked = false; this.over = true; this.player = playerName; this.id = id; this.bet = bet; this.aces = 0; this.handDiv = new Array(); this.cards = this.newCard(2); // adds to cards at random to hand, updates aces and total } //function for adding cards to a hand hand.prototype.newCard = function (howMany){ var cards = new Array(); for(i=0; i<howMany; i++){ var card; do { card = Math.floor(Math.random() * 52); } //Check to see if the card is in use while (usedCards[card]); //Add card to used array usedCards[card] = true; var nextCard = cards.length; cards[nextCard] = deck[card]; //check for ace if(cards[nextCard].value == 11){ this.aces += 1; //check for dealer ace in second slot if(this.player == "dealer" && cards.length == 2){ //call offer insurance if dealer has ace in second slot this.offerIns();///!!! re-write to reference hand not player } } this.total += cards[nextCard].value; } //update player total return cards; } //DOM commands to generate dealer area HTML player.prototype.generateDlrHTML = function () { this.dlrRegion = document.getElementById('dealer-region'); //creates a div for dealer hand this.plrHands = document.createElement('div'); //sets the class name for dealer hand div this.plrHands.setAttribute('class', 'dealer-hands'); //adds dealerhand div to dlrRegion div this.dlrRegion.appendChild(this.plrHands); //creates a div for dealer total this.dealerTotalRegion = document.createElement('div'); //sets the class name for dealer hand div this.dealerTotalRegion.setAttribute('class', 'dealer-total'); //adds dealertotal div to dlrRegion div this.plrHands.appendChild(this.dealerTotalRegion); } //DOM commands to generate each player area HTML player.prototype.generatePlrHTML = function () { this.plrRegion = document.getElementById('players-region'); //creates a div for player hands this.plrHands = document.createElement('div'); //sets the class name for player hands div and adds it to region this.plrHands.setAttribute('class', 'hands'); this.plrRegion.appendChild(this.plrHands); //Create player bet and bank region this.hud = document.createElement('div'); //sets the class name for player hud and adds to region this.hud.setAttribute('class', 'hud'); this.plrRegion.appendChild(this.hud); //Create bank display this.bankDisplay = document.createElement('span'); //sets the class name for player hud and adds to region this.bankDisplay.setAttribute('class', 'bank-display'); this.hud.appendChild(this.bankDisplay); //Create bet display this.betDisplay = document.createElement('span'); //sets the class name for player hud and adds to region this.betDisplay.setAttribute('class', 'bet-display'); this.hud.appendChild(this.betDisplay); //Create bet field this.betField = document.createElement('input'); //sets the class name for player hud and adds to region this.betField .setAttribute('class', 'bet-input'); this.betField .setAttribute('type', 'text'); this.betField .setAttribute('value', 'bet here'); this.betField .setAttribute('name', 'bet-input'); this.hud.appendChild(this.betField ); //Create bet Button this.betBtn = document.createElement('input'); //sets the class name for player hud and adds to region this.betBtn.setAttribute('class', 'bet-btn'); this.betBtn.setAttribute('type', 'button'); this.betBtn.setAttribute('value', 'Bet'); this.betBtn.setAttribute('name', 'Bet'); this.hud.appendChild(this.betBtn); var subvertEvent = this; this.betBtn.onclick = function () { subvertEvent.placeBet();}; //Create deal button this.dealBtn = document.createElement('input'); //sets the class name for player hud and adds to region this.dealBtn.setAttribute('class', 'deal-btn'); this.dealBtn.setAttribute('type', 'button'); this.dealBtn.setAttribute('value', 'Deal'); this.dealBtn.setAttribute('name', 'Deal'); this.hud.appendChild(this.dealBtn); this.dealBtn.onclick = function () { subvertEvent.deal();}; } //DOM commands to create hand HTML player.prototype.createHandHTML = function (handNum){ //for(i=0; i<this.hands.length; i++){ //Create a hand div this.hands[handNum].handDiv = document.createElement('div'); //sets the class name for player hud and adds to region var handClass = 'hand-' +this.hands[handNum].id; this.hands[handNum].handDiv.setAttribute('class', handClass); this.plrHands.appendChild(this.hands[handNum].handDiv); this.hands[handNum].createHandCtrlHTML(handNum); //} } //Hit - adds and displays card to hand hand.prototype.hit = function () { this.cards.push(this.newCard(1)); var cardNum = this.cards.length -1; this.createCardsHTML(cardNum); } //Stand - Locks hand - If all hands are locked triggers dealersTurn() hand.prototype.stand = function () { //lock this hand this.locked = true; if(checkAllLocked == true){ dealersTurn(); } } //Double Down - doubles bet on hand calls hit for a single card then forces a stand. hand.prototype.doubleDown = function () { if (this.total > 0 && this.cards.length == 2){ //double bet this.bet = this.bet * 2; //!!!update bet //draw a card this.hit(); //force player to stand this.stand(); } else{ var message = "Sir/Maddam you cannot double down at this time."; dealerSays(message, "okay"); } } //Split - Creates a new player hand and assigns a new bet, moves cards as appropriate. hand.prototype.splitHand = function () { } //Creates hand control HTML hand.prototype.createHandCtrlHTML = function (handNum) { if(this.player != "dealer"){ //hand Control Region this.handControl = document.createElement('div'); //sets the class name for player hud and adds to region this.handControl.setAttribute('class', 'hand-control'); this.handDiv.appendChild(this.handControl); //Create hit button this.hitBtn = document.createElement('input'); //sets the class name for player hud and adds to region this.hitBtn.setAttribute('class', 'hit-btn'); var btnId = 'hit-btn-' + this.player + '-' + this.id; this.hitBtn.setAttribute('id', 'btnId'); this.hitBtn.setAttribute('type', 'button'); this.hitBtn.setAttribute('value', 'Hit'); this.hitBtn.setAttribute('name', 'Hit'); this.handControl.appendChild(this.hitBtn); var subvertEvent = this; this.hitBtn.onclick = function () { subvertEvent.hit();}; //Create Stand button this.standBtn = document.createElement('input'); //sets the class name for player hud and adds to region this.standBtn.setAttribute('class', 'hit-btn'); var btnId = 'stand-btn-' + this.player + '-' + this.id; this.standBtn.setAttribute('id', 'btnId'); this.standBtn.setAttribute('type', 'button'); this.standBtn.setAttribute('value', 'Stand'); this.standBtn.setAttribute('name', 'Stand'); this.handControl.appendChild(this.standBtn); this.standBtn.onclick = function () { hands[handNum].stand();}; //Create Double Down button this.dDBtn = document.createElement('input'); //sets the class name for player hud and adds to region this.dDBtn.setAttribute('class', 'hit-btn'); var btnId = 'doubledown-btn-' + this.player + '-' + this.id; this.dDBtn.setAttribute('id', 'btnId'); this.dDBtn.setAttribute('type', 'button'); this.dDBtn.setAttribute('value', 'Double Down'); this.dDBtn.setAttribute('name', 'Double Down'); this.handControl.appendChild(this.dDBtn); this.dDBtn.onclick = function () { hands[handNum].doubleDown();}; //Create Split button this.splitBtn = document.createElement('input'); //sets the class name for player hud and adds to region this.splitBtn.setAttribute('class', 'hit-btn'); var btnId = 'split-btn-' + this.player + '-' + this.id; this.splitBtn.setAttribute('id', 'btnId'); this.splitBtn.setAttribute('type', 'button'); this.splitBtn.setAttribute('value', 'Double Down'); this.splitBtn.setAttribute('name', 'Double Down'); this.handControl.appendChild(this.splitBtn); this.splitBtn.onclick = function () { hands[handNum].splitHand();}; } } //Actived when used hits "deal" button - Adds a hand object to player object if appropriate //!!!Does not support multiplayer by design player.prototype.deal = function () { if(allBetsPlaced == true && roundOver == true){ //wipes old hands clearHands(); //adds a new hand players[0].newHand(); this.newHand(); //sets round over to false as this begins the new round roundOver = false; } } //New hand function creates a new hand called by deal and split player.prototype.newHand = function () { var handIdPass = this.hands.length + 1; this.hands.push(new hand(this.playerName, handIdPass, this.bet)); var handNum = this.hands.length - 1; //alert(this.hands.length); this.createHandHTML(handNum); for (i=0; i<this.hands[handNum].cards.length; i++){ this.hands[handNum].createCardsHTML(i); } } //DOM commands to create cards hand.prototype.createCardsHTML = function (cardNum) { console.log(this.cards); console.log(this.cards[cardNum]); console.log(this.cards[cardNum].name); if(this.player == "dealer" && cardNum == 0){ this.cards[cardNum].imgHTML = '<img src="images/cards/b2fv.png" alt="dealer pocket" />'; } else{ this.cards[cardNum].imgHTML = '<img src="images/cards/' + this.cards[cardNum].image +'" alt="' + this.cards[cardNum].name + ' of ' + this.cards[cardNum].suit +'s" />'; } this.cards[cardNum].cardDiv = document.createElement('div'); var cardId = 'card-' + this.cards[cardNum].id; this.cards[cardNum].cardDiv.setAttribute('id', cardId); $(this.cards[cardNum].cardDiv).hide(); this.cards[cardNum].cardDiv.innerHTML = this.cards[cardNum].imgHTML; this.handDiv.appendChild(this.cards[cardNum].cardDiv); $(this.cards[cardNum].cardDiv).fadeIn(1000); } ..... Hey guys, First post i have searched the web a lot on this subject and am still confused so i thought id try and get some help from the experts, the following function works great in every browser except IE, the line of code that breaks in IE is highlighted in red. I have read some topics about this not working in IE and saw some workarounds with innerhtml or something but i don't really understand. Can someone please take some time to figure out a fix for this? Code: function displayStream(live_id) { var stream_out = document.getElementById("stream_out"); for (var j = 0; j < stream_out.childNodes.length; j++) { stream_out.removeChild(stream_out.childNodes[j]); } var object = document.createElement("object"); object.setAttribute("height", "475"); object.setAttribute("width", "998"); var param = document.createElement("param"); //param.setAttribute("name", "movie"); param.name = 'movie'; param.setAttribute("value", "http://www.own3d.tv/livestream/" + live_id); object.appendChild(param); var param = document.createElement("param"); param.setAttribute("name", "allowfullscreen"); param.setAttribute("value", "true"); object.appendChild(param); var param = document.createElement("param"); //param.setAttribute("name", "wmode"); param.name = 'wmode'; param.setAttribute("value", "transparent"); object.appendChild(param); var embed = document.createElement('embed'); embed.setAttribute("type", "application/x-shockwave-flash"); embed.setAttribute("src", "http://www.own3d.tv/livestream/" + live_id +";autoplay=true"); embed.setAttribute("allowfullscreen", "true"); embed.setAttribute("wmode", "transparent"); embed.setAttribute("height", "475"); embed.setAttribute("width", "998"); object.appendChild(embed); stream_out.appendChild(object); } Hello, I've been writting HTML since last friday and javascript since yesterday. And I'm stuck on my first project. My functions for mouse_move / up / down all control the movement of a box. So you can click a box and move it anyway. It then snaps to an invisible grid. However there are multiple boxes on the screen so if you move it to a spot where another box already resides, then that box needs to swap places. This is what the mouse_over function tries to do. When I click the first box it stores the position of that box that was clicked. If I release the mouse button whilst hoovering over another box I want the other box to take the stored positions of the first box. However what I think is happening is the mouseover function is applying the new position to the box I'm moving, as I guess this is the first layer the mouse is over. Is there anyway I can reference the layer underneath using onmouseover. Sorry if this is jibberish. Thank you very much. Code: <script language="javascript"> var x; var y; var org_top; var org_left; var diff_org_top; var diff_org_left; var element; var element2; var being_dragged = false; var swap = false; function mouse_over(ele_name2) { if (swap = true) { element2 = ele_name2; document.getElementById(element2).style.top = org_top; document.getElementById(element2).style.left = org_left; swap = false; element2 = null } } function mouse_move(event) { x=event.pageX; y=event.pageY; if(being_dragged = true) { document.getElementById(element).style.top = y-diff_org_top +'px'; document.getElementById(element).style.left = x-diff_org_left +'px'; } } function mouse_down(ele_name) { being_dragged = true; swap = false element = ele_name; document.getElementById(element).style.cursor = 'move'; org_top = document.getElementById(element).style.top; org_left = document.getElementById(element).style.left; diff_org_top = y-org_top.substring(org_top.length-2,org_top); diff_org_left = x-org_left.substring(org_left.length-2,org_left); } function mouse_up() { being_dragged = false; document.getElementById(element).style.cursor = 'auto'; if (x < 317) { document.getElementById(element).style.left = Math.floor(x / 316 - 1) * 316 +'px'; } else { document.getElementById(element).style.left = 0+'px'; } element = null; swap = true; } </script> Years ago I created HTML that employs checkboxes and textboxes. I am now writing JS with the intention of adding flexibility and limiting redundancy. I am not sure I truly understand how to correctly interact the two though. For example, one of my scripts have arrays that contain the names of the checkboxes and textboxes, with a 'for' loop to document.write() them to references within the HTML code. This does not seem to be working for me though. Here is what I have thus far (in short): Code: <script language="javascript"> var teamNames = new Array(3); teamNames[0]="South Africa"; teamNames[1]="Mexico"; teamNames[2]="Uruguay"; for (i=0; i<=31; i++) { document.write("<p>" + teamNames[i] + "<\/p>"); } </script> </head> <body> <tr><td>Jun 11</td><td><input type="checkbox" name="teamNames[0]" value="teamAbbr[0]"></td> </body> I've left out a lot of the code (to include the teamAbbr array, but you get the points. I've tried moving the JS within the HTML body and playing with the reference syntax, but nothing so far. Any help would be great! Hi, every time I try and alert: [ { number:0, secondnumber:0 }, { number:2, secondnumber:1 }, { number:1, secondnumber:2 } ] it just shows [object object], [object object], [object object]. Why is this and what can I do to make the record be shown as it is above in an alert? Thanks. I created a method for displaying an object's properties: Code: renderfunction = false; function showProperty (object, property) { document.write ('<td class="type">' + (typeof object[property]) + '</td>' + '<td class="name">' + property + '</td>'); document.writeln('<td class="value">' + ( (typeof object[property] != 'function') ? object[property] :( (property != 'showProperties') ? ( renderfunction ? object[property]() : ('<span class="self">NOT RENDERED</span>') ) : ('<span class="self">THIS</span>') ) ) + '</td>'); document.writeln('<td class="hasOwnProperty" >' + ( object.hasOwnProperty(property) ? "Local" : "Inherited" ) + '</td>'); if (typeof object[property] == 'function') { document.writeln ('<td class="function">' + object[property] + '</td>'); } else { document.writeln ('<td class="function"> </td>'); } } As long as renderfunction = false, the object is fine coming out of this function. However, if I change renderfunction to true, all my properties become undefined. Why isn't this working as I expect it to? How should I fix it? Thanks in advance, -Brian. I can't get any info from Firebug except that one line, uncaught exception [object Object]. The code fully worked, then I needed to make it dynamically create Sortables from the scriptaculous library based on how many X were in a table in my database, which I've done, and I'm thinking it may be a simple slight parse error of some type, I'm not too good with Javascript, because now my script barely works. I've double checked the script's source code, the PHP variables are exactly what they should be. Code: print<<<HERE Sortable.create('sortlist$box', { tag: 'img', overlap:'horizontal',constraint:false, containment: $list, dropOnEmpty: true, onChange: function(item) { var list = Sortable.options(item).element; if(changeEffect) changeEffect.cancel(); changeEffect = new Effect.Highlight('changeNotification', {restoreColor:"transparent" }); }, onDrop: function(item) { var thing=Sortable.options(item).element.identify(); var anchors = document.getElementById(thing).childNodes.length-2; if(anchors > 20){ alert('This box had 20 creatures in it already, your last action has not been saved.'); window.location.reload(); } else{ new Ajax.Request("saveImageOrder.php", { method: "post", parameters: { data: Sortable.serialize("sortlist$box") } }); } } }); HERE; $box++; } ?> }); </script> if you solve this I'll send ya $10 via paypal Ignore post (if mod, please delete)
I'm writing a program that involves a network of interconnected nodes (or simply objects in my example below). It depends on being able to access properties of an object's linked objects (a bit oddly worded, sorry)... Problem is I'm not sure how to properly access those properties... see below please. <script> //This is an example of a problem im having in my own code... //I want to access the name of the object within the links array wintin the object... var objA = {name: "Object A", links: [objB, objC]}; var objB = {name: "Object B", links: [objC, objD, objE]}; var objC = {name: "Object C", links: [objB]}; var objD = {name: "Object D", links: [objE]}; var objE = {name: "Object E", links: [objD]}; //ex: I want to access the name of Object A's first link... console.log(objA.links[0].name); </script> I'm hoping to get "Object B"... But instead I get: TypeError: Result of expression 'objA.links[0]' [undefined] is not an object. Is there another way around this? Any thoughts are appreciated. Hi all, I'm stumped on finding a way in javascript to create an object factory whose instances are also object factories. In short I want something like that below, but no joy ... any clues? Code: function createClass () { return new createClass() function createClass() { return new createInstance () function createInstance () { //Default properties, values and methods which might later be extended } } } var createDoor = createClass(); var door1 = createDoor(); var door2 = createDoor(); var createChair = createClass(); var chair1 = createChair (); var chair2 = createChair (); Hello together! I generate html code with jsp. In that jsp there a several framesets and frames. And yes i know, frames are not really up to date but it's an old program and i have to deal with it now. Anyway, in the top frameset i have an onload attribute like onload="load()". In the function load i want to access the Element.prototype object. But unfortunately typeof Element gives me "undefined". So i looked a little deeper and found that window.toString() gives me "[object]" and not as expected "[object window]" so somehow my window doesn't know that its construcor is Window. window.construcor is "undefined" as well. And i don't have access to the Element object. I really don't know where the error could be. When the page is loaded and i access the same window over the console, then everything is right. But in my function a can't get access to the objects i need. I also don't know what part of the code could be useful to post here, but maybe someone had a similar problem before? i should say that this problem only occurs in IE8. In IE9 it works perfectly. Has anyone any idea?? Hello. Is there any way to get the variable name of an object from inside the object? E.g. PHP Code: function Bla(){ this.write = function(){ document.write(<objectname>); } } obj1 = new Bla(); obj1.write(); //Outputs obj1 Here is my script: PHP Code: function myTimer(seconds, obj){ this.seconds = seconds; this.obj = obj; this.startTimer = function(){ if(this.seconds>0){ this.seconds--; this.obj.innerHTML = this.seconds; this.timer = setTimeout("Timer.start()",1000); } } } Timer = new Timer(10, obj); Timer.startTimer(); Now the problem is that the variable that contains the object must be named "Timer". This way I cannot create new timer objects with different variable names I have tried: this.timer = setTimeout("this.start()",1000); but it doesn't work. That's why it would be good to detect the variable name and instead use something like this: this.timer = setTimeout(varname+".start()",1000); I would rather not have to pass the variable name through a parameter like this: Timer1 = new Timer(10, obj, "Timer1"); Thanks in advance. Quote: menu: function( a, b ) { $( b ).observe( 'click', function( event ) { event.stop(); if( $( a ).visible() ) { $( a ).hide(); $( b ).removeClassName( 'selected' ); document.stopObserving( 'click' ); } else { $( a ).show(); $( b ).addClassName( 'selected' ); document.observe( 'click', function( e ) { if( e.target.id != a && e.target.id != b && !Element.descendantOf( e.target, $( a ) ) ) { $( a ).hide(); $( b ).removeClassName( 'selected' ); document.stopObserving( 'click' ); } }); } }); $$( '#' + b + ' > a' ).each( function( element ) { element.observe( 'click', function( event ) { $( a ).hide(); $( b ).removeClassName( 'selected' ); document.stopObserving( 'click' ); }); }); } This work's perfrect accept when i use it with others on the menu it leaves the other ones open, how do i get it to close the open one when i open a new menu.. Thanks. What are these used for? How are they done in JS? Any refs online?
I am trying to troubleshoot my javascript function below. Code: <script type="text/javascript"> function txtboxfill(fillobj) { var rChar=String.fromCharCode(13); var myVal = "To: " + this.form.to.value + rChar; myVal = myVal + "From: " + this.form.from.value + rChar; myVal = myVal + "Subj: " + this.form.subj.value + rChar + rChar; myVal = myVal + "Message: "; fillobj.value = myVal; } </script> Then I have a text box input field with an Code: <input type="text" id="tp" name="to" size="34" class="totext" onkeyup="txtboxfill(this.form.msg_area);"> and when I enter text in this field it gives me a 'this.form.to' is null or not an object and does not populate the textarea. BTW, msg_area is the id of my textarea. Thank you. How can I change the day when the user select a month? When they select Feb ->29 days, select May -> 31 days. Like what facebook does. |