?
Solved

URGENT How do I send variables when a user clicks a link without putting it in the link?

Posted on 2003-03-21
11
Medium Priority
?
265 Views
Last Modified: 2013-12-16
I have a problem where I want to send variables when the user clicks a link.  
The variables passed are the username and password so they cannot be appended to the link.  The link is in a ColdFusion page and the link is to a HTML page.  I cannot change the HTML page to ColdFusion because it is actually an InfraActive Lite HTML page.

I have heard that it is possible to send a form from the OnClick event of a link and thought this may be the way to go.  I have sort of tried but did not understand how to send a form and follow a link at the same time.

Can anyone tell me code that works to do this?
0
Comment
Question by:Miriama
  • 5
  • 3
  • 2
  • +1
11 Comments
 
LVL 28

Expert Comment

by:sybe
ID: 8185838
<a href="javascript:document.forms['myform'].submit();">click here to submit the form</a>
0
 
LVL 28

Expert Comment

by:sybe
ID: 8185842
but the problem is that you require username/password to be in hidden formfields. This can be read easily from the source code.

You can not hide username/password in the source of a HTML page.

0
 
LVL 1

Expert Comment

by:spo0ky
ID: 8186709
If I've understood you right, you need to send form and to follow a link with the 1 click, then you need:

<a href="pagename.html" onclick="document.forms['formname'].submit()">click here to submit the form and to follow the link</a>
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
LVL 1

Expert Comment

by:spo0ky
ID: 8186728
or vice versa :)

<a href="javascript:document.forms['formname'].submit()" onclick="document.location.href = 'pagename.html'">click here to submit the form and to follow the link</a>
0
 
LVL 1

Expert Comment

by:spo0ky
ID: 8186729
or vice versa :)

<a href="javascript:document.forms['formname'].submit()" onclick="document.location.href = 'pagename.html'">click here to submit the form and to follow the link</a>
0
 
LVL 1

Expert Comment

by:spo0ky
ID: 8186788
sorry, use window.location.href=, but not document.location.href=.
0
 

Author Comment

by:Miriama
ID: 8187971
You will probably think I am an idiot but what is the code to display these variables on 'pagename.html' in a text field?  I don't understand why everything I am trying is not working.

Also do you know if it is possible to pick up the username and password from the ColdFusion session variables before submitting the form so these variables are not stored in hidden variables on the page?
0
 

Author Comment

by:Miriama
ID: 8188006
You will probably think I am an idiot but what is the code to display these variables on 'pagename.html' in a text field?  I don't understand why everything I am trying is not working.

Also do you know if it is possible to pick up the username and password from the ColdFusion session variables before submitting the form so these variables are not stored in hidden variables on the page?
0
 
LVL 1

Expert Comment

by:spo0ky
ID: 8189123
If I understood you clearly, you need to display some information in the text field, then use this script:

document.forms[formName/formIndex(0-..)].textfieldName.value = "something here"

As for the socond question, sorry, but I've never used ColdFusion and I'm absolutely null in cgi, php and databases.
0
 
LVL 3

Accepted Solution

by:
Adelphi earned 700 total points
ID: 8204570
Miriama,
The ways to submit a form and follow a link are right, but are not really a solution for your scenario.

I'm assuming that the user logged in on another page and that you have retained username and password in session variables for your other CF pages.

So, the ways to send previously-acquired data to another page is:
1. append to URL (not good for password!)
2. submit via a form w/hidden fields (still not good for password)
3. session variables
4. cookies
5. store in database

We've established that 1 & 2 are not secure.  On 3, CF session variables will not pass to an external HTML page (I'm assuming you do not have control over the HTML page).  I think the only other way to do this is to write a cookie that is read by the HTML page.

Finally, you asked how to display variables in a text field.  Do you mean that you need to send the username and password to the HTML page and THEN have them show up as editable fields there?  If so, then try:
<input type="text" name="userName" value="[variablename].value">

Where [variablename] is the code required to place that variable name there.  This will vary depending on what coding language you will be using on that HTML page.
0
 

Author Comment

by:Miriama
ID: 8451525
Sorry didn't get back to you earlier.
Thankyou for your clear explanation of the best way to do it.
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

Is your Office 365 signature not working the way you want it to? Are signature updates taking up too much of your time? Let's run through the most common problems that an IT administrator can encounter when dealing with Office 365 email signatures.
Originally, this post was published on Monitis Blog, you can check it here . It goes without saying that technology has transformed society and the very nature of how we live, work, and communicate in ways that would’ve been incomprehensible 5 ye…
The purpose of this video is to demonstrate how to set up an RSS Feed on a WordPress Website. This will be demonstrated using a Windows 8 PC. Feedburner will be used for this demonstration. Go to your WordPress login page. This will look like the…
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.
Suggested Courses

612 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