Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Web Programming > JavaScript > Javascript
|
Javascript General Javascript discussions.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Javascript section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old August 15th, 2003, 03:49 PM
Registered User
 
Join Date: Aug 2003
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to Nazz
Default Change form ACTION value from checkbox value

I've been trying to modify the form's ACTION= value based on the value of a checked checkbox.

What I want it to do is have the value of numerous checkboxes being a url, of say Google's search among one, and a text box that will send the query of the text box value to the value of the url that is checked using the GET method.

so far everthing I've tried that almost worked seemed to send the textbox value and checkbox value as parameters to the locallly saved page.

any suggestions. thanks.


 
Old August 15th, 2003, 04:54 PM
joefawcett's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 3,074
Thanks: 1
Thanked 38 Times in 37 Posts
Default

Don't use a submit button just have an ordinary button. When its onclick handler is called check which checkbox is selected and then set the form's action property before calling the form's submit method.

--

Joe
 
Old March 10th, 2005, 07:25 AM
Registered User
 
Join Date: Mar 2005
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to Mauzer
Default

Well im sort of in the same situation...
I have a form in which you can ask a question. And i want the visitor the be able to select to who he sends the question. I tried a <select multiple> first but that didn't work so i tried check boxes but I just cant get it right. Can somebody help me? I have 5 check boxes with a value which is a email address. (You really cant do this with buttons, because with only five emails you have 31 possibilities.

Thanks in advance.
 
Old March 10th, 2005, 11:50 AM
Registered User
 
Join Date: Mar 2005
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to Mauzer
Default

Found it out :D

[i]
<script type="text/javascript">
function check()
{
address=document.QuestionForm.address
txt=""
for (i=0;i<address.length;++ i)
{
if (address[i].checked)
{
txt=txt + address.value + " "
}
}
document.QuestionForm.action = "mailto:" + txt;
}
</script>







Similar Threads
Thread Thread Starter Forum Replies Last Post
Request action on change and get no action. Help crussell Ajax 0 September 12th, 2007 11:11 AM
form action attribute austinf HTML Code Clinic 2 August 2nd, 2006 08:30 AM
Two action in a form johnjohn Classic ASP Components 1 November 16th, 2004 05:45 PM
I want button action to change current window drb2k2 JSP Basics 0 June 4th, 2003 06:00 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.