View Full Version : Forms
pssparkman
01-03-2008, 08:22 AM
I have two radio buttons, as I want them to hold different information. Both will hold two seperate links and I want the user to select one then hit a GO button. As they hit the GO button, I want them to go to whatever link that was attached to the radio button that is selected. Any suggestions?
jscheuer1
01-03-2008, 03:43 PM
Using HTML alone, you cannot. There are probably various ways. Here's one which requires javascript:
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>
<form action="#" onsubmit="for (var e=this.elements, i = e.length-1; i > -1; --i)
if(e[i].name=='url'&&e[i].checked)
window.location=e[i].value;
return false;">
<div>
<input type="radio" name="url" value="http://www.google.com/">Google<br>
<input type="radio" name="url" value="http://www.dynamicdrive.com/">Dynamic Drive<br>
<input type="submit" value="Go!">
</div>
</form>
</body>
</html>
pssparkman
01-03-2008, 08:05 PM
It worked, Thank You. Is there a way to get them to open up in a new windown or tab when submitted. I have tried to set the form to do it, but it doesn't want to.
Also I another issue that is about the same as the previous one, but one is a link and the other is a form within that I need to be able to run when its radio button is selected and go is hit.
jscheuer1
01-04-2008, 03:06 AM
I'm not that clear on what you are talking about, but see:
http://www.dynamicdrive.com/forums/showthread.php?t=26289
particularly post #3 in that thread. It might be close to what you are saying. When you say a form within, within what?
pssparkman
01-04-2008, 05:38 AM
The form you game me is a form, but one of the radio buttons needs to hold a form of its own. So when that radio button is selected and the submit button is hit. The form that is attached to that radio button will execute. Does that make more sense? Sorry it wasn't clear enough before.
jscheuer1
01-04-2008, 06:44 AM
Something like so? The 'inner' form isn't really inner, and is just the most basic sort of form. It could be a very complex form though:
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>
<form action="#" name="days">
<div>
Days: <input type="text" name="days" value="24">
</div>
</form>
<form action="#" onsubmit="return false;">
<div>
<input type="radio" name="act" value="url::http://www.google.com/">Google<br>
<input type="radio" name="act" value="frm::days">Execute Days<br>
<input type="submit" value="Go!"
onclick="for (var e=this.form.elements, i = e.length-1; i > -1; --i)
if(e[i].name=='act'&&e[i].checked)
if(e[i].value.split('::')[0]=='url')
window.open(e[i].value.split('::')[1],'_blank','top=100, left=250, width=600, height=400, location, resizable');
else if(e[i].value.split('::')[0]=='frm')
document.forms[e[i].value.split('::')[1]].submit();">
</div>
</form>
</body>
</html>
Notes: Once again, javascript is required. If you need more fine tuning, it would probably be easier for me to know exactly what you want the 'inner' form to do.
pssparkman
01-04-2008, 07:42 AM
I know just looking at it, it can be complicated to understand what is going on in it. But as a radio button is selected (two radios max) and then the submit button is clicked. If this particular radio is seleceted I need it to execute this form:
<form action="https://www.paypal.com/cgi-bin/webscr" method="post">
<input type="hidden" name="cmd" value="_xclick">
<input type="hidden" name="business" value="paypal@squadserver.com">
<input type="hidden" name="undefined_quantity" value="1">
<input type="hidden" name="item_name" value="TeamWork Gaming Server Payment">
<input type="hidden" name="item_number" value="QP">
<input type="hidden" name="page_style" value="SquadServer">
<input type="hidden" name="no_shipping" value="1">
<input type="hidden" name="return" value="http://www.squadserver.com/paypal/quickpay.html">
<input type="hidden" name="cn" value="Payment Instructions">
<input type="hidden" name="currency_code" value="USD">
<input type="hidden" name="bn" value="PP-BuyNowBF">
<input type="submit" name="Submit" id="submit2" value="Donations" width="160"/>
</form>
Alone as a form on it own, it does the job. But I have serveral things that can be donated to, so I want the user to select what they want to donate to from the radios. The other donate radios are using web address, as this is too with extra info to fill in the form being used.
I hope it makes sense.
jscheuer1
01-04-2008, 07:57 AM
As I said, it doesn't matter how complex the form is. But the form should have a name, so by substituting your form for the simple form and giving it a name, we can make it work with the code given:
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>
<form action="https://www.paypal.com/cgi-bin/webscr" method="post" name="pp1">
<div>
<input type="hidden" name="cmd" value="_xclick">
<input type="hidden" name="business" value="paypal@squadserver.com">
<input type="hidden" name="undefined_quantity" value="1">
<input type="hidden" name="item_name" value="TeamWork Gaming Server Payment">
<input type="hidden" name="item_number" value="QP">
<input type="hidden" name="page_style" value="SquadServer">
<input type="hidden" name="no_shipping" value="1">
<input type="hidden" name="return" value="http://www.squadserver.com/paypal/quickpay.html">
<input type="hidden" name="cn" value="Payment Instructions">
<input type="hidden" name="currency_code" value="USD">
<input type="hidden" name="bn" value="PP-BuyNowBF">
<input type="submit" name="Submit" id="submit2" value="Donations" width="160"/>
</div>
</form>
<form action="#" onsubmit="return false;">
<div>
<input type="radio" name="act" value="url::http://www.google.com/">Google<br>
<input type="radio" name="act" value="frm::pp1">Make TeamWork Gaming Server Payment<br>
<input type="submit" value="Go!"
onclick="for (var e=this.form.elements, i = e.length-1; i > -1; --i)
if(e[i].name=='act'&&e[i].checked)
if(e[i].value.split('::')[0]=='url')
window.open(e[i].value.split('::')[1],'_blank','top=100, left=250, width=600, height=400, location, resizable');
else if(e[i].value.split('::')[0]=='frm')
document.forms[e[i].value.split('::')[1]].submit();">
</div>
</form>
</body>
</html>
Incidentally, if you want this PayPal form to post open to a new window, just set its target to _blank:
<form target="_blank" action="https://www.paypal.com/cgi-bin/webscr" method="post" name="pp1">
pssparkman
01-04-2008, 03:46 PM
Thanks it works perfect. I know there had to be a way it could be done, both ways.
Or using a server-side language (here PHP):
<?php if(@$_POST['url'])
header('Location: ' . $_POST['url']); ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title>Document sans Titre</title>
</head>
<body>
<form action="<?php echo $_SERVER['REQUEST_URI']; ?>" method="post">
<div>
<label>
<input type="radio" name="url" value="http://www.google.com/">
Google
</label>
<label>
<input type="radio" name="url" value="http://www.yahoo.com/">
Yahoo!
</label>
<label>
<input type="radio" name="url" value="http://www.example.com/">
Example
</label>
</div>
</form>
</body>
</html>This way is better, although it's only possible if you have a scripting-enabled server.
jscheuer1
01-04-2008, 05:44 PM
This way is better, although it's only possible if you have a scripting-enabled server.
I agree that using the server side is better where available, but how do we incorporate the PayPal form as an option, as was worked out in my previous post in this thread?
sticks.cabinets
01-21-2008, 05:59 PM
Integrating paypal into your website;
https://www.paypal.com/IntegrationCenter/ic_standard_home.html#BuyNowButtons
How do I make these work on sitespaces? Sitespaces only uses html in their website builder.
It's a few codes for making paypal buttons. Thank you so much in advance, Phil
jevon2008
01-21-2008, 06:18 PM
Have a situation. I have made a form and I can't get it to just email me the information that I have punched in. I will type the coding in here to see if any of you can help me figure this out. I am having a hard time. And when I do submit the form it opens the email Thunderbird. How can I get it to just send to my email whenever I hit submit? Is there a way to do that. I have been looking for an answer on the internet and it keeps saying something about a php or something like that. What is that.
<!DOCTYPE HTML PUBLIC"-//W3C//DTD HTML 3.2//EN">
<html>
<head>
<title>My first forms page</title>
</head>
<body background bg color="#FFFFFF">
<font size="+4" face="Trebuchet MS, Arail"
color="#990000"><b>HTML Help Line</b></font>
<font face="trabuchet MS, Arail" color="#000066">
<b>
<p>Use this form to submit problems or questions concerning HTML. I'll do my best to answer them, and
if I can't I'll try to direct you to someone else. I'll also post selected problems and solutions that
others night find useful in on this site.
</p>
<form action="MAILTO:jarmstrongbpa2008@yahoo.com" method="post" enctype="text/plain">
<table cellpadding=5>
<tr>
<td align="left" colspan=2><b>Brief problem title:</b><input type="text" name="title" value="" size=60 maxlength=120</td>
</tr>
<tr>
<td align="Left" colspan=2><b>Your name:</b><input type="text" name="name" size=30 maxlength=50></td>
</tr>
<tr>
<td align="Left" colspan=2><b>E-mail address:</b><input type="text" name="mail" value="name@domain.type" size=30 maxlength=50><br>
<font color="#990000"><b>(you must enter your e-mail address correctly, or I won't be able to send you a response)</b></font>
</td>
</tr>
<tr>
<td><b>Describe what youare trying to do and the problem you're having as fully as you can:</b><br>
<textarea name="problem" rows=20 cols=60>
</textarea>
</td>
<td><b>If possible, paste the HTML code from problem page here:</b><br>
<textarea name"code" rows=20 cols=60>
</textarea>
</td>
</tr>
<tr>
<td colspan=23><b>The information below is optional, but I'd appreciate your taking the time to provide it.</b></td>
</tr>
<tr>
<td>
<b>What browser do you use the most?<br>
<select name="browser">
<option>Internet Explorer
<option>Netscape
<option>Mosiac
<option>Firefox
<option>Other
</select>
</b>
</td>
<td>
<b>What editor do you use the most to write HTML?<br>
<input type="radio" name="editor" value="Homesite">Homesite<br>
<input type="radio" name="editor" value="Dreamweaver">Dreamweaver<br>
<input type="radio" name="editor" value="WebEdit">WebEdit<br>
<input type="radio" name="editor" value="Frontpage">FrontPage<br>
<input type="radio" name="editor" value="Netscapegold">Netscapegold<br>
<input type="radio" name="editor" value="other">Other<input type="text" name="othereditor" size=15 maxlength=15>
</b>
</td>
</tr>
<tr>
<td colspan=2><b>How did you find this website?<input type=text" name="findsite" size=50 maxlength=50><br>
<input type="checkbox" name="previous" value="Previous Visitor">Previous Visitor
</b>
</td>
</tr>
<tr>
<td align="center" colspan=2>
<input type="submit" name="submit" value="Submit Information" action="mailto:jarmstrongbpa2008@yahoo.com">
<input type="reset" name="reset" value="Reset">
</td>
</tr>
</table>
</form>
</b>
</font>
</body>
</html>
Powered by vBulletin® Version 4.2.2 Copyright © 2021 vBulletin Solutions, Inc. All rights reserved.