Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1708
  • Last Modified:

How to post from an href..

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
Candis_Sue
Asked:
Candis_Sue
  • 10
  • 5
  • 5
  • +2
1 Solution
 
Dave_GreeneCommented:
<ping>
0
 
Candis_SueAuthor Commented:
that certainly doesn't help...  arrrggg
0
 
hongjunCommented:
Are you trying to get the values of form fields and then redirect to a page with url querystring?

hongjun
0
Independent Software Vendors: 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!

 
Candis_SueAuthor Commented:
Yes, please
0
 
DemonscoutCommented:
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
 
Candis_SueAuthor Commented:
VBScript please.
0
 
hongjunCommented:
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
 
Candis_SueAuthor Commented:
Hate to be rude, but I like to pick the answers.
0
 
venkatg76Commented:
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
 
Candis_SueAuthor Commented:
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
 
Candis_SueAuthor Commented:
venkatg76,

It isn't vbscript but it has potential!  
0
 
hongjunCommented:
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
 
Candis_SueAuthor Commented:
venkatg76,

It gives me an error...

'Document.myform' is null or not an object
0
 
DemonscoutCommented:
myform is the name of the form you are using in you page
0
 
DemonscoutCommented:
myform is the name of the form you are using in you page
0
 
DemonscoutCommented:
opps sorry about double post
0
 
Candis_SueAuthor Commented:
yes, does it matter if it's like this?

myform

when its real name is "MyForm"
0
 
Candis_SueAuthor Commented:
hongjun,

I am trying to do this from a "href=" not a button.
0
 
hongjunCommented:
It matters. JavaScript is case sensitive.

hongjun
0
 
DemonscoutCommented:
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
 
hongjunCommented:
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
 
Candis_SueAuthor Commented:
Worked like a charm!!!

Thanks everyone!!!
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 10
  • 5
  • 5
  • +2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now