Solved

How to pass 2 parameter to other form when click on image button?

Posted on 2004-03-24
10
590 Views
Last Modified: 2010-04-06
<form name="form1" method="post" action="login.asp?username=request.form("username");password=request.form("password") >

<input type = "text" name="username" >
<input type = "password name="password">
<input type = "image" name ="submit" >

==========
login.asp
<% response.write ("request.querystring("username")") %>

why not working?
0
Comment
Question by:zipzip
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
10 Comments
 
LVL 6

Expert Comment

by:jkna_gunn
ID: 10665516
<form name="form1" method="post" action="login.asp">
<input type = "text" name="username" >
<input type = "password name="password">
<input type = "image" name ="submit" >
</form>

=========
login.asp
<% Response.Write Request.QueryString("id") %>
0
 
LVL 2

Expert Comment

by:poopall
ID: 10665715

This should read like this

<%=request.querystring("username") %>


not like

<% response.write ("request.querystring("username")") %>

0
 
LVL 51

Expert Comment

by:Ryan Chong
ID: 10665840
Also, try like:

<% response.write (request("username")) %>

instead of

<% response.write (request.querystring("username")) %>

as QueryString only get the variable when you use form method GET, to make it simple, use as what i stated there.

like:

request("username")
request("password")

Hope this helps
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 35

Expert Comment

by:YZlat
ID: 10667454
try to do the following:

<form name="form1" method="post" action="login.asp?username=<%=request.form("username")%>;password=<%=request.form("password")%> >

<input type = "text" name="username" >
<input type = "password name="password">
<input type = "image" name ="submit" >

or

<form name="form1" method="post" action="login.asp?username=<%=strUserName%>;password=<%=strPassword%> >

<input type = "text" name="username" >
<input type = "password name="password">
<input type = "image" name ="submit" >

<%
Dim strUserName, strPassword
strUserName=request.form("username")
strPassword=request.form("password")
%>
0
 
LVL 35

Expert Comment

by:YZlat
ID: 10667479
also make sure request.querystring("username") is not blank before you print it out.

Another suggestion I'd like to make is do not pass your password as a querystring. It's not secure.
You could use session objects instead
0
 
LVL 1

Accepted Solution

by:
j_chakraverty earned 76 total points
ID: 10672431
just a note on previous comment
Session objects are server side objects one needs ssl for that security

and now the main question WHY NOT WORKING?
it is not working because you are trying to use 2 different methods of passing data together.
One is a post from a web form and another using a url enoded variables.
Judging from your question I think you need the posting
solutions given below

the lines
          <form name="form1" method="post" action="login.asp>
is all u need the rest of the values are encoded and submitted by the browser

                       ----------------------------FORM-----------------------------------
                      <form name="form1" method="post" action="login.asp">
                      <input type = "text" name="username" >
                      <input type = "password name="password">
                      <input type = "image" name ="submit" >

                     ----------------------------login.asp--------------------------
                     <%
                            DIM username, password
         
                              username=Request.Form( "username" )

                        %>
                    ----------------------------------------------------------------
Now u can write it with a response write it with a responce object like this

or you can simply put a asp tag in html page any where u want it like this
                -------------------------------SAMPLE-------------------------------------------------------
                <body>
                 hi this is some formated tect and i shall tell u your name is  <%>=username<%>
                </body>
 
                 ----------------------------------------------------------------------------------------------
the benifit of this approch is we can use a WYSIWYG editor to format the pages responce.write should be used when u want to output a complete page or formated html output say when you are working on a templet system.


---------------------------image submit------------------------
I also think you are trying to use an image as submit button instead of a button
if so u shall need to enclose it in a address tag and put a javascript see example below

<img src="image.gif" width="x" height="y" border="0">
<a href="javascript:form1.submit();"><img src="image-name" border="0"></a>
0
 

Expert Comment

by:wwwgts
ID: 10675928
Like j_chakraverty said there's 2 methods to post the data and coz of that there's also 2 ways to parse the data.

Your form is using method POST and on your asp page you're trying to read the data from URL when POST method actually doesn't put the info in URL. If you want the info to be in URL then you must use method GET with your form then you can parse the data like you did with request.querystring("username") etc, but i don't recommend you to keep username etc on URL so change the method to POST and use the sample which j_chakraverty gave to you.
0
 
LVL 27

Expert Comment

by:skullnobrains
ID: 10688305
just to make it simple, why don't you add a 'value' attribute to your inputs ?

<form name="form1" method="post" action="login.asp">
just one thing the correct syntax is PATH?var1=this&var2=that&... forget about the ';'

<input type = "text" name="username" value="<% =request.form("username"); %>">
i'm not good on asp so just check out if it echoes the needed value allright


<input type = "image" name ="submit" > :(( no good at all, see below

<input type = "image" onClick="javascript:document.forms.form1.submit();" src="..."> (you can add the name attribute but it's useless, you should prefferably use a IMG tag with the onclick and src attributes)

<input type="submit" src="..."> will work on some browsers but not good at all either

<a href="sendtoerrorpagesayingthatyouneedactivejavascript" onClick="javascript:
document.forms.form1.submit();
this.href='#';"><img src="whatever"></a> will let you intercept non javascript-compliant surfers and will show the little hand when you put your mouse over the image !!

the best : just don't use an image for this purpoise when you don't need or just store the image as a background for a simple <input type="submit"> prefferably using CSSs. the image will only be displayed to recent browsers but older ones and javascript-forbidden clients will still be able to press the button !!

==========
login.asp
<% response.write ("request.querystring("username")") %>

of course you can only use this with the 'get' method
btw even with the get method you should not try to store variables in the 'action' attribute of the 'form' tag
just use <input type="hidden" name="variable" value="the_value">

try html forms in google and read a tutorial will prevent you from mixing asp and html problems too often
0
 
LVL 1

Author Comment

by:zipzip
ID: 10701807
thanks everyone ,  I chose to use this method  and it works perfectly :

<script langugage = "javascript">
function form_submit()
{
form1.submit();
}
</script>

<input type = "image" img src = " ../" name = submit onclick ="form_submit();"> // call submit function//

or

<input type...                  onclick ="javascript:form_submit();">

<form name="form1" method="post" action="login.asp"> //posting method//

login.asp
=====

request.form("username")
request.form("password")

and done :)
0
 
LVL 1

Author Comment

by:zipzip
ID: 10701816
opps, sorry

onclick = "javascript: form1.submit();"
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Build and evolve an interactive experience 1 99
CSS display:none AND display:block on same element 3 110
React or Angular? 6 86
Where do I learn ES6? 3 81
Article by: Matthew
I am a very big proponent of technology compliance standards and strive to meet such criteria in all of my work. That includes my site, which is 100% XHTML 1.0 compliant as determined by the World Wide Web Consortium. https://www.matthewstevenkel…
I will show you how to create a ASP.NET Captcha control without using any HTTP HANDELRS or what so ever. you can easily plug it into your web pages. For Example a = 2 + 3 (where 2 and 3 are 2 random numbers) Session("Answer") = 5 then we…
Viewers will learn about if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:
The viewer will learn the benefit of using external CSS files and the relationship between class and ID selectors. Create your external css file by saving it as style.css then set up your style tags: (CODE) Reference the nav tag and set your prop…

749 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question