SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Zealot
    Join Date
    Jun 2000
    Posts
    165
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hello,

    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.

    Thank you, if you can help,

    Regards,

    Jason


  2. #2
    SitePoint Zealot
    Join Date
    Jun 2000
    Posts
    165
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    the problem exemplified:

    <HTML>
    <HEAD>
    <SCRIPT LANGUAGE = "JavaScript">

    function openWin(LINK){
    aWindow = window.open(LINK, "thewindow", "width=520,height=300");
    }

    </SCRIPT>
    </HEAD>
    </HTML>
    <BODY>
    <FORM>
    <INPUT TYPE = "BUTTON" VALUE = "Open Window" onClick = "openWin('mydoc.html?button=results');">
    </FORM>
    </BODY>
    </HTML>

  3. #3
    SitePoint Member
    Join Date
    Sep 2000
    Posts
    23
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    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.

  4. #4
    SitePoint Guru Vincent Puglia's Avatar
    Join Date
    Feb 2000
    Location
    where the World once stood
    Posts
    700
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi backpack,

    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.");
    }

    Vinny

    Where the World Once Stood
    the blades of grass
    cut me still


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •