Jump to content
Larry Ullman's Book Forums

ionezation

Members
  • Posts

    44
  • Joined

  • Last visited

Posts posted by ionezation

  1. Yes hartleysan, after the script you have submitted it shows this

     

    Employee Added

    Name : undefinedundefined                    // undefined first and last name. They are still undefined
    Department : IT                            // It is changing now
    Hire Date : Wed Jan 15 2014                  // date is this

     

    In console it is that

     

    // undefined undefined "accounts" Wed Jan 15 2014 06:22:11 GMT-0800 (Pacific Standard Time)

     

    i have found one error in my code and that was here in :

     

    function init()

    {
    'use strict';
    var form = document.getElementById('form');
    form.onsubmit = calculate;
    }; // end init()
     
     
    window.onload = calculate;            // Instead of init; i placed here calculate();  
  2. Thanks for correction and giving me more knowledge Jaepee and HartleySen.

     

    one mistake i am making everytime is

    function init(){
    
    
        'use stric';
        var theform = document.getElementById('theform');
        theform.onsubmit = calculate;
        };
        window.onload = init;

    misspelling of Strict [ 'use stric' ], even jaypee dint notced that.

  3. In Chapter 7 - Creating Function page number 237. The code in the book has a discrepency that is provided in source code. It took me 30mins to get on the conclusion. The difference was at line 

    output.textContent = numbers;

    Instead it would be output.textContent = message;

     

     

    Here it is the code

     

    This is in the book at page 237

    function setText(elementId,message)
    {
    'use strict';
    
    
    if ((typeof elementId == 'string')
    && (typeof message == 'string') ){
    var output = $(elementId);
    if(output.textContent !== undefined)
    {
    output.textContent = numbers;
    } else {
    output.innerText = numbers;
    }
    } // end of if
    } // end of setText()

    This is the working corrected one in source code :

     

    function setText(elementId,message)
    {
    'use strict';
    
    
    if ((typeof elementId == 'string')
    && (typeof message == 'string') ){
    var output = $(elementId);
    if(output.textContent !== undefined)
    {
    output.textContent = message;
    } else {
    output.innerText = message;
    }
    } // end of if
    } // end of setText()
    

     

  4. It doesn`t work either hartley ! this is from chapter 6 [complex variable type] on page 212, its about working with array. 

     

    Before this example there also one in this book that is also not working it is on page 196 chapter 6 [complex variable type] and it is for working with objects

  5. This is my HTML

    <form id="form" method="post">
    
    
    First Name :
    <input type="text" id="fname" name="fname">
    <br>
    
    
    Last Name :
    <input type="text" id="lname" name="lname">
    <br>
    Department :
    
    
    <select name="department" id="department">
    <option value="accounts">Accounts</option>
    <option value="hr">HR</option>
    <option value="it">Information Technology</option>
    
    
    <input type="submit" id="submit" value="Add Employee">
    
    
    <div id="output"></div>
    </form>
    </select>

    This is my CSS !

    function calculate(){
    'use strict';
    
    
    var fname = document.getElementById('fname').value;
    var lname = document.getElementById('lname').value;
    var depart = document.getElementById('department').value;
    
    
    var output = document.getElementById('output');
    
    
    var employee = {
    firstname:fname,
    lastname:lname,
    department:depart,
    hireDate:new Date()
    };
    
    
    var msg = '<h2>Employee Added</h2> Name :  ' + employee.firstname +  employee.lastname + '<br>';  
    msg += 'Department :  ' + employee.department + '<br>';
    msg += 'Hire Date :  ' + employee.hireDate.toDateString();
    
    
    output.innerHTML = msg;
    }
    
    
    
    
    function init()
    {
    'use stric';
    var form = document.getElementById('form');
    form.onsubmit = calculate;
    }; // end init()
    
    
    window.onload = calculate;
    

    For unknown reason i cant figured it out what is the problem please help

     

  6. <h1>CALCULATOR FOR SHOP</h1>
    <form id="theform" method="post">
    <fieldset>
    <label>Quantity</label>
    <input type="number" name="quantity" id="quantity" value="1" min="1" required>
    <label>Price per unit</label>
    <input type="number" name="price" id="price" value="1" min="1" required>
    <label>Tax Rate(%)</label>
    <input type="text" name="tax" id="tax" value="0.0" required>
    <label>Discount</label>
    <input type="text" name="discount" id="discount" value="0.0" required>
    <label>Total</label>
    <input type="text" name="total" id="total" value="0.00">
    <button>Calculate</button>
    </fieldset>
    </form>

    This is my HTML

    function calculate(){
    'use strict';
    
    
    var total;
    var quantity = document.getElementById('quantity').value;
    var price = document.getElementById('price').value;
    var tax = document.getElementById('tax').value;
    var discount = document.getElementById('discount').value;
    total = quantity * price;
    tax = tax/1000;
    tax = tax + 1;
    total = total * tax;
    total -= discount;
    document.getElementById('total').value = total;
    return false;
    }; // end of calculate() function
    
    
    function init(){
    
    
    'use stric';
    var theform = document.getElementById('theform');
    theform.onsubmit = calculate;
    };
    window.onload = init;

    This is CSS !

     

    this is not working and i am not getting it why :s

  7. Hi,

     

      I am stuck at this place at chapter 17 Message Board. When connecting to database it gives this error

     

    could not connect to database access denied for user 'user'@'localhost' (using password yes)

     

    in mysqli_connect.php

     

    DEFINE ("DB_USER","root")

    DEFINE ("DB_PASSWORD","")

    DEFINE ("DB_HOST","localhost") 

    DEFINE ("DB_NAME","forum2")

     

    $connect = @mysqli_connect(DB_USER,DB_PASSWORD,DB_HOST,DB_NAME) or die ('Could Not Connect to Database:'. mysqli_connect_error() ) ;

     

    mysqli_set_charset($connect, 'utf-8').

     

     

    I have also changed the position of user name local host password but nothing works. What I do I cant figure it out. Please help.

     

    One thing more I am not getting the idea that why $_SESSION = array(); is uncommented to virtually log the user out? how it is possible ?? on page 530 chapter 17 'Message Board

     

    Regards,

    Anu'

×
×
  • Create New...