Connecting Tech Pros Worldwide Forums | Help | Site Map

Based on login ID display content

Newbie
 
Join Date: Sep 2008
Posts: 14
#1: Sep 5 '08
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>

Ferris's Avatar
Member
 
Join Date: Oct 2007
Location: Shanghai
Posts: 102
#2: Sep 5 '08

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";
Newbie
 
Join Date: Sep 2008
Posts: 14
#3: Sep 5 '08

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....
RamananKalirajan's Avatar
Needs Regular Fix
 
Join Date: Mar 2008
Location: Chennai - India
Posts: 349
#4: Sep 5 '08

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
Newbie
 
Join Date: Sep 2008
Posts: 14
#5: Sep 5 '08

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.
gits's Avatar
Moderator
 
Join Date: May 2007
Location: Munich, Germany
Posts: 4,134
#6: Sep 5 '08

re: Based on login ID display content


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

kind regards
acoder's Avatar
Site Moderator
 
Join Date: Nov 2006
Location: UK
Posts: 14,581
#7: Sep 5 '08

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.
RamananKalirajan's Avatar
Needs Regular Fix
 
Join Date: Mar 2008
Location: Chennai - India
Posts: 349
#8: Sep 5 '08

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