Web Wiz - Green Windows Web Hosting

  New Posts New Posts RSS Feed - HELP!! Need A Javascript Function
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

HELP!! Need A Javascript Function

 Post Reply Post Reply
Author
WebDever View Drop Down
Newbie
Newbie


Joined: 28 September 2003
Location: United Kingdom
Status: Offline
Points: 36
Post Options Post Options   Thanks (0) Thanks(0)   Quote WebDever Quote  Post ReplyReply Direct Link To This Post Topic: HELP!! Need A Javascript Function
    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

Back to Top
dj air View Drop Down
Senior Member
Senior Member
Avatar

Joined: 05 April 2002
Location: United Kingdom
Status: Offline
Points: 3627
Post Options Post Options   Thanks (0) Thanks(0)   Quote dj air Quote  Post ReplyReply Direct Link To This Post 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
Back to Top
WebDever View Drop Down
Newbie
Newbie


Joined: 28 September 2003
Location: United Kingdom
Status: Offline
Points: 36
Post Options Post Options   Thanks (0) Thanks(0)   Quote WebDever Quote  Post ReplyReply Direct Link To This Post 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?

Back to Top
Phat View Drop Down
Senior Member
Senior Member


Joined: 23 February 2003
Status: Offline
Points: 386
Post Options Post Options   Thanks (0) Thanks(0)   Quote Phat Quote  Post ReplyReply Direct Link To This Post 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();
}

Back to Top
WebDever View Drop Down
Newbie
Newbie


Joined: 28 September 2003
Location: United Kingdom
Status: Offline
Points: 36
Post Options Post Options   Thanks (0) Thanks(0)   Quote WebDever Quote  Post ReplyReply Direct Link To This Post 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



Edited by WebDever
Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.08
Copyright ©2001-2026 Web Wiz Ltd.


Become a Fan on Facebook Follow us on X Connect with us on LinkedIn Web Wiz Blogs
About Web Wiz | Contact Web Wiz | Terms & Conditions | Cookies | Privacy Notice

Web Wiz is the trading name of Web Wiz Ltd. Company registration No. 05977755. Registered in England and Wales.
Registered office: Web Wiz Ltd, Unit 18, The Glenmore Centre, Fancy Road, Poole, Dorset, BH12 4FB, UK.

Prices exclude VAT at 20% unless otherwise stated. VAT No. GB988999105 - $, € prices shown as a guideline only.

Copyright ©2001-2026 Web Wiz Ltd. All rights reserved.