does anybody know how to turn off form actions please?
I have 2 types of users (members and non-members) using the same form action. This form has 4 buttons in total.
If the user is a member they have full access to all buttons.
If the user is a non-member they can only use 2 of the 4 buttons.
So, at the moment, when they are non-members and click on one of the members buttons, an OnClick event handler is added to the input type = "submit", which generates a new window with a document explaining to the user that they need to register.
There is no problem generating this window.
The problem is that the form specified in the form action still executes and the members page is still displayed.
So is it possible to turn off the form action in this instance so that the main page isn't refreshed/executed, or do I have to create different form actions for different users.
Surely there must be a way to prevent the form action from being triggered?
I realise I could simply not display the button for non-members, but I'd prefer to do so, as it allows them to see the features that members receive.
With what you have I am not exactly sure how you can prevent any other user from seeing the memebers section or not, unless you have some way of telling a function what type of user is viewing the page. A good way of doing this is with a server side language, such as ColdFusion, PHP, ASP, etc.. where when the page is accessed by a user, it can set a variable, lets call it User, USer = "userstate" where userstate is member or non-member of the simular type, and then as your image link is click a javascript function could be called and wether your variable is member have the function perform the rest of the resulting function call of the click or exit and return a false so that the rest of your function is not called, but I would need to see more of your code to better help you.
As dndpavlik said server side is the best way to handle this. I'm presuming you have some method of determining the members, either through the use of cookies or a database. If so, you should be able to set a boolean variable (eg, isMember) and then change the openWin function as so:
function openWin(LINK){
if (isMember)
aWindow = window.open(LINK, "thewindow", "width=520,height=300");
else
alert("Sorry, you must be a member to continue.");
}
Bookmarks