www.webdeveloper.com
Results 1 to 5 of 5

Thread: document.pressed not working in Internet Explorer

  1. #1
    Join Date
    May 2012
    Posts
    38

    document.pressed not working in Internet Explorer

    Hi ,

    I have 'document.pressed ' checking in my javascript code. Problem is it is working fine in Firefox but not in Internet Explorer. I need to make it work in both the browser.

    My code is as follows :

    Code:
    function onSubmitForm()
    {
    if(document.pressed == 'Save')
    {
      ....
    }
    if(document.pressed == 'Run')
    {
     ---
    }
    
    }
    <input type="submit" value = 'Save'  name='SaVE_RUn'
    	onclick = "document.pressed=this.value">
    <input type="submit" value = 'Run'  name='RUn'
    	onclick = "document.pressed=this.value">
    Please help, Thanks.
    Last edited by myuser; 10-09-2012 at 11:38 PM.

  2. #2
    Join Date
    Mar 2009
    Posts
    452
    it not supposed to work in firefox either or you have not posted your code completely. why don't you try defining two functions save() and run() then call from their relative buttons

  3. #3
    Join Date
    May 2012
    Posts
    38
    Hi ZABI,

    This onSubmitForm button has been mentioned in the <form action> . So when I press any one of them , the control goes to this onSubmitForm() and there it checks which button is clicked.
    So writing two functions save() and run() is not possible.
    Can I not somehow check which button is clicked inside the onSubmitForm. If in the 'onclick' of those two buttons I assign value '1' to them and then in onSubmitForm() if I check document.myform.Savebutton.value ==1, something like this.

    I am not able to come up with that. Please help.

    Thanks.

  4. #4
    Join Date
    May 2012
    Posts
    38
    Well ZABI, I could make that work. Now document.myform.action = "myscript.pl" is not working in IE. Here 'myform' is my form name and 'myscript.pl' is a script where I want the action to go upon submission of my form. thanks.

  5. #5
    Join Date
    Mar 2009
    Posts
    452
    i assume you are trying to change the action value depending upon the button clicked. i've tested the following to work in IE9

    <script>
    function onSubmitForm(){
    alert(myform.action);
    }
    </script>
    <form name="myform" action="default.pl" onsubmit="onSubmitForm();" method="post">
    <input type="submit" value = 'Save' name='SaVE_RUn' onclick = "myform.action='save.pl';">
    <input type="submit" value = 'Run' name='RUn' onclick = "myform.action='run.pl';">
    </form>

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