Based on login ID display content

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • srinathpandit
    New Member
    • Sep 2008
    • 14

    #1

    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,

    [CODE=javascript] <script type="text/javascript">
    function pinnu()
    {
    if(document.log in.pinnumber.va lue == '001')
    {
    window.location ="paid_Card.htm l";
    document.getele mntByID("prepai d").card.innerH TML = "test test test";
    }

    }
    </script>[/CODE]
    Last edited by gits; Sep 5 '08, 07:27 AM. Reason: added code tags
  • Ferris
    New Member
    • Oct 2007
    • 101

    #2
    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:
    Code:
    window.location.href="paid_Card.html";
    line 7 should be:
    Code:
    document.getElementById("prepaid").card.innerHTML = "test test test";

    Comment

    • srinathpandit
      New Member
      • Sep 2008
      • 14

      #3
      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:
      Code:
      window.location.href="paid_Card.html";
      line 7 should be:
      Code:
      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....

      Comment

      • RamananKalirajan
        Contributor
        • Mar 2008
        • 608

        #4
        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_Ca rd.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.getEle mentById('myDiv 1').style.displ ay='block';
        else if(log=="c002")
        document.getEle mentById('myDiv 2').style.displ ay='block';
        else if(log=="c003")
        document.getEle mentById('myDiv 3').style.displ ay='block';
        else
        document.getEle mentById('myDiv 4').innerHTML=" <font color='red'>You are a invalid User</font>"
        }
        function doHide()
        {
        document.getEle mentById('myDiv 1').style.displ ay='none';
        document.getEle mentById('myDiv 2').style.displ ay='none';
        document.getEle mentById('myDiv 3').style.displ ay='none';
        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

        Comment

        • srinathpandit
          New Member
          • Sep 2008
          • 14

          #5
          Originally posted by RamananKaliraja n
          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_Ca rd.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.getEle mentById('myDiv 1').style.displ ay='block';
          else if(log=="c002")
          document.getEle mentById('myDiv 2').style.displ ay='block';
          else if(log=="c003")
          document.getEle mentById('myDiv 3').style.displ ay='block';
          else
          document.getEle mentById('myDiv 4').innerHTML=" <font color='red'>You are a invalid User</font>"
          }
          function doHide()
          {
          document.getEle mentById('myDiv 1').style.displ ay='none';
          document.getEle mentById('myDiv 2').style.displ ay='none';
          document.getEle mentById('myDiv 3').style.displ ay='none';
          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.

          Comment

          • gits
            Recognized Expert Moderator Expert
            • May 2007
            • 5390

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

            kind regards

            Comment

            • acoder
              Recognized Expert MVP
              • Nov 2006
              • 16032

              #7
              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.

              Comment

              • RamananKalirajan
                Contributor
                • Mar 2008
                • 608

                #8
                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

                Comment

                Working...