SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Member etron's Avatar
    Join Date
    Dec 2003
    Location
    kuala lumpur
    Posts
    7
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Javascript submit not working ...

    Code:
    	<script language = "javascript">
    		function frmdisabletext(Form) {
    			frm = Form;
    			frm.changeuser.value = 'yes';
    			frm.action = 'test.php';
    			frm.submit();
    		}
    	</script>
    
    	<?php
    		$changeuser = $_POST["changeuser"];
    		if ($changeuser == "yes") {
    			$whichuser = $_POST["select_user"];
    
    			switch ($whichuser) {
    				case "teacher":
    					$disabled1 = "disabled";
    					break;
    
    				case "teacher_under":
    					$disabled2 = "disabled";
    					break;
    
    				case "moe":
    					$disabled3 = "disabled";
    					break;
    			}
    		}
    	?>
    
    		<table width="392" height="100%" border="0" cellpadding="0" cellspacing="0">
    
    		<form name="formregister" method="post" action="processRegistration.php">
    		<input type=hidden name="changeuser" value="">
    
            <tr><td><table width="390" height="98%" border="0" cellspacing="0" cellpadding="0" class="tableLine" align="center">
    
    		<tr><td><br><br></td></tr>
    		<TR><TD>
    		  <table width="99%" height="98%" border="0">
                    <tr>
                    <td width="5%" class="text">&nbsp;</td>
                    <td width="35%" class="text">User Type : <?=$changeuser?></td>
                    <td width="54%"><select name="select_user" class="text" onChange="javascript:frmdisabletext(this.form);">
    					<option value="" selected>- Select User Type -</option>
                        <option value="teacher">Teacher</option>
                        <option value="teacher_under">Teacher (under training)</option>
                        <option value="moe">MOE Officer</option>
                      </select></td>
                    <td width="6%">&nbsp;</td>
                  </tr>
                  <tr>
                    <td>&nbsp;</td>
                    <td class="text">Name: <br></td>
                    <td><input name="name" type="text" size="30" class="text"></td>
                    <td>&nbsp;</td>
                  </tr>
                  <tr>
                    <td>&nbsp;</td>
                    <td class="text">State: </td>
                    <td><select name="select_state" class="text">
                    	<option>Perlis</option>
                    	<option>Kedah</option>
                    	<option>Pulau Pinang</option>
                    	<option>Perak</option>
                    	<option>Selangor</option>
                    	<option>Melaka</option>
                    	<option>N. Sembilan</option>
                    	<option>Johor</option>
                    	<option>Kelantan</option>
                    	<option>Terengganu</option>
                    	<option>Pahang</option>
                    	<option>Sabah</option>
                    	<option>Sarawak</option>
                    	<option>Wilayah P. Kuala Lumpur</option>
                    	<option>Wilayah P. Labuan</option>
                    	</select></td>
                    <td>&nbsp;</td>
                  </tr>
                  <tr>
                    <td>&nbsp;</td>
                    <td class="text">District/Town: </td>
                    <td><input name="district" type="text" size="30" class="text" <?=$disabled1?><?=$disabled2?><?=$disabled3?>></td>
                    <td>&nbsp;</td>
                  </tr>
                  <tr>
                    <td>&nbsp;</td>
                    <td class="text">School: </td>
                    <td><input name="school" type="text" size="30" class="text" <?=$disabled1?><?=$disabled2?><?=$disabled3?>></td>
                    <td>&nbsp;</td>
                  </tr>
                  <tr>
                    <td>&nbsp;</td>
                    <td class="text">Level: </td>
                    <td><input name="level" type="text" size="5" class="text"></td>
                    <td>&nbsp;</td>
                  </tr>
                  <tr>
                    <td>&nbsp;</td>
                    <td>&nbsp;</td>
                    <td>
    				<table width="100%" border="0">
                        <tr>
                          <td width="82%" height="28">&nbsp;</td>
                          <input type="submit" class="submit" name="submit" value="Submit">
                          <input type="reset" class="submit" name="reset" value="Reset">
                        </tr>
                      </table></td>
    
                    <td>&nbsp;</td>
    
    
                </table></td></tr>
              </table></td></tr>
    		</form>
    		</table>
    I have this code ... the submit function wont work inside the javascript ... is the naming of the function name causing me the problem? or something else ...

    It is not the page requested not found error ... it is the javascript ... cause there is an error icon in the status bar ... telling me that object doesn't support this method or property on line 6, char 4, code 0, which is : " frm.submit(); "

    please help ... thanx ...

  2. #2
    SitePoint Enthusiast
    Join Date
    Apr 2002
    Posts
    75
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Change onChange="java_script_:frmdisabletext(this.form);" to

    onChange="frmdisabletext(this.form)"

    and in your script change frm.submit() to frm.submit.click();

  3. #3
    SitePoint Wizard silver trophy
    Join Date
    May 2003
    Posts
    1,843
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Here's your problem:
    Code:
    <input type="submit" class="submit" name="submit"......
    ...which overwrites the Form.submit() method, making programmatic submission of the form impossible ("object doesn't support this....method"). Change that name!
    Code:
    function frmdisabletext(oSelect)
    {
    	if (oSelect.options[oSelect.selectedIndex].value)
    	{
    		var oForm = oSelect.form;
    		oForm.elements.changeuser.value = 'yes';
    		oForm.action = 'test.php';
    		oForm.submit();
    	}
    }
    ............
    ............
    <select name="select_user" class="text" onchange="frmdisabletext(this);">
    The click() method should be avoided due to inconsistent support.
    ::: certified wild guess :::

  4. #4
    SitePoint Member etron's Avatar
    Join Date
    Dec 2003
    Location
    kuala lumpur
    Posts
    7
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    thanx for pointing the problem to me ... it is now working as I want it to be ...

    thank you adios and shoop for your replies ....


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
  •