Simple Asp Code To Print Name?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Kandiman
    New Member
    • Dec 2007
    • 12

    Simple Asp Code To Print Name?

    Hello,

    Im hoping you can help, for now im trying to learn how to do something so an easy example may help me to gain the concept.

    I wish to create a hyperlink that when i click it, it prints my name further down the page.

    I had a search for the last few hours on the <a Href> and onclick command, but this does not make sense?.. the part im getting confused is how am i able to call a function (something like response.write "boo") and get it able to print out on the same page... could some one please write a simple .asp page using vbscript so i can see how its done, then i can try to expand on that myself.

    any help will be appriciated.

    if i havent explained anything correct please feel free to ask, but its only a simple example i want... just so when i click a hyperlink, it prints some text out on the same page.

    The reason i want this, is once i get the concept, i will have a list of the alphabet and on each one will have a sql statement that will return some values....

    Im using .ASP, VBScript. thanks!
  • Kandiman
    New Member
    • Dec 2007
    • 12

    #2
    Okay i realised how to do it, but not in the most stylish way....

    <SCRIPT LANGUAGE="VBScr ipt">
    <!--
    Sub MyFunctionA()
    Dim Letter
    Letter = "You selected A"
    txtResult.Value = Letter
    End Sub
    -->
    </SCRIPT>

    goes at the top, and my code is

    <A href="#" onClick="MyFunc tionA()">a<a>


    and is displayed:

    <Table>
    <tr>
    <td>Name:</td>
    <td><input type="text" name="txtResult "size="40"> </td>
    </tr>
    </Table>


    now just need to know how to pass something back via a variable so i can use response.write? ... any ideas?

    Comment

    • Nicodemas
      Recognized Expert New Member
      • Nov 2007
      • 164

      #3
      You could do somethign like this with JavaScript easily, but if you want ASP to do it, you could:

      Code:
      <%
      dim myName
      myName = request.querystring("n")
      %>
      
      <a href="?n=A">A</a>
      
      <%
      if myName <> "" then
         response.write "I clicked: "& myName
      end if
      %>
      Does this answer your question?

      Comment

      • Kandiman
        New Member
        • Dec 2007
        • 12

        #4
        i since hanged my code, to use javascript and post data,... but now in trying to read post data from my hyperlink...


        <SCRIPT LANGUAGE="JavaS cript">
        <!--
        function AddWithForm()
        {
        //Variables will be retrieved from submitted form
        document.Shows. submit();
        return true;
        }
        -->
        </SCRIPT>

        -------------------------------------------------------

        <FORM id="Shows" name="Shows" method="post" action="Shows.a sp">
        ---------------------------------------------------------
        <%
        'VB Scipt in here (server side)
        dim Vletter
        dim letter

        letter = Request.Form("N umber1")
        Vletter = "The letter you have clicked on is: " & letter
        %>

        -------------------------------------------------------

        <A href="#" id=Number1 name=Number1 value="a" onClick="AddWit hForm()">a<a>

        ---------------------------------------------------------------

        <% Response.Write Vletter %>




        but this is not printing out the value thats been passed "a" just the text "The letter you have clicked on is: "....

        any idea on how to solve this?....

        Comment

        • deric
          New Member
          • Dec 2007
          • 92

          #5
          Maybe you didn't click the "a" link.. the form has to be submitted first before it can get the value of "Number1". On first load of the page, it doesn't have any form to request.

          Comment

          • Nicodemas
            Recognized Expert New Member
            • Nov 2007
            • 164

            #6
            Did you try my code above? It should work just fine.

            Comment

            • chaitanya1167
              New Member
              • Dec 2007
              • 8

              #7
              IN ASP

              Place a LinkButton
              on doubleclick
              Response.Write( "Name");

              Comment

              • Nicodemas
                Recognized Expert New Member
                • Nov 2007
                • 164

                #8
                Unless I completely misunderstood the original request, I have posted a viable solution to the user's problem. He isn't using .NET, as stated in the last sentence of the original topic.

                Comment

                Working...