Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Change value onSubmit??

Status
Not open for further replies.

Elliott3

Programmer
Sep 5, 2002
347
CA
I could really use a hand figureing this out... I have the following code with the init() call in the body of the page sop that it is called every so many minutes:

function init(){
window.setTimeout("force_submit()", 1000*10*1)
}
function force_submit(){
alert("Please save your work at regular intervals. Click OK to save your work now.")
document.form_application.elements["action"].value = "SAVE"
document.form_application.action="applicationform2003.asp?Step=<%Response.Write(Request.QueryString("Step"))%>"
document.form_application.submit()
}

the 'action' element is is the name of a submit button. the second reference of action changes the forms action and then it is submitted... i know that the form is submitted to the correct place but the value of the button is not being set... can someone tell me the silly thing that i am doing wrong?

if you need further explanation please just ask :)

CES
 
try:

getElementById("action")

id="action"



______________________________________________________________________________
"The sluggard does not plow after the season, so he begs during the harvest and has nothing."
-[Proverbs 20:4]


 
how about reversing the order of the two "actions", so that you set the action buttons value after changing the form action?

must you name your button "action" ?



=========================================================
-jeff
try { succeed(); } catch(E) { tryAgain(); } finally { rtfm(); }
 
even better... ;)

______________________________________________________________________________
"The sluggard does not plow after the season, so he begs during the harvest and has nothing."
-[Proverbs 20:4]


 
i tried changing the two around but still no go!? i know the word 'action' is an terrible choice of words but the application that i have been thrown into is big enough that it would be a lot of word to change that now... any other suggestions? im lost lol

CES
 
I have have come to realize that elements["action"].value is read-only... its the silly ones that take up your time the most!!

CES
 
You should not name your form element "action". The form does not always know whether you want to change its action, or one of its elements named action. Suggest you pick another name.

Hope this helps,
Dan
 
As I said... If I had created the site from scratch then I would not have used that keyword... Unfortunately, there is a lot of poorly writen code out there and sometimes you have to just deal with it.

CES
 
my last post was not meant to sound rude... thought it could be taken that way... only unhappy with the number of keywords that have been used in this site... definately not the help I am receiveing form this site... Thanks a lot!

CES
 
here's another idea:

document.form_application.action.value = "SAVE"
document.form_application.action="applicationform2003.asp?Step=<%Response.Write(Request.QueryString("Step"))%>"



=========================================================
-jeff
try { succeed(); } catch(E) { tryAgain(); } finally { rtfm(); }
 

>> I had created the site from scratch then I would not have used that keyword

Well - now you are editing the site, so you can go through and fix these things now, surely?

Dan
 

Sometimes you have to bite the bullet and do what would be "more right" - even if it does take time. And I would say that having no form elements called "action" (or "submit", or "method") would definately be "more right".

But that, of course, is just my opinion ;o)

Dan
 
Of course and i am as anal as the next programmer...but how often do you really havce the time to start rewriting code... im also dealing with other worse keywords like 'references' (sql server)... such as life... thanks for the comments.
 
Use a text editor ( to perform multiple find/replace across the whole site. If you need to... use a regular expression to define the pattern to search for/replace.

You ask how often I have the time to rewrite code... I make the time... every time. I am a contractor... and my productivity consists of delivering a quality solution. I learned a long time ago that there is nothing to be gained in cutting corners. If it is going to take time to rewrite some code (so that it works to the client spec) then I put forward the estimate and await the response. If the time is not approved - the rewrite won't happen and the code remains unchanged. That's how I deal with my own code as well as inherited code.

Maybe you just need to go back to the client with a fair estimate on the time to deliver the solution.

Jeff
 
haha...i think i can deal with it...unless you REALLY want me to change it lol
 
k so just to let ya know BabyJeffy i am going through and making the changes to the input fields named action... itll probably be worth it..

tx for the suggestions..
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top