This works in IE but not FF

Discussion in 'Javascript' started by Martin, Oct 9, 2005.

  1. Martin

    Martin Guest

    I have this simple little script that submits a page where some
    server-side scripting deletes a record from a database. This works as
    expected in IE but it appears that, in FF, the submit is not occurring
    (I'm receiving nothing at the server). FWIW, the "confirm" dialog does
    pop up and I can click OK/Cancel - but nothing happens after that.

    What am I doing wrong?


    function DoDelete(x)
    {
    var resp = confirm('Delete ' + x + '? - Are You Sure?');
    if (resp)
    {
    document.all['deleteThis'].value=x;
    document.forms.frmDisplay.submit();
    }
    }
     
    Martin, Oct 9, 2005
    #1
    1. Advertisements

  2. Martin

    Mick White Guest

    You are using IE proprietary syntax:
    document.all['deleteThis'].value=x; <----
    What is "x", a form control?

    Mick
     
    Mick White, Oct 9, 2005
    #2
    1. Advertisements

  3. David Dorward, Oct 9, 2005
    #3
  4. Martin

    Martin Guest

    Mick / David -

    Thanks for the response but I still can't get this thing to submit. I
    understand what you're saying about the IE-specific syntax. I changed
    the way the passed-in value is assigned but the script still does not
    submit in Firefox. Here's what I changed it to:

    document.getElementById('deleteThis').value=x;

    I've also changed the .submit statement to this:

    document.forms['frmDisplay'].submit();

    but, it didn't seem to make any difference.


    BTW, here's the statement that calls the DoDelete function:

    <input type="button" name="delIt" value="Delete This Record"
    onclick="DoDelete("MyValue");

    where "MyValue" is the data that is used by the server-side script to
    find the proper record in the database.


    Can anyone tell me what the problem is here?

    Thanks again.


     
    Martin, Oct 10, 2005
    #4
  5. Martin

    Mick White Guest

    onclick="DoDelete("MyValue");

    Should be something like the following:
    onclick='DoDelete("MyValue");'

    Without knowing what the function is trying to accomplish, it's
    difficult to say what else may be wrong.
    Mick
     
    Mick White, Oct 10, 2005
    #5
  6. Martin

    Martin Guest

    Yes, you're correct. That was just a typo that occurred when I wrote
    the newsgroup message.
    Here's the entire function (with the modified statements as suggested
    earlier):

    function DoDelete(x)
    {
    var resp = confirm('Delete ' + x + '? - Are You Sure?');
    if (resp)
    {
    document.all['deleteThis'].value=x;
    document.forms['frmDisplay'].submit();
    }
    }

    The function executes OK; the problem is that the "submit" does not
    occur when the page is being viewed in Firefox.


    Any suggestions?

     
    Martin, Oct 10, 2005
    #6
  7. Martin

    Martin Guest

    OK, finally figured this out. These lines work in Firefox:

    document.forms['frmDisplay'].elements['deleteThis'].value=x;
    document.forms['frmDisplay'].submit();
     
    Martin, Oct 10, 2005
    #7
  8. Martin

    Randy Webb Guest

    Martin said the following on 10/10/2005 4:38 PM:
    Imagine that. It works in any other browser as well. And it only took
    you 4 or 5 posts to figure out what you were told in the first one. Now,
    if we can teach you to not top-post..

    --
    Randy
    comp.lang.javascript FAQ - http://jibbering.com/faq & newsgroup weekly
    Answer:It destroys the order of the conversation
    Question: Why?
    Answer: Top-Posting.
    Question: Whats the most annoying thing on Usenet?
     
    Randy Webb, Oct 10, 2005
    #8
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.