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

Posts: 35
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?
liandra is offline
Reply With Quote
View Public Profile
 
When You Register, These Ads Go Away!
Old 09-11-2006, 11:57 AM Re: Javascript to change form post action URL
funkdaddu's Avatar
Web Design Snob

Posts: 636
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>
__________________
Will Work For Talkputation...

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

Posts: 35
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>

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

Posts: 636
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.
__________________
Will Work For Talkputation...
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

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

vB 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 0.12277 seconds with 12 queries