SitePoint Sponsor

User Tag List

Results 1 to 6 of 6
  1. #1
    I'm not a human
    Join Date
    Aug 2006
    Location
    India
    Posts
    281
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    form has no properties error??

    hi ,

    i'm developing an online application.

    and i'm using a same page for adding a new record and then to edit also.

    i'm intended to get the data from the table using the id from the page..

    but there error shows that document.add has no properties..

    Code:
    <script language=javascript src="js/addrole.js"></script>
    <script language=javascript>document.onload(loadentries());</script> 
    <?php	
                $function = $_POST['function'];
    	    $rname    = $_POST['role'];
     	    $per        = $_POST['grpper'];
    	    $id          = $_GET['id'];
    	    $edit       = $_GET['edit'];
    		
    ?>
    
    <center>
      <table align=center width=100% border=0>
    	<form name="add" method=POST action="<?php echo $PHP_SELF;?>" onSubmit= "return check()">
    	<input name="function" type=hidden value="change">
    	<input name="grpper" type=hidden value="<?php echo $per;?>">
    	<tr><td>Enter Role Name </td><td><input type=text name='name' value='<?php echo "$rname"; ?>'></td></tr>
    	<tr height=20><td></td></tr>
    	<tr><td colspan=3>
    		<table frame=box rules=rows border=1 width=100%>
    			<tr><td><b>Select </b></td><td class=cjust><b>View Only</b></td><td class=cjust><b>Create/Edit/Delete</b></td></tr>
    			<tr><td>permission</td><td class=cjust><input type=checkbox name=chk1 value=1></td><td class=cjust><input type=checkbox  name=chk2 value=2></td></tr>
    			<tr><td>permission1</td><td class=cjust><input type=checkbox name=chk3 value=3></td><td class=cjust><input type=checkbox name=chk4 value=4></td></tr>
    
    .
    .
    .
    .
    
    			<tr><td>permission9</td><td class=cjust></td><td class=cjust><input type=checkbox  name=chk15 value=15</td></tr>
    		</table>
    	</td></tr>
    	<tr><td colspan=4 class=rjust><input class="frmbtn" type=button name=add value="Select All" onClick="selall()"></td></tr>
          <tr height=35 align=center><td><input class="frmbtn" type=submit name=add value="Add"></td>
    	    <td><input class="frmbtn" type=reset value="Cancel"></td>
    	</tr>
     	</form>
      </table>  
    
    <?php
    }
    ?>
    the page will add.php for adding and add.php?edit="yes"&id=5 for editing the record with id 5..

    the javascript code

    Code:
    function loadentries()
    {
      alert ("entered");
      alert ("document.add.grpper.value");
      	
    }
    what's the error with this function .??
    pls help me
    Regards,
    Vijay
    Follow me on twitter @vijaycbe
    World Holiday Calander || My Cricket Blog

  2. #2
    SitePoint Member
    Join Date
    Feb 2007
    Posts
    19
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi there,

    First thing i notice is that;

    Code:
    <script language=javascript>document.onload(loadentries());</script>
    Should be;

    Code:
    <script language=javascript>window.onload(loadentries());</script>
    I think . .give that a go!

    Cheers

    Matt

  3. #3
    I'm not a human
    Join Date
    Aug 2006
    Location
    India
    Posts
    281
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    hi

    i tried this and the same problem and the same error.

    when i tried
    var yy = document.getElementById("add"); // note i added the id tag to the form... id="add"
    the alerted value is null.

    but

    var xx = document.add.grpper.value;
    alert (xx); didn't alert anything.

    what's the problem?? anyone pls
    Regards,
    Vijay
    Follow me on twitter @vijaycbe
    World Holiday Calander || My Cricket Blog

  4. #4
    SitePoint Member
    Join Date
    Feb 2007
    Posts
    19
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi there,

    I'm a little confused, is that your only code, or have you chopped it up just for the purpose of this post?

    is the below line placed in the head of your page?

    Code:
    <script language=javascript src="js/addrole.js"></script>
    If not it needs to be i think.

    Cheers

    Matt

  5. #5
    I'm not a human
    Join Date
    Aug 2006
    Location
    India
    Posts
    281
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I'm a little confused, is that your only code, or have you chopped it up just for the purpose of this post?
    yes i really cut down the code ,, but i cut the code php code only the html is same as that..

    and when the page is used to add it's working nicely other than this function and data are inserted correctly.

    is the below line placed in the head of your page?
    yes i think i made it right,

    because The other functions inside the addrole.js are working nicely..
    Regards,
    Vijay
    Follow me on twitter @vijaycbe
    World Holiday Calander || My Cricket Blog

  6. #6
    SitePoint Member
    Join Date
    Feb 2007
    Posts
    4
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Two things

    Have you tried to access your form with this notation ?

    document.forms['add'].elements['your_element'].value

    You should give a try.

    Also please ensure that your JS code is in the head.

    I've made an example below.

    Code:
    <html>
    <head>
    <script type="text/javascript">
     window.onload = function() {
       var frm = document.forms['add'];
       var fld = frm.elements['grpper'];
       alert(fld.value);
     }
    </script>
    </head>
    <body>
       <form name="add" id="add" method="post">
          <input type="text" name="grpper" id="grpper" value="test" />
       </form>
    </body>
    </html>
    Cheers

    Kris


Bookmarks

Posting Permissions

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