SitePoint Sponsor

User Tag List

Results 1 to 5 of 5

Hybrid View

  1. #1
    SitePoint Addict ibeblunt's Avatar
    Join Date
    Jan 2001
    Location
    Jersey City, NJ
    Posts
    312
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Javascript Confirm Box Assistance

    I'm trying to get this Javascript Confirm Box to work? Basically it sends the user a message. They are given an option to either correct it or leave it as is.

    Here is the script below. What could I be doing wrong?

    <script language="JavaScript" type="text/javascript">
    <!--

    var text = "You have an SOHH Account, but you still need to fill out your address properly. Would you like to update your profile?";

    document.write(confirm(text)) {

    top.location.href = "http://www.sohh.com/members/profile/";

    }

    //-->
    </script>

    Also with CSS is there a way to change to colors of an alert box? Just wondering.
    <///////~

    www.sohh.com

  2. #2
    SitePoint Evangelist
    Join Date
    Jul 2001
    Location
    UK
    Posts
    407
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Confirm boxes aren't embedded in the page as such:

    Change

    Code:
    document.write(confirm(text)) { 
    top.location.href = "http://www.sohh.com/members/profile/"; 
    }
    to

    Code:
    confirm(text) { 
    top.location.href = "http://www.sohh.com/members/profile/"; 
    }

  3. #3
    SitePoint Addict ibeblunt's Avatar
    Join Date
    Jan 2001
    Location
    Jersey City, NJ
    Posts
    312
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Now it's not working at all.

    Here what I got:

    <script language="JavaScript" type="text/javascript">
    <!--

    confirm('You have an SOHH Account, but you still need to fill out your address properly. Would you like to update your profile?') { top.location.href = "http://www.sohh.com/members/profile_edit.php?return_URL=/shop/index.php?shopcategoryID=&userid=64276" }

    //-->
    </script>
    <///////~

    www.sohh.com

  4. #4
    SitePoint Addict ibeblunt's Avatar
    Join Date
    Jan 2001
    Location
    Jersey City, NJ
    Posts
    312
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I found something that worked:

    <script language="JavaScript" type="text/javascript">
    <!--

    var agree = confirm('You have an SOHH Account, but you still need to fill out your address properly. Would you like to update your profile?');

    if (agree) {

    top.location.href = "http://www.sohh.com/members/profile_edit.php";

    }

    //-->
    </script>

    Just incase anyone needs this in the future.

    Otherwise, thanks for your help!

    Steven
    <///////~

    www.sohh.com

  5. #5
    SitePoint Evangelist
    Join Date
    Jul 2001
    Location
    UK
    Posts
    407
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Of course. I was pretty stupid. A confirm is pointless without an if statement. Ah well, glad it works now.


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
  •