Avatar of yo_bee
yo_bee
Flag for United States of America asked on

ASP Form Get Question

I have a very simple ASP for that I am trying to parse URL

 <form id="form1" runat="server" method="get" action=" https://commerce.wsj.com/auth/group/login?">
    <input type="hidden" name="groupSignOnId" value="XXXXXLaw"/>
    <input type="hidden" name="groupSignOnPassword" value="**********"/>
    <input type="text" name="groupUserKey"/>
    <input type="submit" value="WSJ.com"/>

Open in new window


And I have VB snippet that gets the current username.

 Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        Label1.Text = Environment.UserName()
    End Sub

Open in new window


I want to pass the username to the <input type="text" name="groupUserKey"/> Value=

The final goal of this whole this is to put a Hyperlink on our Intranet to redirect the user to a webpage with the imputs parsed in the URL.

I know it is probably super simple, but I am a newbie at this.
HTMLASPShell Scripting

Avatar of undefined
Last Comment
yo_bee

8/22/2022 - Mon
ASKER CERTIFIED SOLUTION
Big Monty

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
Scott Fell

Is this for classic asp?  

It would be better to use a function instead of a sub.  Then the function can return a value.  Are you getting the username from a querystring? or the sub/function?
<%
username= "yo_bee"  ' or request.querystring("user")
%>
<input type="text" name="groupUserKey" value="<%=username%>"/>

Open in new window

yo_bee

ASKER
Your code changed worked for my preliminary test, but now if I want to put a hyperlink on my SharePoint page to redirect sort of like the form1.
Big Monty

since you're using the GET method in your form, you can just submit it. to do that using a <a> tag, put this in your form:

<a href="#" onclick="return document.form1.submit();">submit form</a>
I started with Experts Exchange in 2004 and it's been a mainstay of my professional computing life since. It helped me launch a career as a programmer / Oracle data analyst
William Peck
yo_bee

ASKER
but do I really need a form to do this?
Could I create a link to point to a code snippet?
Big Monty

it would be more code, but yes, you could. is there a specific reason you don't want to use a form?
Big Monty

keep in mind, this will pass ALL form data to the redirect page, and the page it goes to will be the one in the form action attribute. if you want to redirect to another page, then you'd have to create a custom form submit handler. if you don't mind ALL of the data going to another page, you could do:

<a href="#" onclick="document.form1.action = 'somePage.htm';  document.form1.submit();">submit form</a>
Get an unlimited membership to EE for less than $4 a week.
Unlimited question asking, solutions, articles and more.
yo_bee

ASKER
I am getting the username from the Protect Sub on load.

If there is a better way to get the username I am open to suggestions.
yo_bee

ASKER
I do not think there is a need for a form since this will just me a link on the intranet page to parse a url and redirect it to WSJ.com/logon?
Big Monty

that's usually where you want to load data, I would say thats the best way to do it.
Your help has saved me hundreds of hours of internet surfing.
fblack61
Big Monty

what variables do you want to pass to that page? is it just the user name or is it all of your hidden variables as well? if it's the latter, there's nothing wrong with using a form tag and just submitting the form on a link click. The browser will then parse out the values you want to send in the URL.

Why do you want to write code to do that?
yo_bee

ASKER
Big Monty

then use a form, it's the easiest and quickest way to get your desired results
Get an unlimited membership to EE for less than $4 a week.
Unlimited question asking, solutions, articles and more.
yo_bee

ASKER
Thank you for all you help.