Go Back   CodingForums.com > :: Client side development > JavaScript programming

Before you post, read our: Rules & Posting Guidelines

Closed Thread
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 05-12-2011, 10:02 AM   PM User | #1
helloise
New Coder

 
Join Date: Jan 2011
Posts: 79
Thanks: 7
Thanked 0 Times in 0 Posts
helloise has a little shameless behaviour in the past
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
helloise is offline  
Old 05-12-2011, 10:41 AM   PM User | #2
Kor
Red Devil Mod


 
Kor's Avatar
 
Join Date: Apr 2003
Location: Bucharest, ROMANIA
Posts: 8,478
Thanks: 58
Thanked 379 Times in 375 Posts
Kor has a spectacular aura aboutKor has a spectacular aura about
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
-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
Kor is offline  
Old 05-12-2011, 11:06 AM   PM User | #3
helloise
New Coder

 
Join Date: Jan 2011
Posts: 79
Thanks: 7
Thanked 0 Times in 0 Posts
helloise has a little shameless behaviour in the past
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
helloise is offline  
Old 05-12-2011, 11:24 AM   PM User | #4
Kor
Red Devil Mod


 
Kor's Avatar
 
Join Date: Apr 2003
Location: Bucharest, ROMANIA
Posts: 8,478
Thanks: 58
Thanked 379 Times in 375 Posts
Kor has a spectacular aura aboutKor has a spectacular aura about
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
-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
Kor is offline  
Old 05-12-2011, 11:34 AM   PM User | #5
helloise
New Coder

 
Join Date: Jan 2011
Posts: 79
Thanks: 7
Thanked 0 Times in 0 Posts
helloise has a little shameless behaviour in the past
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
}
?>
helloise is offline  
Old 05-12-2011, 11:45 AM   PM User | #6
Kor
Red Devil Mod


 
Kor's Avatar
 
Join Date: Apr 2003
Location: Bucharest, ROMANIA
Posts: 8,478
Thanks: 58
Thanked 379 Times in 375 Posts
Kor has a spectacular aura aboutKor has a spectacular aura about
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
-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
Kor is offline  
Old 05-12-2011, 11:53 AM   PM User | #7
helloise
New Coder

 
Join Date: Jan 2011
Posts: 79
Thanks: 7
Thanked 0 Times in 0 Posts
helloise has a little shameless behaviour in the past
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
helloise is offline  
Old 05-12-2011, 12:12 PM   PM User | #8
Kor
Red Devil Mod


 
Kor's Avatar
 
Join Date: Apr 2003
Location: Bucharest, ROMANIA
Posts: 8,478
Thanks: 58
Thanked 379 Times in 375 Posts
Kor has a spectacular aura aboutKor has a spectacular aura about
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
-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
Kor is offline  
Users who have thanked Kor for this post:
helloise (05-12-2011)
Old 05-12-2011, 12:20 PM   PM User | #9
helloise
New Coder

 
Join Date: Jan 2011
Posts: 79
Thanks: 7
Thanked 0 Times in 0 Posts
helloise has a little shameless behaviour in the past
yikes! finally it works thank you VERY much! i learnt something!
helloise is offline  
Closed Thread

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 06:32 PM.


Advertisement
Log in to turn off these ads.