Wrox Programmer Forums
|
Javascript How-To Ask your "How do I do this with Javascript?" questions here.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Javascript How-To 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 4th, 2005, 02:31 AM
Friend of Wrox
 
Join Date: Apr 2005
Posts: 128
Thanks: 0
Thanked 0 Times in 0 Posts
Default Conditional submit

Hi everyone,

I have a form where I have 2 dropdown lists which have a Y or N value. I want to submit the form to some page if the value of list a is Y and to another page if the value of list b is Y. I have a validation function called in the onsubmit of the form tag.I have used document.form.submit in the javascript function where the return value is true. But this code is not working and since I am using the javascript function I am not putting the target page in the action text. I am writing my code below:
--------------------------------------------
if(document.form1.cbopaystatus.value=="N" && document.form1.cboshipmentstatus.value=="Y")
    {
        alert("Shipment status cannot be Shipped if payment status is Unpaid.");
        document.form1.cbopaystatus.focus();
        return false;
    }
if(document.form1.cbopaystatus.value=="Y")
{
   document.form1.submit="aaa.asp"
}
else if(document.form1.cboshipmentstatus.value=="Y")
{
   document.form1.submit="bbb.asp"
}
    return true;
}

Here cbopaystatus & cboshipmentstatus are the 2 dropdown fields which have Y & N as values.

Any help would be appreciated.

Thanks in advance!!
 
Old August 4th, 2005, 02:40 AM
Friend of Wrox
 
Join Date: Oct 2004
Posts: 553
Thanks: 0
Thanked 1 Time in 1 Post
Send a message via MSN to vinod_yadav1919 Send a message via Yahoo to vinod_yadav1919
Default

HII arnabghosh!!

For this you need to set action="aaa.asp"
for example

if(document.form1.cbopaystatus.value=="N" && document.form1.cboshipmentstatus.value=="Y")
    {
        alert("Shipment status cannot be Shipped if payment status is Unpaid.");
        document.form1.cbopaystatus.focus();
        return false;
    }
if(document.form1.cbopaystatus.value=="Y")
{
   document.form1.action="aaa.asp"
}
else if(document.form1.cboshipmentstatus.value=="Y")
{
   document.form1.action="bbb.asp"
}
   document.form1.submit()

//here is your return true;
}


Hope this will help you


Cheers :)

vinod





Similar Threads
Thread Thread Starter Forum Replies Last Post
regarding conditional statements abhi.prince4u XSLT 1 July 21st, 2007 06:00 AM
How to submit the different data on single submit pushpa Classic ASP Databases 1 January 24th, 2007 07:10 PM
conditional IF roy_mm Reporting Services 0 October 30th, 2006 07:52 AM
onUnload Conditional Submit fs22 Javascript 1 March 16th, 2006 02:48 AM
How can we submit a form without a submit butto phpsharma BOOK: Beginning PHP4/PHP 5 ISBN: 978-0-7645-4364-7; v5 ISBN: 978-0-7645-5783-5 4 October 20th, 2003 08:50 AM





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