Welcome to WebmasterWorld Guest from 54.161.149.107

Forum Moderators: open

On click Javascript code!

I need some code please.

   
12:37 am on Jun 8, 2003 (gmt 0)

WebmasterWorld Senior Member dreamcatcher is a WebmasterWorld Top Contributor of All Time 10+ Year Member



Hi guys,

I`m putting a demo version of one of my scripts on my website and I want to disable some features. So, can someone give me a little bit of javascript code so that when say, a "SUBMIT" button is pressed, a message pops up saying "This feature is disabled" and then returns false when "OK" is clicked.

Thank you,

dreamcatcher.

:)

3:45 am on Jun 8, 2003 (gmt 0)

10+ Year Member



What about this:

<script language="JavaScript" type="text/JavaScript">
function notyet() {
alert("This function is not yet available!");
}
</script>

<form onsubmit="JAVASCRIPT:notyet()">
<input type="submit" value="Log on">
</form>

8:00 am on Jun 8, 2003 (gmt 0)

WebmasterWorld Senior Member dreamcatcher is a WebmasterWorld Top Contributor of All Time 10+ Year Member



Cheers mrnoisy, I figured it would be something simple. I don`t really know Javascript that well.

Thanks again.

:)

10:07 am on Jun 9, 2003 (gmt 0)

WebmasterWorld Senior Member blobfisk is a WebmasterWorld Top Contributor of All Time 10+ Year Member



You don't need to include javascript: in the onClick method, it is assumed. Using onSubmit="myFunction()" will do just fine.
10:12 am on Jun 9, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Don't forget to include 'return false', otherwise the form will be submitted anyway.

<form onsubmit="notyet(); return false">

1:06 pm on Jun 9, 2003 (gmt 0)

WebmasterWorld Senior Member dreamcatcher is a WebmasterWorld Top Contributor of All Time 10+ Year Member



Thanks for the tips. I haven`t added "return false" and the code works just fine, the form doesn`t get submitted.

:)

1:24 pm on Jun 9, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



"...haven`t added "return false" and the code works just fine, the form doesn`t get submitted...."
Probably because you don't have an action="..." attribute in your <form...> tag yet.
5:37 pm on Jun 9, 2003 (gmt 0)

WebmasterWorld Senior Member dreamcatcher is a WebmasterWorld Top Contributor of All Time 10+ Year Member



"Probably because you don't have an action="..." attribute in your <form...> tag yet."

Thats correct, I don`t. :)

I have changed it to return false though, because that removes the click action when the button is pressed and I like it better like that.

Whilst we are on the subject of this, how about if I want someone to confirm an action before the action is completed? Say I had "Delete" button and I wanted a box to pop us saying "Are you Sure?", how would I do that? So that yes returns true and no returns false?

Thank you.

:)

5:40 pm on Jun 9, 2003 (gmt 0)

WebmasterWorld Senior Member korkus2000 is a WebmasterWorld Top Contributor of All Time 10+ Year Member



function submitConfirmation(){
var confirmSub = confirm("Are you Sure?");
if (confirmSub){
return true;
}else{
return false;
}
6:35 pm on Jun 9, 2003 (gmt 0)

WebmasterWorld Senior Member dreamcatcher is a WebmasterWorld Top Contributor of All Time 10+ Year Member



Thank you korkus2000. Appreciate the help

:)

 

Featured Threads

Hot Threads This Week

Hot Threads This Month