homepage Welcome to WebmasterWorld Guest from 54.211.138.180
register, free tools, login, search, subscribe, help, library, announcements, recent posts, open posts,
Subscribe and Support WebmasterWorld
Home / Forums Index / Code, Content, and Presentation / JavaScript and AJAX
Forum Library, Charter, Moderator: open

JavaScript and AJAX Forum

    
On click Javascript code!
I need some code please.
dreamcatcher




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

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.

:)

 

mrnoisy




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

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>

dreamcatcher




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

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

Thanks again.

:)

BlobFisk




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

You don't need to include
javascript: in the onClick method, it is assumed. Using onSubmit="myFunction()" will do just fine.
RonPK




msg:1494331
 10:12 am on Jun 9, 2003 (gmt 0)

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

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

dreamcatcher




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

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

:)

ShawnR




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

"...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.

dreamcatcher




msg:1494334
 5:37 pm on Jun 9, 2003 (gmt 0)

"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.

:)

korkus2000




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

function submitConfirmation(){
var confirmSub = confirm("Are you Sure?");
if (confirmSub){
return true;
}else{
return false;
}

dreamcatcher




msg:1494336
 6:35 pm on Jun 9, 2003 (gmt 0)

Thank you korkus2000. Appreciate the help

:)

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / JavaScript and AJAX
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About
© Webmaster World 1996-2014 all rights reserved