Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New to the CF scene
    Join Date
    May 2014
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Car Registration Project

    I am working on a project where I have to create a website which reads car registration plates and from that tells us the year the car was produced and the county it was produced in.

    So far we have done a basic page with a form with spaces for First Name , last name and registration plate. We want to display the results of the form in an alert box. We have created arrays for the year the car was made and the Area it was made in but cant link the relevant box in the form to the array.

    Any Ideas ? ?

    I have attached the Arrays , our code and image explaining layout of Irish reg


    NOTE :

    In Ireland the registrations are different than in the uk. On our form we have the first box is for the Year which is the last two number of year (e.g 90 = 1990 , 13=2013 etc) The second box is for the County and each county has its own code , (eg D= Dublin , DL= Donegal etc)
    If you could point us in the right direction as to how to link the array and the input from the form that would be great help.
    Cheers for the help if you can


    My Code :

    <head>
    <title>Web Programming Project</title>

    </head>
    <style>
    body
    {
    background-color:#99CCFF;
    body {font-size:250%}
    }
    input { font-size:25px; font-family:ariel; }

    </style>
    <body>
    <center>
    <img src="car.jpg" alt="Car Registration plate" width="900" height="200"
    <center>
    <br>
    <br>
    <br>
    <br>
    <br>
    <script type="text/javascript">

    </script>
    <center>
    <h1><b><u>Please enter Required Details Below</u></b></h1>
    <form name="myform">
    <label for="first_name">First Name : </label>
    <input type="text" name="first_name" maxlength="50" size="30">
    <br>
    <label for="last_name">Last Name :</label>
    <input type="text" name="last_name" maxlength="50" size="30">
    <br>
    <label for="email">Registration Number :</label>
    <input type="text" name="reg" maxlength="10" size="1"> -
    <input type="text" name="reg" maxlength="10" size="1"> -
    <input type="text" name="reg" maxlength="20" size="10">
    <br>
    <input type="submit" value="Submit" onClick="addtext()">
    </form>
    <br>
    <br>
    </form>
    </center>
    </body>

    array for project.txt2ndarray for project.txt

  • #2
    Senior Coder jmrker's Avatar
    Join Date
    Aug 2006
    Location
    FL
    Posts
    3,130
    Thanks
    38
    Thanked 504 Times in 498 Posts

    Question

    Couple of questions...

    In your "2ndarry for project.txt" file, why does the coding change for the years after 2012? Where the code for 2013 is 131.
    Why do the years (25 elements for 1990-2014) not match the plateYear array elements (27 elements)?
    The county element count does seem to match the plateLetter element count.

    What is supposed to be entered into the 3rd input display element of the registration?

    Why not combine your different arrays into on array or a pseudo-hash to avoid miscounting or misplaced array assignments?
    For example:
    Code:
    var counties = [
        "C:Cork", "CE:Clare", "CN:Cavan", "CW:Carlow",
        "D:Dublin", "DL:Donegal", "G:Galway", "KE:Kildare", "KK:Kilkenny", "KY:Kerry",
        "L:Limerick", "LD:Longford", "LH:Louth", "LM:Leitrim", "LS:Laois",
        "MH:Meath", "MN:Monaghan", "MO:Mayo", "OY:Offaly", "RN:Roscommon", "SO:Sligo", 
        "TN:North Tipperary", "TS:South Tipperary", 
        "W:Waterford", "WH:Westmeath", "WX:Wexford", "WW:Wicklow" ]
    You could combine the year and plateYear array in a similar fashion.
    Then it would be a simple process to split the plateLetters and Counties from the registration to display the correct alert message.



    And one suggestion...
    BTW: You should enclose your scripts between [ code] and [ /code] tags (without the spaces)
    to make it easier for forum members to read, copy, paste, debut and revise.
    Last edited by jmrker; 05-06-2014 at 10:25 PM.

  • #3
    Senior Coder jmrker's Avatar
    Join Date
    Aug 2006
    Location
    FL
    Posts
    3,130
    Thanks
    38
    Thanked 504 Times in 498 Posts
    For example, you could use some of this code...

    Code:
    <!DOCTYPE html>
    <html lang="en">
    <head>
    <meta charset="UTF-8" />
    
    <title> HTML5 page </title>
    
    </head>
    <body>
    <form id="myForm" action="#" onsubmit="return validation()"> <!-- for testing purposes -->
    
    <input type="text" id="vehicleYear" value=""> 4-digit Year <p>
    <input type="text" id="countyInfo" value=""> County code <p>
    <input type="submit" value="Submit" onclick="return validation()">
    
    <script type="text/javascript">
    var counties = [
        "C:Cork", "CE:Clare", "CN:Cavan", "CW:Carlow",
        "D:Dublin", "DL:Donegal", "G:Galway", "KE:Kildare", "KK:Kilkenny", "KY:Kerry",
        "L:Limerick", "LD:Longford", "LH:Louth", "LM:Leitrim", "LS:Laois",
        "MH:Meath", "MN:Monaghan", "MO:Mayo", "OY:Offaly", "RN:Roscommon", "SO:Sligo", 
        "TN:North Tipperary", "TS:South Tipperary", 
        "W:Waterford", "WH:Westmeath", "WX:Wexford", "WW:Wicklow" ];
    
    var msg = '';
    var d = new Date();  var cyear = d.getFullYear();
    var vYear = [];  for (y=1990; y<=cyear; y++) { vYear.push(y); }
    // alert(vYear.join('\n'));  // for testing purposes only
    
    function checkCounty(countyCode) {
      var fnd = 'Unknown county';  var tarr = [];
      for (var i=0; i<counties.length; i++) {
        tarr = counties[i].split(':');
        if (tarr[0] == countyCode.toUpperCase()) { fnd = tarr[1]; }
      }
      return fnd;
    }
    
    function validation() {
      msg = '';
      var tmp = document.getElementById('vehicleYear').value;
      if (tmp.length == 4) { msg = tmp.substring(2); } else { msg = 'Missing year'; }
      msg += '\n'+checkCounty(document.getElementById('countyInfo').value);
      alert(msg);
      return false; // for testing purposes
    }
    
    </script>
    
    </body>
    </html>
    Good Luck!


  •  

    Tags for this Thread

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •