sending value of a textfield without using form tag to another window

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Sofia
    New Member
    • Nov 2006
    • 11

    sending value of a textfield without using form tag to another window

    Hi
    there is text field and a button.... now i have to send this textfield value to another page without using form tag......i have to use javescript... is there anyone who can help me regarding this problem...?... bye
  • Sofia
    New Member
    • Nov 2006
    • 11

    #2
    sending value of textfield to other asp page using javascript

    i am using this code ..... when i click on button the textfield value is appeared in a textbox.. without using form tag..... now anyone can help me to send this value to an asp page......using javescript... actually i dont want to use form tag..

    Here is the code........... .

    <html>
    <head>
    <title>Untitl ed Document</title>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    <script>
    function submitSearch() {
    alert(document. getElementById( 'searchString') .value);
    }
    </script>

    </head>

    <body>

    <table>
    <td width="140"><in put type="text" name="searchStr ing" id="searchStrin g" class="smallFon t" style="width: 135px;" /></td>
    <td width="25" align="right">< input type="submit" name="searchBut ton" id="searchButto n" onclick="submit Search()" /></td>
    </table>

    </body>
    </html>

    Comment

    • Sofia
      New Member
      • Nov 2006
      • 11

      #3
      how can i send javascript values to other window

      Hi!
      i can get the textfield value in a javescript function ..... without using form tag... now anyone can help me to send this javascript value to another page...Bye

      Comment

      • vee10
        New Member
        • Oct 2006
        • 141

        #4
        hi,

        place the textfield value in the cookie

        document.cookie = escape(value)
        for getting value in other asp page then in onload function of the body
        ie <body onload="getvalu e();">
        <script>
        function getvalue()
        {
        var value=unescape( value);
        }
        </script>
        if u want any references the go to





        Originally posted by Sofia
        Hi!
        i can get the textfield value in a javescript function ..... without using form tag... now anyone can help me to send this javascript value to another page...Bye

        Comment

        • Sofia
          New Member
          • Nov 2006
          • 11

          #5
          Originally posted by vee10
          hi,

          place the textfield value in the cookie

          document.cookie = escape(value)
          for getting value in other asp page then in onload function of the body
          ie <body onload="getvalu e();">
          <script>
          function getvalue()
          {
          var value=unescape( value);
          }
          </script>
          if u want any references the go to

          http://echoecho.com/jscookies.htm
          so nice of u to help me... as i never use cookies before so plz would u plz help me to use cookies in this code...

          here is the code

          <html>
          <head>
          <title>Untitl ed Document</title>
          <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
          <script>
          function submitSearch() {
          alert(document. getElementById( 'searchString') .value);
          }

          </script>

          </head>

          <body>

          <table>
          <td width="140"><in put type="text" name="searchStr ing" id="searchStrin g" class="smallFon t" style="width: 135px;" /></td>
          <td width="25" align="right">< input type="submit" name="searchBut ton" id="searchButto n" onclick="submit Search()" /></td>
          </table>

          </body>
          </html>

          in this code i want to send the input field data to other page.... as on click this input field data is shown in a msg box with the help of javascript... now i have to send this value to other page... as i am not using the form tag..

          Comment

          • Thevercad
            New Member
            • Oct 2006
            • 26

            #6
            hi,

            it would be a great help, if i knew how to pass the values using the cookie property.

            when you say " document.cookie = escape(value) "
            value contains the text box's value. is that right?

            and on the second page, i retrieve it as
            var value = unescape(value) .

            what is the variable that i should use as attribute in the unescape()?
            i'm a bit confused. Can you clear it?

            Thanks.

            Comment

            • vee10
              New Member
              • Oct 2006
              • 141

              #7
              hi,

              this is the code for ur project

              this is just an example that i used a textbox to place the content that is passed
              ok

              Code:
              <%@ Page Language="VB" AutoEventWireup="false" CodeFile="Default.aspx.vb" Inherits="_Default" %>
              
              <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
              
              <html>
              <head>
              <title>Untitled Document</title>
              <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
              <script type="text/javascript">
              function submitSearch() { 
              alert(document.getElementById('searchString').value); 
              document.cookie=escape(document.getElementById('searchString').value);
              window.open("Default2.aspx");
              } 
              
              </script>
              
              </head>
              
              <body>
              <table>
              <tr>
              <td width="140"><input type="text" name="searchString" id="searchString" class="smallFont" style="width: 135px;" /></td> 
              <td width="25" align="right"><input type="submit" name="searchButton" id="searchButton" onclick="submitSearch()" /></td>
              </tr>
              </table> 
              
              </body>
              </html>
              
              other window
              <%@ Page Language="VB" AutoEventWireup="false" CodeFile="Default2.aspx.vb" Inherits="Default2" %>
              
              <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
              
              <html xmlns="http://www.w3.org/1999/xhtml" >
              <head runat="server">
                  <title>Untitled Page</title>
                  <script type="text/javascript">
                  function getcookie()
                  {
                  var cookie=unescape(document.cookie);
                  document.getElementById("TextBox1").value=cookie;
                   }
                  
                  </script>
              </head>
              <body onload="getcookie();">
                  <form id="form1" runat="server">
                  <div>
                      <asp:TextBox ID="TextBox1" runat="server" Style="z-index: 100; left: 200px; position: absolute;
                          top: 136px"></asp:TextBox>
                  
                  </div>
                  </form>
              </body>
              </html>



              Originally posted by Sofia
              so nice of u to help me... as i never use cookies before so plz would u plz help me to use cookies in this code...

              here is the code

              <html>
              <head>
              <title>Untitl ed Document</title>
              <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
              <script>
              function submitSearch() {
              alert(document. getElementById( 'searchString') .value);
              }

              </script>

              </head>

              <body>

              <table>
              <td width="140"><in put type="text" name="searchStr ing" id="searchStrin g" class="smallFon t" style="width: 135px;" /></td>
              <td width="25" align="right">< input type="submit" name="searchBut ton" id="searchButto n" onclick="submit Search()" /></td>
              </table>

              </body>
              </html>

              in this code i want to send the input field data to other page.... as on click this input field data is shown in a msg box with the help of javascript... now i have to send this value to other page... as i am not using the form tag..

              Comment

              • vee10
                New Member
                • Oct 2006
                • 141

                #8
                hi,

                i am sorry a small mistake i have written

                it is not unescape(value)
                it is unescape(docume nt.cookie); in this that textbox value will be returned
                yes it contains the value of the textbox

                if u want to more about the cookie property go to this site which gives u whole details about cookies ok

                http://echoecho.com/jscookies.htm








                Originally posted by Thevercad
                hi,

                it would be a great help, if i knew how to pass the values using the cookie property.

                when you say " document.cookie = escape(value) "
                value contains the text box's value. is that right?

                and on the second page, i retrieve it as
                var value = unescape(value) .

                what is the variable that i should use as attribute in the unescape()?
                i'm a bit confused. Can you clear it?

                Thanks.

                Comment

                • Sofia
                  New Member
                  • Nov 2006
                  • 11

                  #9
                  Thanx 4 ur help...... but if i want to show that text box value in the same window then what will i doo.....

                  Comment

                  • vee10
                    New Member
                    • Oct 2006
                    • 141

                    #10
                    hi,

                    if u want to show in same window then no need of using the cookie directly place an alert box or use document.write or assign the textbox value to another textbox or label





                    Originally posted by Sofia
                    Thanx 4 ur help...... but if i want to show that text box value in the same window then what will i doo.....

                    Comment

                    • Thevercad
                      New Member
                      • Oct 2006
                      • 26

                      #11
                      hey thanks,

                      it is working now. But i'm getting a strange text appended to my textbox's value. It says. " textbox value ; mysheet=wildern ess ".

                      ; mysheet=wildern ess - it seems to be an already existing cookie. So how do i clear a cookie.?

                      Comment

                      • Sofia
                        New Member
                        • Nov 2006
                        • 11

                        #12
                        actually i want to open a new window but not in a separate window .. i want to open a new window in that same window.......

                        Comment

                        • Sofia
                          New Member
                          • Nov 2006
                          • 11

                          #13
                          can this work be done without using cookie......... ....?

                          Comment

                          • vee10
                            New Member
                            • Oct 2006
                            • 141

                            #14
                            hi,

                            sorry for late reply since i am busy with my project
                            ok if ur problem is solved then ok otherwise can u explain me what u want
                            and

                            to clear the cookie u can directly write as
                            document.cookie =" ";

                            ok
                            byeeeee







                            Originally posted by Sofia
                            can this work be done without using cookie......... ....?

                            Comment

                            • Thevercad
                              New Member
                              • Oct 2006
                              • 26

                              #15
                              I did try that...
                              but that text got appended, nonetheless.. :-) But its okay. Thanks to you, i learned to use document.cookie . :-)

                              Comment

                              Working...