Forum Moderators: open

Message Too Old, No Replies

HTML forms & Action Page Results

Passing Form Values in Defined Window

         

jnscollier

1:41 am on Jun 7, 2006 (gmt 0)

10+ Year Member



I have a form where I am trying to submit three fields on a basic html page (username, name, domain). I've searched and searched online and I KNOW this probably sounds so bad... But how do i get my form's field values to display in my action page?

ANY HELP WOULD BE GREAT!
thanks,
****Sammy *** :)

eelixduppy

2:30 am on Jun 7, 2006 (gmt 0)



If you want to create a login page, I would suggest the use of PHP (my personal favorite). This task would then become easy. Let's say you have a form that looks like this:

<form action="test.php" method="post">
Username<input type="text" name="uname" size="40" /><br />
Password<input type="password" name="pass" size="40" /><br />
Domain<input type="text" name="domain" size="40" /><br />
<input type="submit" value="Login!" />
</form>

You would then get these variables in test.php like this (with PHP that is):

echo $_POST["uname"].'<br />';
echo $_POST["pass"].'<br />';
echo $_POST["domain"].'<br />';

This of course only prints them to the browser. You would instead want to check to see if their credentials match. For more information about PHP and how it works, visit the PHP Forum [webmasterworld.com] here at WebmasterWorld.com. Good luck!

jnscollier

2:36 am on Jun 7, 2006 (gmt 0)

10+ Year Member



I've been refreshing this page like crazy! lol! I'm not really doing a login, rather im trying to just display a "confirmation page" I guess. I am not really sure how php works at all... Is there a way to do this in javascript?

eelixduppy

2:41 am on Jun 7, 2006 (gmt 0)



>>> rather im trying to just display a "confirmation page" I guess
What does this confirmation page do exactly? Are you registering a user? I think i would be able to help more if i knew.

jnscollier

2:46 am on Jun 7, 2006 (gmt 0)

10+ Year Member



I'm sorry ...

Here's what I'm trying to do.
I have a site where I am telling a user to copy and paste their code and fill in their affiliate id, domain name, and first and last name in certain areas. (it's kind of like an affiliate program)

Well, I thought, instead of them having to edit all these places themselves, I can just have them enter in their affiliate id, domain name and first and last name into three fields on my page and I would pop open another window where they can copy and paste this html code (with their id, name, and domain) already in there...

Does that make sense? Or would it help if I pasted the code? AHHH! thanks for all your help....

**Sammy :)

eelixduppy

2:59 am on Jun 7, 2006 (gmt 0)



So something like this. Of course you will have to modify it to your own needs:

<html>
<head>
</head>
<body>
<script language='javascript'>
function print_code()
{
document.writeln("First:"+document.form1.first.value+"<br>Last:"+document.form1.last.value);

}

</script>
<form name='form1'>
<input type='text' name='first'><br>
<input type='text' name='last'><br>
<input type="button" onClick="print_code()" value="test">
</form>

</body>
</html>

Good luck!

jnscollier

3:10 am on Jun 7, 2006 (gmt 0)

10+ Year Member



I guess I cant do what I'm trying to do... would it be possible for me to maybe email my code for this one little portion so you can just tell me what I'm doing wrong or at least where to look?

jnscollier

3:12 am on Jun 7, 2006 (gmt 0)

10+ Year Member



Can I not put the html code in the javascript code, bc i actually want to output html code so they can copy and paste it on their page but just be customized with their info? I'm so confused!
the html is messing with the javascript code i think...

eelixduppy

10:47 am on Jun 7, 2006 (gmt 0)



You can set the value of a textarea instead so they will be able to copy the html:

<html>
<head>
</head>
<body>
<script language='javascript'>
function print_code()
{
document.form2.text.value = "First:"+document.form1.first.value+"<br>Last:"+document.form1.last.value;
}

</script>
<form name='form1'>
<input type='text' name='first'><br>
<input type='text' name='last'><br>
<input type="button" onClick="print_code()" value="Add Custom Values!">
</form>

<form name="form2">
<textarea name="text" cols="50" rows="30">Text to be copied</textarea>
</form>

</body>
</html>


I'm not en expert on javascript so there may be a better way to accomplish this.

rocknbil

4:47 pm on Jun 7, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



This should probably have gone in the Javascript forum.

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Get the code</title>

<script type="text/javascript">
function getCode() {
var str = 'name=' + document.getElementById('nm').value +
'&domain=' + document.getElementById('domain').value +
'&id=' + document.getElementById('aff_id').value;
str = str.replace(/ /g, '+'); // Convert spaces in name to encoded string.
// could also use str = str.replace(/ /g, '%20');
var day = new Date();
var id = day.getTime();
var msg = '<html><head><title>Your Code<\/title><\head><body><div style="text-align:center"><p><code>\n'+
str + '<\/code><\/p><form><input type="button" onClick="javascript:window.close();" value="Close Window">\n'+
'<\/form><\/div><\/body><\/html>\n';
var win = open('',id,'width=500,height=500,scrollbars,resizable');
win.document.write(msg);
win.document.close();
}
</script>
</head>
<body>

<form method="get" action="#" name="get_code" id="get_code" onSubmit="return false;">
<label for="aff_id">Your Name:</label> <input type="text" name="nm" id="nm" size="25" maxlength="150" value=""><br>
<label for="aff_id">Affiliate ID:</label> <input type="text" name="aff_id" id="aff_id" size="25" maxlength="150" value=""><br>
<label for="aff_id">Domain:</label> <input type="text" name="domain" id="domain" size="25" maxlength="150" value=""><br>
<input type="submit" onClick="getCode();" value="Get Code">
</form>

</body>
</html>

jnscollier

2:20 am on Jun 8, 2006 (gmt 0)

10+ Year Member



Thanks you guys! I got it! YAY!

shaggy5

12:59 pm on Jun 9, 2006 (gmt 0)

10+ Year Member



It would be easier to do this is ASP. Let me know if you want help. I have done many forms like this in ASP and have confirmations emailed after and such.
Let me know. Would be glad to help. I could also look over your JavaScript if you like and help you try and figure that out.

jnscollier

3:04 pm on Jun 9, 2006 (gmt 0)

10+ Year Member



i "sticky mailed" you!