在提交时动态更改表单后期操作

时间:2013-01-25 22:53:47

标签: forms

我正在尝试根据用户按下提交时在下拉列表中做出的选择动态地进行表单更改后期操作。一旦做出选择,我就让它工作了,但这会覆盖我的验证规则。

我正在处理的网站的网址是instaloan.glidewebdesign.com

根据“汽车标题状态”下拉列表中的选项,我希望根据答案提交不同的帖子操作。

提前感谢所有帮助!!!!!!

function set_form_action()
{
    if (page == 'clear_title')
    {
        window.location = 'https://secure.leads360.com/Import.aspx?   Provider=TMXFinance&Client=TMXFinance&CampaignId=1034&Url=http://instaloan.glidewebdesign.com/index.php/thank-you';
    }
    else if (page == 'lien_on_title')
    {
        window.location = 'https://secure.leads360.com/Import.aspx?Provider=TMXFinance&Client=TMXFinance&CampaignId=1034&Url=http://instaloan.glidewebdesign.com/index.php/thank-you2';
    }
    else if (page == 'no_title')
    {
        window.location = 'https://secure.leads360.com/Import.aspx?Provider=TMXFinance&Client=TMXFinance&CampaignId=1034&Url=http://instaloan.glidewebdesign.com/index.php/thank-you3';
    }
}


<form name="homeform" >

            <fieldset>
                            <input name="first" type="text" class="name" placeholder="&nbsp;First Name" maxlength="10" onkeyup="checkInput2(this)" required="required" />
                            <input name="last" type="text" class="name" placeholder="&nbsp;Last Name" maxlength="15" onkeyup="checkInput2(this)" required="required" /></br>
                            <input name="phone" type='tel'    pattern='^\(?([0-9]{3})\)?[-. ]?([0-9]{3})[-. ]?([0-9]{4})$' title='Phone Number (Format:  (999) 999-9999)' class="name" placeholder="&nbsp;Phone Number" maxlength="10"     onkeyup="checkInput(this)" required="required" />
                            <input name="zip" type="text"     name="zipCode" value=""
   pattern="[0-9]{5}([-][0-9]{4})?" placeholder="&nbsp;Zip Code" class="name"     maxlength="5" onkeyup="checkInput(this)" required="required"  /></br>
                            <select name="amount" class="dropdown" value="Amount Requested">
                                <option value="0">Amount</option>
                                <option value="$100-$499">$100 - $499</option>
                                <option value="$500-$999">$500 - $999</option>
                                <option value="$1000-$1999">$1,000 - $1,999</option>
                                <option value="$2000-$2999">$2,000 - $2,999</option>
                                <option value="$3000+">$3,000+</option>
                        </select>
                            </br>
                            <select name="status" class="dropdown" value="Car Title Status" >
                                <option value="smt">Car Title Status</option>
                                <option value="clear_title">I have a clear car title</option>
                                <option value="lien_on_title">There&#8242;s a lien against my car title</option>
                                <option value="no_title">I don&#8242;t have a car title</option>
                            </select>
                            </br>
                            <input name="submit" type="submit" class="submit" value="Find Out Now" />
                    </fieldset>

    </form>

1 个答案:

答案 0 :(得分:0)

好的......拔出我留下的小头发后,我弄明白了......我正在做的事情是完全错误的,因为无论如何我想要完成的事情。这是我最后的工作代码:

$("#homeform").submit(function(){
    if($("#status").val() == "clear_title"){
        $(this).attr("action","https://secure.leads360.com/Import.aspx?    Provider=TMXFinance&Client=TMXFinance&CampaignId=1034&Url=http://instaloan.glidewebdesign.co    m/index.php/thank-you");   
    }
   else if($("#status").val() == "lien_on_title"){
        $(this).attr("action","https://secure.leads360.com/Import.aspx?    Provider=TMXFinance&Client=TMXFinance&CampaignId=1034&Url=http://instaloan.glidewebdesign.co    m/index.php/thank-you2");   
    } 
    else if($("#status").val() == "no_title"){
        $(this).attr("action","https://secure.leads360.com/Import.aspx?    Provider=TMXFinance&Client=TMXFinance&CampaignId=1034&Url=http://instaloan.glidewebdesign.co    m/index.php/thank-you3");  
    }
}); 

HTML:

<form id="homeform" name="homeform" method="post" action="">

                <fieldset>
                            <input name="first" type="text" class="name" placeholder="&nbsp;First Name" maxlength="10" onkeyup="checkInput2(this)" required="required" />
                            <input name="last" type="text" class="name" placeholder="&nbsp;Last Name" maxlength="15" onkeyup="checkInput2(this)" required="required" /></br>
                            <input id="phone" name="phone" type='tel' pattern='^\(?([0-9]{3})\)?[-. ]?([0-9]{3})[-. ]?([0-9]{4})$' title='Phone Number (Format: (999) 999-9999)' class="name" placeholder="&nbsp;Phone Number" maxlength="10"  required="required" />
                            <input name="zip" type="text" name="zipCode" value=""
   pattern="[0-9]{5}([-][0-9]{4})?" placeholder="&nbsp;Zip Code" class="name"     maxlength="5" onkeyup="checkInput(this)" required="required"  /></br>
                        <select name="amount" class="dropdown" value="Amount Requested">
                            <option value="0">Amount</option>
                            <option value="$100-$499">$100 - $499</option>
                            <option value="$500-$999">$500 - $999</option>
                            <option value="$1000-$1999">$1,000 - $1,999</option>
                            <option value="$2000-$2999">$2,000 - $2,999</option>
                            <option value="$3000+">$3,000+</option>
                        </select>
                        </br>
                        <select id="status" name="status" class="dropdown" value="Car Title Status" >
                            <option value="smt">Car Title Status</option>
                            <option value="clear_title">I have a clear car title</option>
                            <option value="lien_on_title">There&#8242;s a lien against my car title</option>
                            <option value="no_title">I don&#8242;t have a car title</option>
                        </select>
                        </br>
                        <input name="submit" type="submit" class="submit" value="Find Out Now" />
                </fieldset>

</form>