Connecting Tech Pros Worldwide Help | Site Map

Based on login ID display content

 
LinkBack Thread Tools Search this Thread
  #1  
Old September 5th, 2008, 06:32 AM
Newbie
 
Join Date: Sep 2008
Posts: 14
Default Based on login ID display content

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 07:27 AM. Reason: added code tags
Reply
  #2  
Old September 5th, 2008, 07:38 AM
Ferris's Avatar
Member
 
Join Date: Oct 2007
Location: Shanghai
Age: 23
Posts: 102
Default

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";
Reply
  #3  
Old September 5th, 2008, 07:54 AM
Newbie
 
Join Date: Sep 2008
Posts: 14
Default

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....
Reply
  #4  
Old September 5th, 2008, 08:39 AM
RamananKalirajan's Avatar
Needs Regular Fix
 
Join Date: Mar 2008
Location: Chennai - India
Age: 24
Posts: 297
Default

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
Reply
  #5  
Old September 5th, 2008, 09:14 AM
Newbie
 
Join Date: Sep 2008
Posts: 14
Default

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.
Reply
  #6  
Old September 5th, 2008, 10:13 AM
gits's Avatar
Moderator
 
Join Date: May 2007
Location: Munich, Germany
Age: 37
Posts: 3,780
Default

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

kind regards
Reply
  #7  
Old September 5th, 2008, 11:00 AM
acoder's Avatar
Site Moderator
 
Join Date: Nov 2006
Location: UK
Posts: 14,235
Default

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.
Reply
  #8  
Old September 5th, 2008, 12:27 PM
RamananKalirajan's Avatar
Needs Regular Fix
 
Join Date: Mar 2008
Location: Chennai - India
Age: 24
Posts: 297
Default

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
Reply

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search


Popular Articles

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over 220,840 network members.