1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

'object is required' error when submitting form

Discussion in 'JavaScript' started by motofzr1000, Feb 15, 2007.

  1. #1
    Hi,

    recently, I downloaded a script to make MySQL database changes through a web interface written in php, and with some javascript. Everything works quite fine, except when I try to make changes to the database.

    I'll explain how the script works... It outputs a table with all fields in a database, and I can add rows and delete them, so that part is working fine. But then I type something in the textfield of an existing table field, to make changes, the table row gets another color to show that a change has been made, and the 'Make changes' submit button gets enabled, which stays disabled if you don't touch the existing fields, so untill here still working fine. But it's when I try to submit the 'form' that I get a javascript error.

    It's saying 'Object is required', and when I look at the lines of the error, it says this:

    function datecheck(month,day,year){ //checks for illegal dates

    obj = document.getElementById(month);
    if(obj.value > 12 || obj.value < 1 || obj.value == "") {
    alert('Enter valid month.');
    return false;
    }

    So I have been trying to figure out what exactly the problem could be, but I can't find it. Have been trying to remove parts of the javascript, but then I got other errors, and it has gone from bad to worse. So I'm a bit stuck here... Is there anyone who can help me with this ? I'll post the full code if someone is interested in checking...

    cheers,

    Jurgen
     

    Attached Files:

    motofzr1000, Feb 15, 2007 IP
  2. phper

    phper Active Member

    Messages:
    247
    Likes Received:
    17
    Best Answers:
    0
    Trophy Points:
    60
    #2
    Looks like document.getElementById(month) doesn't return a valid object.
    Make sure that there is an element with ID passed as 'month' (first parameter) in the document. You may want to try:
    alert(month);
    alert(document.getElementById(month));
     
    phper, Feb 15, 2007 IP