document hierarchy problem

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • jiing.deng@gmail.com

    document hierarchy problem

    I want to transfer a value "re1" to ldapDeleteUserE xec.php

    The "alert(document .ha)" appears a dialog and shows "undefined. "
    The "alert(document )" shows "object"

    But there seems some problem:
    The error msg said "document.ha.re 1" is null or not a object
    and can't transfer to the ldapDeleteUserE xec.php

    My friend told me that may be a DOM(Document Object Model) problem.
    He said it maybe lack of some tags

    Can anyone give me some suggestions.
    Thanks a lot

    Code:
    <script language="JavaScript">
    function confirmDelete(){
    alert(document.ha);     //<------------here shows undefined
    // but alert(document) shows
    isDelete = confirm("Are you sure you want to delete?");
    
    if(isDelete == false){
    document.ha.re1.value="0";
    alert(document.ha.re1.value);
    }else{
    alert(document.ha.re1.value);
    document.ha.re1.value="1";
    }
    alert(document.ha.re1.value);
    document.ha.submit();
    }
    confirmDelete();
    </script>
    
    <form name="ha" action="./ldapDeleteUserExec.php" method="post">
    <input type="hidden" name="re1" value=""></input>
    <input name="authority" type="hidden" value="$authority" ></input>
    <input name="dealedUserName" type="hidden" value="$dealedUserName"[color=blue]
    ></input>[/color]
    </form>
    The whole php file is in http://nopaste.snit.ch:8001/1864
    (although it's a php file, but I guess the problem is about html and
    javascript)

  • Randell D.

    #2
    Re: document hierarchy problem

    jiing.deng@gmai l.com wrote:[color=blue]
    > I want to transfer a value "re1" to ldapDeleteUserE xec.php
    >
    > The "alert(document .ha)" appears a dialog and shows "undefined. "
    > The "alert(document )" shows "object"
    >
    > But there seems some problem:
    > The error msg said "document.ha.re 1" is null or not a object
    > and can't transfer to the ldapDeleteUserE xec.php
    >
    > My friend told me that may be a DOM(Document Object Model) problem.
    > He said it maybe lack of some tags
    >
    > Can anyone give me some suggestions.
    > Thanks a lot
    >
    >
    Code:
    >  <script language="JavaScript">
    >    function confirmDelete(){
    >    	  alert(document.ha);     //<------------here shows undefined
    >                                   // but alert(document) shows
    >       isDelete = confirm("Are you sure you want to delete?");
    >
    >       if(isDelete == false){
    >       	 document.ha.re1.value="0";
    >       	 alert(document.ha.re1.value);
    >       }else{
    >          alert(document.ha.re1.value);
    >          document.ha.re1.value="1";
    >       }
    >       alert(document.ha.re1.value);
    >       document.ha.submit();
    >    }
    >     confirmDelete();
    >  </script>
    >
    >   <form name="ha" action="./ldapDeleteUserExec.php" method="post">
    >     <input type="hidden" name="re1" value=""></input>
    >     <input name="authority" type="hidden" value="$authority" ></input>
    >     <input name="dealedUserName" type="hidden" value="$dealedUserName"
    >[color=green]
    >></input>[/color]
    >
    >   </form>
    >
    >
    > The whole php file is in http://nopaste.snit.ch:8001/1864
    > (although it's a php file, but I guess the problem is about html and
    > javascript)
    >[/color]

    I'm a newbie with javascript though I'm not doing to bad with it... and
    I have some php experience... I don't know where the problem is but this
    is what I would do to help pin point a solution:

    First - I cannot see how your function confirmDelete gets called - So I
    cannot see how you get any alert boxes in the first place...

    Second... if you do get alert boxes, then you've left out something...
    so this is one thing I would do:

    I would swap the following around:[color=blue]
    > alert(document. ha.re1.value);
    > document.ha.sub mit();[/color]
    so as to look like:[color=blue]
    > document.ha.sub mit();
    > alert(document. ha.re1.value);[/color]

    Then retry and check if you are getting a value in the alert box...

    If that fails you then try this...

    Change your hidden input tag to a visable box (ie type=text as opposed
    to tpye=hidden)

    Change it so that your form posts to a new php script that contains a
    single command - call it testdump.php

    <?
    phpinfo();
    ?>

    Now re-run your form, manually enter a value into your now visable box
    re1 and submit it - Then examine the output of phpinfo() and see if you
    can find what you manually entered.

    What you have done above is pretty basic and I believe should work (but
    obviously it isn't or you wouldn't have posted). I'm wondering if
    you've neglected to include a line or two of code somewhere...I'v e had a
    quick look at the url you gave me and that didn't tell me much else...

    Since I'm eight or nine hours behind you, I'm afraid I'm off to bed now
    so I won't be able to check again until morning - I hope something above
    helps you forward... or that someone else in this ng helps you along the
    way...

    Cheers
    Randell D.

    Comment

    • Jeff North

      #3
      Re: document hierarchy problem

      On 17 Feb 2005 21:27:43 -0800, in comp.lang.javas cript
      jiing.deng@gmai l.com wrote:
      [color=blue]
      >| I want to transfer a value "re1" to ldapDeleteUserE xec.php
      >|
      >| The "alert(document .ha)" appears a dialog and shows "undefined. "
      >| The "alert(document )" shows "object"
      >|
      >| But there seems some problem:
      >| The error msg said "document.ha.re 1" is null or not a object
      >| and can't transfer to the ldapDeleteUserE xec.php[/color]

      Does using document.ha.re1 .value help?
      [color=blue]
      >| My friend told me that may be a DOM(Document Object Model) problem.
      >| He said it maybe lack of some tags
      >|
      >| Can anyone give me some suggestions.
      >| Thanks a lot
      >|
      >|
      Code:
      >|  <script language="JavaScript">
      >|    function confirmDelete(){
      >|    	  alert(document.ha);     //<------------here shows undefined
      >|                                   // but alert(document) shows
      >|       isDelete = confirm("Are you sure you want to delete?");
      >|
      >|       if(isDelete == false){
      >|       	 document.ha.re1.value="0";
      >|       	 alert(document.ha.re1.value);
      >|       }else{
      >|          alert(document.ha.re1.value);
      >|          document.ha.re1.value="1";
      >|       }
      >|       alert(document.ha.re1.value);
      >|       document.ha.submit();
      >|    }
      >|     confirmDelete();
      >|  </script>
      >|
      >|   <form name="ha" action="./ldapDeleteUserExec.php" method="post">
      >|     <input type="hidden" name="re1" value=""></input>
      >|     <input name="authority" type="hidden" value="$authority" ></input>
      >|     <input name="dealedUserName" type="hidden" value="$dealedUserName"
      >| ></input>
      >|   </form>
      >|
      >|
      >| The whole php file is in http://nopaste.snit.ch:8001/1864
      >| (although it's a php file, but I guess the problem is about html and
      >| javascript)[/color]

      ---------------------------------------------------------------
      jnorthau@yourpa ntsyahoo.com.au : Remove your pants to reply
      ---------------------------------------------------------------

      Comment

      • RobB

        #4
        Re: document hierarchy problem

        jiing.deng@gmai l.com wrote:[color=blue]
        > I want to transfer a value "re1" to ldapDeleteUserE xec.php
        >
        > The "alert(document .ha)" appears a dialog and shows "undefined. "
        > The "alert(document )" shows "object"
        >
        > But there seems some problem:
        > The error msg said "document.ha.re 1" is null or not a object
        > and can't transfer to the ldapDeleteUserE xec.php
        >
        > My friend told me that may be a DOM(Document Object Model) problem.
        > He said it maybe lack of some tags
        >
        > Can anyone give me some suggestions.
        > Thanks a lot
        >
        >
        Code:
        >  <script language="JavaScript">
        >    function confirmDelete(){
        >    	  alert(document.ha);     //<------------here shows undefined
        >                                   // but alert(document) shows
        >       isDelete = confirm("Are you sure you want to delete?");
        >
        >       if(isDelete == false){
        >       	 document.ha.re1.value="0";
        >       	 alert(document.ha.re1.value);
        >       }else{
        >          alert(document.ha.re1.value);
        >          document.ha.re1.value="1";
        >       }
        >       alert(document.ha.re1.value);
        >       document.ha.submit();
        >    }
        >     confirmDelete();
        >  </script>
        >
        >   <form name="ha" action="./ldapDeleteUserExec.php" method="post">
        >     <input type="hidden" name="re1" value=""></input>
        >     <input name="authority" type="hidden" value="$authority"
        ></input>
        >     <input name="dealedUserName" type="hidden"[/color]
        value="$dealedUserName"[color=blue][color=green]
        > ></input>[/color]
        >   </form>
        >
        >
        > The whole php file is in http://nopaste.snit.ch:8001/1864
        > (although it's a php file, but I guess the problem is about html and
        > javascript)[/color]

        Imagine you were a parser, reading the file in question.

        When you got to:

        alert(document. ha);

        ....how would you know what 'document.ha' was? Sure, there's a Document
        (object), created when the file began loading, but the <form
        name="ha"...> isn't created until down below (after) the script runs.
        Try pasting it *above* the script block for a better outcome.

        No closing tag for <input>. Hmm...why submit anything at all if the
        delete is aborted? This operation is typically done like so:

        <form name="ha"
        action="./ldapDeleteUserE xec.php"
        method="post"
        onsubmit="retur n confirm('Are you sure you want to delete?')">
        ............... .
        ............... .
        <input type="submit" value="delete" />

        Comment

        • jiing

          #5
          Re: document hierarchy problem

          thanks RobB
          I moved the form to the *above* of the script block, and the script can
          see the document.ha

          -jiing-

          Comment

          Working...