Print Page | Close Window

HELP!! Need A Javascript Function

Printed From: Web Wiz Forums
Category: General Discussion
Forum Name: General Discussion
Forum Description: General discussion and chat on any topic.
URL: https://forums.webwiz.net/forum_posts.asp?TID=11352
Printed Date: 01 April 2026 at 1:14am
Software Version: Web Wiz Forums 12.08 - https://www.webwizforums.com


Topic: HELP!! Need A Javascript Function
Posted By: WebDever
Subject: HELP!! Need A Javascript Function
Date Posted: 29 July 2004 at 4:39pm

Hi all,

I've got a Javascript question 4 ya. Now be easy on me I know nowt about Javascript, so if this is full of errors, I'm sorry...

Anyway, I'm trying to create a function that I can use on every submit button through my website. I want the function to change the value of the submit button and then disable the submit and reset buttons, oh yeah and of course - submit the form. This is what I came up with, and yes it doesn't work, I'm a rookie on Javascript

This would be the function (that is in a js file which is included to every page):

function submitForm(frmName, btnSubmit, submitValue, btnReset) 
{
  document[frmName][btnSubmit]value = [submitValue];
  var btnSubmit = document[frmName][btnSubmit]
  var btnReset = document[frmName][btnReset]
  btnSubmit.disabled = true;
  btnReset.disabled = true;
  document[frmName]submit();
}

...and this is what would be in the input tag (for the submit button):

onclick="Javascript:submitForm('frmAddPhoto', 'btnAddPhoto', 'Adding Photo to gallery...', 'btnReset');"

Can somebody please help me, show me what to put where

Thank you for reading



-------------
--Ashley



Replies:
Posted By: dj air
Date Posted: 30 July 2004 at 4:15pm
your doing it the long way ....

function submitForm()
{
   document.formname.btnSubmit.disabled = true;
  document.formname.btnReset.disabled = true;

}

make the input button a submit button
<input Name="Submit Form" Type="submit" Value="" onclick=SubmitForm();" >

that has to be done on evey form.. i hope that helps or have i miss read your post


Posted By: WebDever
Date Posted: 01 August 2004 at 4:36pm

Well, that has helped but, I'd prefer something a bit more dynamic, so I don't have to re-write the function on each page.

Is there a way to do it?



-------------
--Ashley


Posted By: Phat
Date Posted: 01 August 2004 at 9:11pm
I don't know javsscript but bylooking at you code you need the dots between the object names.

function submitForm(frmName, btnSubmit, submitValue, btnReset)
{
  document.[frmName].[btnSubmit].value = [submitValue];
  var btnSubmit = document.[frmName].[btnSubmit]
  var btnReset = document.[frmName].[btnReset]
  btnSubmit.disabled = true;
  btnReset.disabled = true;
  document.[frmName].submit();
}



Posted By: WebDever
Date Posted: 02 August 2004 at 4:28am

Thanks Phat,

I understand the function bit now, but what do I put on the form button - onClick="" ??

Cheerz



-------------
--Ashley



Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.08 - https://www.webwizforums.com
Copyright ©2001-2026 Web Wiz Ltd. - https://www.webwiz.net