Solved

How to post from an href..

Posted on 2001-08-22
22
1,686 Views
Last Modified: 2006-11-17
I need to know how to post the pages contents to an ASP from an a href= tag... or if that isn't possible, I need scipt to grab the contents of an input text field and append it to my asp page.  eg..  result.asp?Field1=<<Value>>

Where Value is captured from the text field when the user clicks the link...

Any Ideas?
0
Comment
Question by:Candis_Sue
  • 10
  • 5
  • 5
  • +2
22 Comments
 
LVL 8

Expert Comment

by:Dave_Greene
ID: 6416237
<ping>
0
 

Author Comment

by:Candis_Sue
ID: 6416241
that certainly doesn't help...  arrrggg
0
 
LVL 33

Expert Comment

by:hongjun
ID: 6416250
Are you trying to get the values of form fields and then redirect to a page with url querystring?

hongjun
0
 

Author Comment

by:Candis_Sue
ID: 6416252
Yes, please
0
 

Expert Comment

by:Demonscout
ID: 6416268
You can use javascript to post form information. I wrote a script to call which also went to a new page after the submit.

********Here is the function************
function LoginSubmit(varnewpage){

     document.login.newpage.value = varnewpage;
     document.login.submit();

}

***************************************

******** Put this is the href **********
javascript:LoginSubmit('add_user.asp');

Or you could just do in the link

javascript:document.login.submit();

Hope this helps
0
 

Author Comment

by:Candis_Sue
ID: 6416276
VBScript please.
0
 
LVL 33

Expert Comment

by:hongjun
ID: 6416279
Try this if you intend to using GET method for form

<form name="frmMain" method="get" action="result.asp">
Text1: <input type="text" name="text1">
<br>
Text2: <input type="text" name="text2">
<br>
<input type="submit" value="Click to redirect">
</form>


hongjun
0
 

Author Comment

by:Candis_Sue
ID: 6416280
Hate to be rude, but I like to pick the answers.
0
 
LVL 1

Accepted Solution

by:
venkatg76 earned 100 total points
ID: 6416286
Hi,
check out this..

A.html
-------

<script language=javascript>
function fnSubmit()
{
document.myForm.action="b.asp";
document.myForm.method="get";
document.myForm.submit();
return false;
}
</script>

<form name=myForm>
<input type=text name=txt1>
<input type=text name=txt2>
</form>
<a href="b.asp" onclick="javascript:return fnSubmit()">Click Here to submit data</a>


B.asp
------
<%
For each i in Request.QueryString
  response.write "<br>" & i & "  ---  " & request.querystring(i)
Next
%>

Hope this helps...
0
 

Author Comment

by:Candis_Sue
ID: 6416288
Hi hongjun,

I already have this definition in my page.

<form name="frmMain" method="get" action="result.asp">

It confirms a users login.  What I need is a way to get info from input boxes into my request string.

so I can build the <a href=...

I know what page I want to go to, I just cannot figure out how to get information that has been entered in the page into the href= locale
0
 

Author Comment

by:Candis_Sue
ID: 6416294
venkatg76,

It isn't vbscript but it has potential!  
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 33

Expert Comment

by:hongjun
ID: 6416299
How about this?

<HTML>
<HEAD>
<META NAME="GENERATOR" Content="Microsoft Visual Studio 6.0">
<TITLE></TITLE>

<script language="VBScript">
Sub redirect
     Dim str
     
     str = "result.htm?text1=" & document.frmMain.text1.value
     str = str & "&text2=" & document.frmMain.text2.value
     MsgBox(str)
End Sub
</script>

</HEAD>
<BODY>

<form name="frmMain" method="get" action="result.asp">
Text1: <input type="text" name="text1">
<br>
Text2: <input type="text" name="text2">
<br>
<input type="button" value="Click to redirect" onclick="redirect()">
</form>


</BODY>
</HTML>
0
 

Author Comment

by:Candis_Sue
ID: 6416309
venkatg76,

It gives me an error...

'Document.myform' is null or not an object
0
 

Expert Comment

by:Demonscout
ID: 6416312
myform is the name of the form you are using in you page
0
 

Expert Comment

by:Demonscout
ID: 6416314
myform is the name of the form you are using in you page
0
 

Expert Comment

by:Demonscout
ID: 6416315
opps sorry about double post
0
 

Author Comment

by:Candis_Sue
ID: 6416319
yes, does it matter if it's like this?

myform

when its real name is "MyForm"
0
 

Author Comment

by:Candis_Sue
ID: 6416321
hongjun,

I am trying to do this from a "href=" not a button.
0
 
LVL 33

Expert Comment

by:hongjun
ID: 6416324
It matters. JavaScript is case sensitive.

hongjun
0
 

Expert Comment

by:Demonscout
ID: 6416327
I didn't think it was case sensitive but in the case where I have used it I have kept the case the same
0
 
LVL 33

Expert Comment

by:hongjun
ID: 6416336
This then

<HTML>
<HEAD>
<META NAME="GENERATOR" Content="Microsoft Visual Studio 6.0">
<TITLE></TITLE>

<script language="VBScript">
Function redirect
     Dim str
     
     str = "result.asp?text1=" & document.frmMain.text1.value
     str = str & "&text2=" & document.frmMain.text2.value
     window.location.href = str
End Function
</script>

</HEAD>
<BODY>

<form name="frmMain" method="get" action="result.asp">
Text1: <input type="text" name="text1">
<br>
Text2: <input type="text" name="text2">
<br>
<a onclick="vbscript:redirect()" style="CURSOR:hand">Click here</a>
</form>


</BODY>
</HTML>
0
 

Author Comment

by:Candis_Sue
ID: 6416340
Worked like a charm!!!

Thanks everyone!!!
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

I have helped a lot of people on EE with their coding sources and have enjoyed near about every minute of it. Sometimes it can get a little tedious but it is always a challenge and the one thing that I always say is:  The Exchange of information …
This demonstration started out as a follow up to some recently posted questions on the subject of logging in: http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/Q_28634665.html and http://www.experts-exchange.com/Programming/…
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
Many functions in Excel can make decisions. The most simple of these is the IF function: it returns a value depending on whether a condition you describe is true or false. Once you get the hang of using the IF function, you will find it easier to us…

912 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now