Connecting Tech Pros Worldwide Help | Site Map

Based on login ID display content

  #1  
Old September 5th, 2008, 07:32 AM
Newbie
 
Join Date: Sep 2008
Posts: 14
Hi

I have one requirement that, Based on the User ID the content should display on the page. How can we do that, I don't have much knowledge on javascript but I tried its not working. Please help me and please refer some gud websites to learn javascript.

Below is the code that I have tried,

Expand|Select|Wrap|Line Numbers
  1.  <script type="text/javascript">
  2.      function pinnu()
  3.      {
  4.      if(document.login.pinnumber.value == '001')
  5.      {
  6.      window.location="paid_Card.html";
  7.      document.getelemntByID("prepaid").card.innerHTML = "test test test";
  8.       }
  9.  
  10.      }
  11.      </script>

Last edited by gits; September 5th, 2008 at 08:27 AM. Reason: added code tags
  #2  
Old September 5th, 2008, 08:38 AM
Ferris's Avatar
Member
 
Join Date: Oct 2007
Location: Shanghai
Posts: 102

re: Based on login ID display content


I am sorry i am not able to get your requirement clearly. What is "User Id" and "content"? Where is it? and what is "paid_Card.html"? Please make it clear.

I can help to fix some syntax error in your code:

line 6 should be:
Expand|Select|Wrap|Line Numbers
  1. window.location.href="paid_Card.html";
line 7 should be:
Expand|Select|Wrap|Line Numbers
  1. document.getElementById("prepaid").card.innerHTML = "test test test";
  #3  
Old September 5th, 2008, 08:54 AM
Newbie
 
Join Date: Sep 2008
Posts: 14

re: Based on login ID display content


Quote:
Originally Posted by Ferris
I am sorry i am not able to get your requirement clearly. What is "User Id" and "content"? Where is it? and what is "paid_Card.html"? Please make it clear.

I can help to fix some syntax error in your code:

line 6 should be:
Expand|Select|Wrap|Line Numbers
  1. window.location.href="paid_Card.html";
line 7 should be:
Expand|Select|Wrap|Line Numbers
  1. document.getElementById("prepaid").card.innerHTML = "test test test";
Hi, Thanks for reply.

The requirement is like this, this is for HTMl page only, There is no backend coding.

1. There are 3 login IDs are there Ex: 001, 002, 003
2. The User will come to the login page and he enter his Id number (ex:001),
3. Onclick on submit button the page will go to paid_Card.html page
4. There is diffrent text or content for diffrent IDs,
Ex: for 001 ( Hi welcome to the test page and read the content)
For 002 ( How are u? what are u doing some text)

5. Based on the user ID (001), the text has to display in paid_Card.html page.

6. If user enters 002 in login page, It will go to same page (paid_Card.html) But the text or content is diffrent.


I think now u will get clear idea. Please let me, if u need more information....
  #4  
Old September 5th, 2008, 09:39 AM
RamananKalirajan's Avatar
Needs Regular Fix
 
Join Date: Mar 2008
Location: Chennai - India
Posts: 344

re: Based on login ID display content


Hi, i hope this will help u out. Just have a look over this code. any doubt post back to the forum

This is your Login Page

[HTML]<html>
<form method="get" action="paid_Card.html">
User Name: <input type="text" name="Uname">
<br/>
<input type="submit" value="Login">
</form>
</html>[/HTML]

paid_Card.html
[HTML]<html>
<head>
<script type="text/javascript">
function checkLogin()
{
var val = location.search;
var x = new Array();
x = val.split("=");
var log=x[1];
if(log=="c001")
document.getElementById('myDiv1').style.display='b lock';
else if(log=="c002")
document.getElementById('myDiv2').style.display='b lock';
else if(log=="c003")
document.getElementById('myDiv3').style.display='b lock';
else
document.getElementById('myDiv4').innerHTML="<font color='red'>You are a invalid User</font>"
}
function doHide()
{
document.getElementById('myDiv1').style.display='n one';
document.getElementById('myDiv2').style.display='n one';
document.getElementById('myDiv3').style.display='n one';
checkLogin();
}
</script>
</head>
<body onload="doHide()">
<div id="mydiv1">
<table>
<tr>
<td>
This is for User c001
</td>
</tr>
</table>
</div>
<div id="mydiv2">
<table>
<tr>
<td>
This is for User c002
</td>
</tr>
</table>

