Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 9 of 9
  1. #1
    New Coder
    Join Date
    Jan 2011
    Posts
    79
    Thanks
    7
    Thanked 0 Times in 0 Posts

    return a value in javascript help needed

    i have this line of code:
    Code:
        <a href="#" id="profilelink" name="link2" onClick="viewornot(<?php echo $freechat_id ?>)"><?php echo $freechat_list; ?></a>
        //call the JS onclick and if OK was click do the message box and send button here
    then i have my JS:
    Code:
        function viewornot(id)
        {
           var e = confirm('Do you want to view this profile?');
           if (e == true)
           {
               window.location.href = "http://www-rainbowcode-net/apps_dev.php/profiles/showprofilepersonal?id="+id;
               window.location('http://www-rainbowcode-net/apps_dev.php/profiles/showprofilepersonal?id='+id);
               return true;
           }
           else
           {
              var e2 = confirm('Do you want to send a message?');
              if (e2 == true)
              {
                  //if ok was clicked send value back?? 
                  return e2;
              } 
           }  
         }
    on the e2 confirm: if i clicked OK how can i send a value back(so that i know OK was clicked) so that i can then produce the message box and send button and do the rest of the code to send a message???

    thank you

  • #2
    Kor
    Kor is offline
    Red Devil Mod Kor's Avatar
    Join Date
    Apr 2003
    Location
    Bucharest, ROMANIA
    Posts
    8,478
    Thanks
    58
    Thanked 379 Times in 375 Posts
    Send value back to what? Where do you produce the message box? Where is the "send button"? What kind of element is? What does it do? Which is the whole procedure of "sending message"? Detail, please.
    KOR
    Offshore programming
    -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*

  • #3
    New Coder
    Join Date
    Jan 2011
    Posts
    79
    Thanks
    7
    Thanked 0 Times in 0 Posts
    1. send a value back from where i called the onclick in the href

    2. i will only do the message box and send button once i know it the user clicked on the OK of the confirm in my javascript code

    <a href="#" id="profilelink" name="profilelink" onClick="return viewornot(<?php echo $freechat_id ?>)"><?php echo $freechat_list; ?></a>
    //check here if OK was clicked then produce message box and send button
    if isset($_POST['profilelink']) ///i get error here: Undefined index: profilelink in
    {
    //do message box and send button
    }

    function viewornot(id)
    {
    var e = confirm('Do you want to view this profile?');

    if (e == true)
    {
    window.location.href = "http://www-rainbowcode-net/apps_dev.php/profiles/showprofilepersonal?id="+id;
    window.location('http://www-rainbowcode-net/apps_dev.php/profiles/showprofilepersonal?id='+id);
    return true;
    }
    else
    {
    var e2 = confirm('Do you want to send a message?');
    if (e2 == true)
    {
    document.getElementById('profilelink').value = e2;
    return e2;
    }
    }
    }

    hope this helps??
    thank you

  • #4
    Kor
    Kor is offline
    Red Devil Mod Kor's Avatar
    Join Date
    Apr 2003
    Location
    Bucharest, ROMANIA
    Posts
    8,478
    Thanks
    58
    Thanked 379 Times in 375 Posts
    Quote Originally Posted by helloise View Post
    1. send a value back from where i called the onclick in the href
    To do what, as a next step? Once again, please, detail your aim. You keep on being cryptic.
    KOR
    Offshore programming
    -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*

  • #5
    New Coder
    Join Date
    Jan 2011
    Posts
    79
    Thanks
    7
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by Kor View Post
    To do what, as a next step? Once again, please, detail your aim. You keep on being cryptic.
    here again my JS:

    function viewornot(id)
    {
    var e = confirm('Do you want to view this profile?');

    if (e == true)
    {
    window.location.href = "http://www-rainbowcode-net/apps_dev.php/profiles/showprofilepersonal?id="+id;
    window.location('http://www-rainbowcode-net/apps_dev.php/profiles/showprofilepersonal?id='+id);
    return true;
    }
    else
    {
    var e2 = confirm('Do you want to send a message?');
    if (e2 == true)
    {
    //i know user clicked ok thus wants to send a message
    document.getElementById('profilelink').value = 1;
    return 1;
    }
    }
    }

    <a href="#" id="profilelink" name="profilelink" onClick="return viewornot(<?php echo $freechat_id ?>)"><?php echo $freechat_list; ?></a>

    <?php
    if (isset($_POST['profilelink']) == 1)
    {
    echo "ok was clicked"; //not executing!
    ?>
    //now do a message area with a submit or cancel button
    <textarea name="message" rows="10" cols="20"></textarea>
    <br /><br />
    <input type="submit" value="Send">
    <input type="reset" value="Reset" name='reset'>

    <?php
    }
    ?>

  • #6
    Kor
    Kor is offline
    Red Devil Mod Kor's Avatar
    Join Date
    Apr 2003
    Location
    Bucharest, ROMANIA
    Posts
    8,478
    Thanks
    58
    Thanked 379 Times in 375 Posts
    I have already seen your JS, but I don't understand which is your aim. I need you to describe your aim in plain words.

    I see also you are looking for a PHP query, but I see no form there.
    KOR
    Offshore programming
    -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*

  • #7
    New Coder
    Join Date
    Jan 2011
    Posts
    79
    Thanks
    7
    Thanked 0 Times in 0 Posts
    a user clicks on the link in the href( a nother user's profile)..it calls the JS in the js i ask if the user want to preview the profile of the person he just clicked on..if the user clicks cancel another popup comes up which asks if the user wants to send a message to the profile of the user he clicked on... if the user clicks ok i want to produce a message box with a submit button

    more than this i cant explain...it is just that simple what i want to do... if the user clicked yes bring up a message box with a submit botton

  • #8
    Kor
    Kor is offline
    Red Devil Mod Kor's Avatar
    Join Date
    Apr 2003
    Location
    Bucharest, ROMANIA
    Posts
    8,478
    Thanks
    58
    Thanked 379 Times in 375 Posts
    Finally

    What about this?
    Code:
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
    <html>
    <head>
    <title>Untitled Document</title>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <meta http-equiv="Content-Style-Type" content="text/css">
    <meta http-equiv="Content-Script-Type" content="text/javascript">
    <style type="text/css">
    #messageDiv {
    display:none;
    }
    </style>
    <script type="text/javascript">
    function viewornot(id){
    var e = confirm('Do you want to view this profile?');
    if(e){
    window.location.href = "http://www-rainbowcode-net/apps_dev.php/profiles/showprofilepersonal?id="+id;
    return false
    }
    else{
    	var e2=confirm('Do you want to send a message?');
    	if(e2){
    	var div=document.getElementById('messageDiv');
    	div.style.display='block';
    	}
    }
    return false
    }
    </script>
    </head>
    <body>
    <a href="#" id="profilelink" name="profilelink" onclick="return viewornot('someid')">some list</a>
    <br>
    <div id="messageDiv">
    <form>
    <textarea name="message" rows="10" cols="20"></textarea>
    <br /><br />
    <input type="submit" value="Send">
    <input type="reset" value="Reset" name='reset'>
    </form>
    </div>
    </body>
    </html>
    KOR
    Offshore programming
    -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*

  • Users who have thanked Kor for this post:

    helloise (05-12-2011)

  • #9
    New Coder
    Join Date
    Jan 2011
    Posts
    79
    Thanks
    7
    Thanked 0 Times in 0 Posts
    yikes! finally it works thank you VERY much! i learnt something!


  •  

    Posting Permissions

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