www.webdeveloper.com
Results 1 to 3 of 3

Thread: change the onClick() value of a form

  1. #1
    Join Date
    Mar 2007
    Posts
    2

    change the onClick() value of a form

    How do i change the onClick() value when it is called in a function? Here is the code I have stripped it down to bare bones.

    First time you click it enables the form the second time I want it to alert user its under construction. Im sure its very simple to fix and my syntax is incorrect namely this line

    Code:
    document.form2.edit.onclick()=alert('under construction');


    Code:
    <html>
    <head>
    <title>Script</title>
    
    <script language="Javascript">
    
    function enableForm() {
       
       document.form2.regionID.disabled=false;
       document.form2.selectArea.disabled=false;
       document.form2.edit.value="Upload changes";
       document.form2.edit.onclick()=alert('under construction');  
    }
    </script>
    </head>
    <body>
    
    
    <form name="form2">
      <input type="text" name="region" size="25" id="regionID" disabled="disabled">
      
            <select name="Region" disabled="disabled" id="selectArea">
            <option value="scotland">Scotland</option>
            <option value="north_west">North West</option>
            <option value="north_east">North East</option>
            <option value="west_midlands">West Midlands</option>
            <option value="east_midlands">East midlands</option>
            <option value="wales">Wales</option>
            <option value="anglia">Anglia</option>
            <option value="london">London</option>
            <option value="south_west">South West</option>
            <option value="south_east">South East</option>
          </select>
    	  
    	  
    <input type="text" name="regionid" size="1" id="regionid" disabled="disabled">
    	  
    	  
    <input type="button" id="edit" value="Edit" onClick="enableForm();">
    </form>
    
    </body>
    
    </html>

  2. #2
    Join Date
    Nov 2002
    Posts
    4,473
    Code:
    document.form2.edit.onclick = function () {alert('under construction');}

  3. #3
    Join Date
    Mar 2007
    Posts
    2

    Talking

    thanks for your reply. its really helped

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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



Recent Articles