Call to javascript function not being called!!

Discussion in 'PHP' started by lost, Nov 30, 2005.

  1. #1
    I have a chunk of php code where the first line is to echo a call to a javascript function...the function doesn't get executed, why??
    Below is the code, please help!

    
    
    <BODY>
    <FORM ID="genericform" ACTION="systemconfig-generic.php" METHOD="post"/>
    
    <INPUT TYPE=submit NAME="newconfigbutton" VALUE="Create New Configuration">
    
      <?php
      if(isset($_POST['newconfigbutton']))
      { 
         echo '<script>displayNewConfig();</script>';  
         echo '<TABLE BORDER="0" CELLSPACING="0" CELLPADDING="0">';
         echo '<TR><BR>';
         echo '<TD><B><FONT SIZE=2>Item 1</TD></B></FONT></TR>';
         echo '<TR><TD ID="textfields"><FONT SIZE=2><SIZE=30>Description<INPUT ID="textfields" TYPE="text" NAME="description" VALUE=""></FONT></SIZE>';
         echo '<FONT SIZE=2><SIZE=30Part Number <INPUT ID="textfields" TYPE="text" NAME="partno" VALUE="" ONKEYDOWN="if (event.keyCode==9) { addNewItem(); }"><BR></TD></FONT></SIZE></TR>';
         echo '</TABLE><BR><BR>';  
      }
      ?>
    
    </FORM>
    </BODY>
    
    <HEAD>  
    <SCRIPT LANGUAGE="Javascript" TYPE="text/javascript">
      function displayNewConfig()
      {    
         document.getElementById('firstChoice').style.display='none';
         document.getElementById('firstChoice').value="";
    
         document.getElementById('secondChoice').style.display='none';
         document.getElementById('secondChoice').value="";
    
         document.getElementById('unitname').style.display='';
         document.getElementById('unitname').focus();    
         
         document.getElementById('unitpartno').style.display='';
         document.getElementById('unitpartno').focus();    
    
         // hide the fake save and cancel buttons
         document.getElementById('dummysave').style.display='none';
         document.getElementById('dummycancel').style.display='none';
    
         // create real submit and cancel buttons
         document.getElementById('save').style.display='';
         document.getElementById('cancel').style.display='';
      }
    </SCRIPT>
    </HEAD>
    
    
    
    Code (markup):

     
    lost, Nov 30, 2005 IP
  2. tresman

    tresman Well-Known Member

    Messages:
    235
    Likes Received:
    20
    Best Answers:
    0
    Trophy Points:
    138
    #2
    Are you really situating the BODY area above the HEAD or is it simply an error when pasting the code here?

    Cause maybe you do not know, but it should be the opposite.
     
    tresman, Nov 30, 2005 IP
  3. lost

    lost Peon

    Messages:
    144
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #3
    :mad:
    YES!
    I'm such a loser, thank you so much!
     
    lost, Nov 30, 2005 IP
  4. tresman

    tresman Well-Known Member

    Messages:
    235
    Likes Received:
    20
    Best Answers:
    0
    Trophy Points:
    138
    #4
    By the way: I didn't want to mean that changing it will work (I don't know, I didn't look at the code itself), but that was so obvious.
     
    tresman, Nov 30, 2005 IP
  5. lost

    lost Peon

    Messages:
    144
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #5
    it did, thank you!
     
    lost, Nov 30, 2005 IP