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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Disableing a button after being clicked

Status
Not open for further replies.

NJDrew

Technical User
Dec 21, 2001
31
0
0
US
ok, I have a button on a form. The form is a test. The button at the botton is calling a gradeing fuction declared in the header which then displays the grade to the document. What I need to do is after the test taker clicks the grade button and the grade is written to the document, the gradeing button needs to become diabled or the grading fuction wont execute again until reload of the page. This will mostly prevent the test taker from retrying the test over and over.

Any help would be great.

Drew
 
try this:
Code:
<input type=button name=gradeButton value=&quot;Grade Test&quot; onClick=&quot;
   gradeTest();//or whatever your grading routine is
   this.disabled = true;
&quot;>
 
hi,

Iam giving 2 options , u could use any one ..


<HTML>
<HEAD>
<META NAME=&quot;GENERATOR&quot; Content=&quot;Microsoft Visual Studio 6.0&quot;>
<TITLE></TITLE>
</HEAD>
<BODY>
<SCRIPT LANGUAGE=javascript>
<!--

function gradeTest()//disable
{
gradeButton.disabled = true;
}
function gradeTest2()//hiding
{
gradeButton2.style.visibility=&quot;hidden&quot;
}


//-->
</SCRIPT>

<P> </P>
<input type=button name=gradeButton value=&quot;Grade Test&quot; onClick=&quot;gradeTest()&quot;>
<input type=button name=gradeButton2 value=&quot;Grade Test&quot; onClick=&quot;gradeTest2()&quot;>

</BODY>
</HTML>
 
Thank you Rk_Telagamreddy and bvallet,

bvallet- When I tried the code you recomended it gives me an object exspected error. After playing with it it seems that the code is right, but it wont work inside of the code for the button.

In RK_Telagamreddy's code he/her uses the same property outside of the button so it works perfectly.

RK_Telagamreddy- As stated before the .disable property works great and the the .visability=&quot;Hidden&quot; property will also come in very useful.

Thank you both for your efforts. I am truely stund in your programing abilities, heck event my JavaScript Teacher at school didnt think that this was possible.

Thanks Alot,
Drew
 
So aren't you worried about enterprising students that will view source and see the answers :) (from your description, it sounded like the actual grading was done on the client) Granted, anyone clever enough to do that probably doesn't need to do that, but still :)

also, you may wanna check the code in other browsers to make sure it behaves. I've never used these, but a lot of the DHTMLish stuff like this I've found only works in the IE DOM.

-Scott
 
Scott,
My brother and I are not realy worried about the code being taken because this test will open in a custom made window without menus and my brother(he also is in school with me) who is designing this page has put in some code to disable the right click. So unless he or I missed something there shouldnt be a way to access the source code. But then again it is all about doing what has never been done before, right :). O, about IE, eventhough this test was designed in html/javascript it will never see vast reaches of the WWW, because it will be linked to the main VB program and installed on all client machines. The only reason why the test was made in html/javascript, was because there was no forseeable way to do it in VB 6.0.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top