Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

JavaScript Forum


You are currently viewing our JavaScript Forum as a guest. Please register to participate.
Login



Reply
Javascript to change form post action URL
Old 09-09-2006, 04:18 AM Javascript to change form post action URL
liandra's Avatar
Experienced Talker

Posts: 35
Trades: 1
hi all,

I'd like to create a login script (for plesk control panel), where there would be 3 fields.

1. Website URL
2. Username
3. Password

and I'd like the Username&Password Post data send to the websiteurl:8443
is it possible to do this with javascript?
__________________

Please login or register to view this content. Registration is FREE


Please login or register to view this content. Registration is FREE
liandra is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 09-11-2006, 12:57 PM Re: Javascript to change form post action URL
funkdaddu's Avatar
Web Design Snob

Posts: 635
Trades: 0
If you have access to the script page, why not just hard-code it into the form?
<form action="http://www.mysite.com:8443/submit.php" ...

or is this a page for multiple sites? In that case you could do something like this:
HTML Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

<html>

	<head>
		<meta http-equiv="content-type" content="text/html;charset=iso-8859-1">
		<title>Untitled Page</title>
		<script type="text/javascript"><!--
function submitForm() {
	this.action = "http://" + this.theSite.value + ":8443/" + this.action;
}

window.onload = function() {
	document.FormName.onsubmit = submitForm;
}
//-->
</script>
	</head>

	<body bgcolor="#ffffff">
		<form id="FormName" action="submit.php" method="get" name="FormName">
			Website URL: <input type="text" name="theSite" value="www.mysite.com" size="24">
			<p>Username: <input type="text" name="u" size="24"></p>
			<p>Password: <input type="password" name="p" size="24"></p>
			<p><input type="submit" name="submitButtonName"></p>
		</form>
		<p></p>
	</body>

</html>

Last edited by funkdaddu; 09-11-2006 at 01:19 PM..
funkdaddu is offline
Reply With Quote
View Public Profile Visit funkdaddu's homepage!
 
Old 09-12-2006, 02:07 AM Re: Javascript to change form post action URL
liandra's Avatar
Experienced Talker

Posts: 35
Trades: 1
it doesn't realy work, after I click on submit it goes to
http://mydomain.tld/submit.php?theSi...mitButtonName=
I tested in Firefox though..

Quote:
Originally Posted by funkdaddu View Post
If you have access to the script page, why not just hard-code it into the form?
<form action="http://www.mysite.com:8443/submit.php" ...

or is this a page for multiple sites? In that case you could do something like this:
HTML Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

<html>

    <head>
        <meta http-equiv="content-type" content="text/html;charset=iso-8859-1">
        <title>Untitled Page</title>
        <script type="text/javascript"><!--
function submitForm() {
    this.action = "http://" + this.theSite.value + ":8443/" + this.action;
}

window.onload = function() {
    document.FormName.onsubmit = submitForm;
}
//-->
</script>
    </head>

    <body bgcolor="#ffffff">
        <form id="FormName" action="submit.php" method="get" name="FormName">
            Website URL: <input type="text" name="theSite" value="www.mysite.com" size="24">
            <p>Username: <input type="text" name="u" size="24"></p>
            <p>Password: <input type="password" name="p" size="24"></p>
            <p><input type="submit" name="submitButtonName"></p>
        </form>
        <p></p>
    </body>

</html>
__________________

Please login or register to view this content. Registration is FREE


Please login or register to view this content. Registration is FREE

Last edited by liandra; 09-12-2006 at 02:08 AM..
liandra is offline
Reply With Quote
View Public Profile
 
Old 09-12-2006, 10:02 AM Re: Javascript to change form post action URL
funkdaddu's Avatar
Web Design Snob

Posts: 635
Trades: 0
Works fine for me in FF. Though FF returns the whole form action url (http://www.site.com/script.php instead of just script.php) so you'll have to hand-code the destination script:
Code:
this.action = "http://" + this.theSite.value + ":8443/process.php";
Though I think you should really use a server-side code, so that it's not javascript dependent.
funkdaddu is offline
Reply With Quote
View Public Profile Visit funkdaddu's homepage!
 
Reply     « Reply to Javascript to change form post action URL
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 1.43492 seconds with 12 queries