473,513 Members | 4,753 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

submit form to different locations on Radio buttons toggle

sam
Hi All,

I have a form with 4 checkboxes and 4 text boxes and one submit button.
The form should work such a way when I select a particular checkbox and
give a url in text box, the form should get submitted to that url
entered in the text box. Is this possible. I know to submit form by
metioning the action attribute only. How do this with one button but
submitting to different locations on different selection...Can any one
help me proceed further. My form will look something like this.

Thanks,
Sam

<html>
<head>
</head>
<script>
function submitme()
{
var form = document.forms['test_submit'];
var selected = form.elements.chk;

if (selected[0].checked)
{
var url = document.test_submit.text1.value;
form.submit(url); // is this correct at all, I get an error
}
else if (selected[1].checked)
{
do something to submit the value entered in text box
}
else if (selected[2].checked)
{
do something to submit the value entered in text box
}
else if (selected[3].checked)
{
do something to submit the value entered in text box
}
}
</script>
<body>
<div style="border:1px solid red; margin:auto; width: 750px; padding:
20px;">
<form name="test_submit" action="#" method="POST">
<input type="checkbox" name="chk" value="rd1" /><input type="text"
name="text1" />
<br /><br />
<input type="checkbox" name="chk" value="rd2" /><input type="text"
name="text2" />
<br /><br />
<input type="checkbox" name="chk" value="rd2" /><input type="text"
name="text3" />
<br /><br />
<input type="checkbox" name="chk" value="rd2" /><input type="text"
name="text4" />
<br /><br />
<input type="submit" name="submit1" value="Submit to desired value"
onclick="javascript:submitme();">
</form>
</div>
</body>
</html>

May 26 '06 #1
1 2315
"sam" <za*****@gmail.com> skrev i melding
news:11**********************@j73g2000cwa.googlegr oups.com...
Hi All,

I have a form with 4 checkboxes and 4 text boxes and one submit button.
The form should work such a way when I select a particular checkbox and
give a url in text box, the form should get submitted to that url
entered in the text box. Is this possible. I know to submit form by
metioning the action attribute only. How do this with one button but
submitting to different locations on different selection...Can any one
help me proceed further. My form will look something like this.

Thanks,
Sam

<html>
<head>
</head>
<script>
function submitme()
{
var form = document.forms['test_submit'];
var selected = form.elements.chk;

if (selected[0].checked)
{
var url = document.test_submit.text1.value;
form.submit(url); // is this correct at all, I get an error

<snipped/>

Try something like
frm.action=url;

instead, and terminate your onSubmit function with
return true;

--
Dag.
May 26 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
4276
by: Eric | last post by:
Hey Everyone.. I have a form that has approximately 7 text fields and 1 checkbox. Generally when this form is submitted(to itself BTW) it works fine, however, when the checkbox is only field...
3
1878
by: Carlo | last post by:
Hi I have three radio buttons where I need the user to select one of the buttons and its value must be emailed to me using the submit button. I'm using strBody = strBody & "<tr><td>Q1:" &...
2
9577
by: ivanhoe | last post by:
All articles and tutorials I've seen on subject of forms say that if there's name and value for submit button(input tag with type="submit"), they'll get submitted along with the rest of the...
15
2526
by: JR | last post by:
Hi. I hope someone out there who is more versed with JavaScript than I can help me with the following annoying problem. Here's the problem. I have a form with the following layout: Column A...
6
18809
by: HD | last post by:
Hi. I have an asp page with radio buttons and a combobox... when the user clicks a radio button, I want the form to submit so I can execute the ASP code in order to change the list shown in the...
4
5458
by: houstoncity2004 | last post by:
Hi, I need help to JavaScript. I am new to this, and am trying to the page online ASAP. I have two submit buttons on one form, and each button will have to do different things. I named both...
1
2628
by: ansc1 | last post by:
Hello, I'm new to using php coding. I need help with the following: 1. There is a submit button on the form and is saves information to my database. After clicking on "Save Measurement" it...
4
1481
by: FlaPnthrsPunk | last post by:
Hi all, this is my first time ever using PHP, and I am still very new to programming in general. I'm doing an assignment for my Media E-Commerce class where the code for a survey is all provided. ...
5
7508
by: g | last post by:
Hi Guys.. i know this might sound really really simple, but I'm kinda stuck..I have this form..which has a table (created from stored procedure values)..once the table is populated..i have some...
0
7153
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
1
7094
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7519
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5677
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
5079
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
3230
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3218
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1585
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
796
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.