PDA

View Full Version : Take form data and input to url



hurbin
Dec 28th, 2010, 08:02 PM
Hello,

This is probably simple but I can't seem to find an answer anywhere.

I am trying to take inputed data from a form, in this case will be an IP address and prepend it to a url followed by a port number. Basically i'm trying to make a web form that will allow me to VNC when I click a "Submit" button to which ever ip address I input into said form.

ex. I want data in text form "ip" to go in front of a port number, but after http://. http://x.x.x.x:5900

I have been googling and digging through forum after forum with no luck that really relate to what i'm doing.

Thanks for any response

DanInMa
Dec 28th, 2010, 08:24 PM
You could do this with JavaScript. I don't have time to write up an example, but basically you can use javascript to capture the value the user puts in the form field and opens a new window using the window.open method

you would need to read the form value(http://www.javascript-coder.com/javascript-form/javascript-get-form.htm) on submit , then using javascript prepend the IP address into the URL parameter of window.open ( http://www.javascript-coder.com/window-popup/javascript-window-open.phtml) , while adding the :5800 or what have you to the url.

hurbin
Dec 29th, 2010, 04:00 AM
Cool, thanks! ill give it a try

teedoff
Dec 29th, 2010, 04:54 AM
You could also do it with any server-side script. Pass the user input value as a variable and insert that variable value into your <a href> tag:

<a href = "http://variableName:Port Number></a>

hurbin
Dec 29th, 2010, 05:33 AM
You could also do it with any server-side script. Pass the user input value as a variable and insert that variable value into your <a href> tag:

<a href = "http://variableName:Port Number></a>

Any chance you can give me an example? Kinda new to this whole form thing. Not asking you to write the script for me or anything, just looking for guidance :confused:

teedoff
Dec 29th, 2010, 02:47 PM
Well since I know Coldfusion much better, its really easy to do this.

You would have a form like so:

<form action="somePage.cfm" method="post">
<input type="text" name="ipAdress" />

</form>


The user would enter the IP address in the form field for example: 215.112.78.130.
Then you would pass the form variable to the action page like:

<cfparam name=FORM.ipAddress default="" type="string">

Then down where you want the href link you output the variable like so:

<cfoutput><a href="http://#ipAddress#:8500></a></cfoutput>

Coldfusion variables must be wrapped in hash marks when outputting.

Thats basically it. Now whatever the user types in the form field becomes the value of #ipAddress#.


This could also be done in PHP, but I didnt show you since I would have to spend some time working through it. But you get the basic idea.

hurbin
Dec 29th, 2010, 02:48 PM
awesome, thank you!