document.formname has no properties !!!

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • kigoobe
    New Member
    • May 2007
    • 67

    document.formname has no properties !!!

    Well, I'm getting an error. Here is the function, what, according to FF's consolde is generating the error.

    Code:
    function citizen3()
    {
        if (document.ededfil.nationalite[0].checked == true) {
        document.ededfil.pays_origine[0].checked = true;
        document.ededfil.pays_origine[0].disabled = true;
        document.ededfil.pays_origine[1].disabled = true;
        document.ededfil.pays_origine[2].disabled = true;
        } else if (document.ededfil.nationalite[1].checked == true) {
        document.ededfil.pays_origine[0].checked = false;
        document.ededfil.pays_origine[0].disabled = false;
        document.ededfil.pays_origine[1].disabled = false;
        document.ededfil.pays_origine[2].disabled = false;
        }
    }
    The line getting selected by the FF console is

    Code:
    if (document.ededfil.nationalite[0].checked == true) {
    The line that's calling the function is -

    Code:
    <input type="radio" name="nationalite" <? If ($nationalite == "Française") { ?> checked <? }?> value="Française" onClick="citizen3();">&nbsp;&nbsp;&nbsp;Autre&nbsp;&nbsp;&nbsp;<input type="radio" name="nationalite" <? If ($nationalite == "Autre") { ?> checked <? }?> value="Autre" onClick="citizen3();">
    The first line of form is -

    Code:
    <form name="ededfil" id="ededfil" method="post" action="<?=$_SERVER['PHP_SELF']?>" enctype="multipart/form-data">
    The error is -

    document.ededfi l has no properties (FF)
    document.ededfi l.nationalite is null or not an object (IE)

    Note: I've similar functions elsewhere in the site. The javascript file is an external file. I am calling the javascript file through top.php file, ie, the sama javascript is available to all my site. Is it due to any problem of mismatching between different javascript code or I am doing some error?

    Another point. This form appears inside a php condition. Means, the form comes into existence depending on if certain conditions are met. Do you guys think that this may be the reason of this problem?

    If this is the reason, i'll probably need a solution like
    Code:
    if (some php conditions are met) {
      //do something and call that function onclick
    } else {
      //do otherthings and also do something so that I don't get the ... [I]has no properties [/I] error.
    }
    Thanks for any help guys. I would love to get a workaround here ... :)
  • merseyside
    New Member
    • Mar 2007
    • 48

    #2
    Have you done a view source to look at the resulting HTML from your script and tried it as a HTML page, since is a JS error and not a PHP one? Its possible you may have missed a space between the word checked and the name if the input field.

    Comment

    • kigoobe
      New Member
      • May 2007
      • 67

      #3
      Thanks.

      Well, I finally solved it ... I just moved the functions from the external file to the concerned pages ... that way I found a workaround to the php condition's issue ... :)

      Comment

      Working...