1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

Refreshing via submit and using submit button on same form... problem

Discussion in 'Programming' started by WarpedMind, Mar 6, 2008.

  1. #1
    I hope someone out there can help me with this. I'll probably kick myself when I find out what I'm doing wrong... but I'm no expert, so I'll forgive myself for my ignorance. :D

    Here's the issue... I have a form. On the form, I have several fields that refresh the page so that other fields appear with values dependent on the values just entered. I do this by using code like:

    <select name="program" id="program" onChange="document.forms[0].submit();" >

    So, when I select a value for program, if I understand this right, the form gets submitted and basically refreshed. This works great.

    HOWEVER...

    The problem is that I also have a submit button at the bottom of the form. I'm using Dreamweaver, and I've set it up so that, when I hit the submit button, it's supposed to insert a record into a database. As a result, this is what my form tag now looks like:

    <form name="form1" method="POST" action="<%=MM_editAction%>">

    When I run this... as soon as I select a value for one of my refreshing fields, this all craps out. I get the very helpful (read with sarcasm) 500 error. What I think is happening is that, before I added the submit button and submit button code, when a field was refreshed, the form was being submitted to itself... and this is how I got the refresh. However, once I added the button and code, now when I change a value in a refresh field, I think the form wants to do all the stuff that would be done when the submit button is pressed.

    So my question is... since I'm using the onChange="document.forms[0].submit();" code to refresh... how would I code the submit button so that it will do it's insert and open a new page or whatever else I want the form to do? Basically, the form is being expected to do one of two things... either refresh when a certain field value is changed, or insert data to a database and move on to the next page.

    If anyone could please help me... this is an urgent high-visibility project I am working on and I'm totally stuck.

    You can email me at TomGrow AT Gmail DOT Com

    Thanks so much!
     
    WarpedMind, Mar 6, 2008 IP