</div>
<div id="mydiv3">
<table>
<tr>
<td>
This is for User c003
</td>
</tr>
</table>
</div>
<div id="myDiv4">
</div>
</body>
</html>[/HTML]

Regards
Ramanan Kalirajan
  #5  
Old September 5th, 2008, 10:14 AM
Newbie
 
Join Date: Sep 2008
Posts: 14

re: Based on login ID display content


Quote:
Originally Posted by RamananKalirajan
Hi, i hope this will help u out. Just have a look over this code. any doubt post back to the forum

This is your Login Page

[HTML]<html>
<form method="get" action="paid_Card.html">
User Name: <input type="text" name="Uname">
<br/>
<input type="submit" value="Login">
</form>
</html>[/HTML]

paid_Card.html
[HTML]<html>
<head>
<script type="text/javascript">
function checkLogin()
{
var val = location.search;
var x = new Array();
x = val.split("=");
var log=x[1];
if(log=="c001")
document.getElementById('myDiv1').style.display='b lock';
else if(log=="c002")
document.getElementById('myDiv2').style.display='b lock';
else if(log=="c003")
document.getElementById('myDiv3').style.display='b lock';
else
document.getElementById('myDiv4').innerHTML="<font color='red'>You are a invalid User</font>"
}
function doHide()
{
document.getElementById('myDiv1').style.display='n one';
document.getElementById('myDiv2').style.display='n one';
document.getElementById('myDiv3').style.display='n one';
checkLogin();
}
</script>
</head>
<body onload="doHide()">
<div id="mydiv1">
<table>
<tr>
<td>
This is for User c001
</td>
</tr>
</table>
</div>
<div id="mydiv2">
<table>
<tr>
<td>
This is for User c002
</td>
</tr>
</table>

</div>
<div id="mydiv3">
<table>
<tr>
<td>
This is for User c003
</td>
</tr>
</table>
</div>
<div id="myDiv4">
</div>
</body>
</html>[/HTML]

Regards
Ramanan Kalirajan
Hi,

Its working fine..... Thank you so much for your help. Please refer me some URLs to learn javascript.
  #6  
Old September 5th, 2008, 11:13 AM
gits's Avatar
Moderator
 
Join Date: May 2007
Location: Munich, Germany
Posts: 4,102
Provided Answers: 1

re: Based on login ID display content


you may have a look at the offsite links thread of our js-forum ...

kind regards
  #7  
Old September 5th, 2008, 12:00 PM
acoder's Avatar
Site Moderator
 
Join Date: Nov 2006
Location: UK
Posts: 14,521
Provided Answers: 12

re: Based on login ID display content


Quote:
Originally Posted by srinathpandit
The requirement is like this, this is for HTMl page only, There is no backend coding.
Since you mention that this is a login ID, you should have this code on the server-side. Anyone could view the source and get the valid IDs.
  #8  
Old September 5th, 2008, 01:27 PM
RamananKalirajan's Avatar
Needs Regular Fix
 
Join Date: Mar 2008
Location: Chennai - India
Posts: 344

re: Based on login ID display content


Quote:
Originally Posted by srinathpandit
Hi,

Its working fine..... Thank you so much for your help. Please refer me some URLs to learn javascript.
Hi I am happy that you got ur requirement. The url's in the first thread named "offsite link" will be useful for u. In future any probs or doubts post it in the forum i will try to help u out. As you asked w3schools will be best for any beginners.

Regards
Ramanan Kalirajan
Reply


Similar Threads
Thread Thread Starter Forum Replies Last Post
ASP.NET: How to conditionally display content based on login/authentication? answers 3 November 19th, 2005 04:48 PM
Role-based security: Access the role of current user Jesper Stocholm answers 2 November 17th, 2005 09:07 PM
I want to edit the table content from www level. Rootshell answers 2 July 17th, 2005 10:52 AM
Questions/Recommendations on Content/Membership Based Website [Sorry, Ended Up Long] Bozo Schmozo answers 11 July 17th, 2005 01:59 AM