CodingForums.com

CodingForums.com (http://www.codingforums.com/index.php)
-   JavaScript programming (http://www.codingforums.com/forumdisplay.php?f=2)
-   -   return a value in javascript help needed (http://www.codingforums.com/showthread.php?t=226678)

helloise 05-12-2011 10:02 AM

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

Kor 05-12-2011 10:41 AM

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.

helloise 05-12-2011 11:06 AM

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

Kor 05-12-2011 11:24 AM

Quote:

Originally Posted by helloise (Post 1089714)
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.

helloise 05-12-2011 11:34 AM

Quote:

Originally Posted by Kor (Post 1089718)
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
}
?>

Kor 05-12-2011 11:45 AM

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.

helloise 05-12-2011 11:53 AM

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

Kor 05-12-2011 12:12 PM

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>


helloise 05-12-2011 12:20 PM

yikes! finally it works thank you VERY much! i learnt something!


All times are GMT +1. The time now is 08:21 AM.

Powered by vBulletin®
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.