Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Javascript > submit form to different locations on Radio buttons toggle

Reply
Thread Tools

submit form to different locations on Radio buttons toggle

 
 
sam
Guest
Posts: n/a
 
      05-26-2006
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>

 
Reply With Quote
 
 
 
 
Dag Sunde
Guest
Posts: n/a
 
      05-26-2006
"sam" <> skrev i melding
news: 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.


 
Reply With Quote
 
 
 
Reply

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

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Routing different VLANS to different locations Asger Cisco 1 05-23-2008 11:34 AM
Created Radio Buttons displaying as if they were conventional buttons Dr. Leff Javascript 3 10-15-2007 09:47 PM
Form with two buttons that submit to different pages Kevin Audleman Javascript 2 08-26-2007 04:58 AM
ASP.NET Reset Radio Button in a group of Radio Buttons Scott D Johnson ASP .Net 1 09-27-2006 10:38 PM
Forms with multiple submit buttons vs 'form' objects with single 'submit' methods neil.fitzgerald@ic.ac.uk Python 4 04-14-2006 04:58 PM



Advertisments