Selenium Webdriver: stale element reference - xpath
Am getting the below error:
stale element reference: element is not attached to the page document.
When I select a country from the country dropdown the page gets refreshed since we have used 'onchange' attribute, so when i try to locate rest of the fields in the form its throwing me the stated exception.
Note: I have cross verified the locators before and after the page gets loaded,
there is no change in it as most of the locators used are id's.
Here is my HTML,
<form method="post" action="/eClaims/app" name="mainForm" id="mainForm"
accept-charset="utf-8">
<div style="display: none;">
<input type="hidden" name="formids"
value="ifErrors,hasErrors,If,If_0,statusDate1,If_1,If_3,If_5,If_7,If_2,callDate,If_8,If_4,countryList,If_9,If_6,languageList,If_10,If_11,If_12,customerEmail,If_13,If_14,customerTitle,If_15,customerFirstName,If_16,If_17,customerLastName,If_18,customerCompany,If_19,If_20,If_21,customerFaxPhoneCode,customerFaxNumber,If_22,If_23,customerPhoneCode,customerPhoneNumber,If_24,If_25,qualificationSystem,If_26,If_27,caseId,If_28,If_29,productNumber,If_30,If_31,serialNumber,If_32,If_33,If_34,purchaseDate,If_35,If_36,problemDescription,If_37,qualificationAgent,If_38,If_39,If_40,cancelDoaAuth,If_41,Submit_0,If_42,Submit_1,If_43,Submit_2,If_44,If_45,If_46,If_47,Submit_6,Submit_7,Submit_8">
<input type="hidden" name="component" value="mainForm"> <input
type="hidden" name="page" value="DoaAuthorisationForm">
</div>
<table width="100%">
<tbody>
<tr>
<td colspan="3"></td>
</tr>
<tr class="theme">
<th width="100%" colspan="3">
<h2 class="themeheader">Authorisation to return DOA product</h2>
</th>
</tr>
<tr>
</tr>
<tr>
<td colspan="10"><font color="red">please obtain a valid
proof of purchase from the customer before proceeding with this
form. </font></td>
</tr>
<tr>
<td colspan="3"><hr width="100%"></td>
</tr>
<!-- <tr style="visibility: hidden;">
<td>
<span key="label.status" ></span>
</td>
<td class="inputFormCell">
<span jwcid="statusList" ></span>
</td>
</tr> -->
<tr style="visibility: hidden;">
<td>Status Date</td>
<td class="inputFormCell"><input type="text" name="statusDate1"
value="" title="dd MMM yyyy" id="statusDate1"> <a
href="javascript:calendar_statusDate1.toggle(document.mainForm.statusDate1);"><img
src="/eClaims/app?digest=d1154f8b7bf653ba6128f8cb1f5c8e95&path=%2Forg%2Fapache%2Ftapestry%2Fform%2FDatePickerIcon.png&service=asset"
border="0"></a></td>
</tr>
<tr>
<td>Call Date<font color="red"> *</font>
</td>
<td class="inputFormCell"><input type="text" name="callDate"
value="" title="dd MMM yyyy" id="callDate"> <a
href="javascript:calendar_callDate.toggle(document.mainForm.callDate);"><img
src="/eClaims/app?digest=d1154f8b7bf653ba6128f8cb1f5c8e95&path=%2Forg%2Fapache%2Ftapestry%2Fform%2FDatePickerIcon.png&service=asset"
border="0"></a></td>
</tr>
<tr>
<td>Country<font color="red"> *</font>
</td>
<td class="inputFormCell"><select name="countryList"
id="countryList" style="width: 180px;"
onchange="javascript:onChangeCountry(this);">
<option value="">--please select--</option>
<option value="AF">Afghanistan</option>
<option value="AS">American Samoa</option>
<option value="AU" selected="selected">Australia</option>
<option value="BD">Bangladesh</option>
<option value="WF">Wallis And Futuna</option>
<option value="WS">Samoa</option>
</select></td>
</tr>
<tr>
<td>Language<font color="red"> *</font>
</td>
<td class="inputFormCell"><select name="languageList"
id="languageList" style="width: 180px;">
<option value="" selected="selected">--please select--</option>
<option value="EN">English</option>
</select></td>
</tr>
<tr>
<td>Customer Email<font color="red"> *</font><font color="red">
*</font>
</td>
<td class="inputFormCell"><input type="text"
name="customerEmail" value="" id="customerEmail"></td>
</tr>
<tr>
<td colspan="3">**Fax Number mandatory for 'Save & Fax',
e-Mail mandatory for 'Save & Mail'</td>
</tr>
<tr>
<td class="section_content"><input type="submit"
name="Submit_6" value="[BUTTON.SUBMIT1]" id="submitDummy"
class="primButton" style="visibility: hidden;"></td>
<td class="section_content"><input type="submit"
name="Submit_7" value="[BUTTON.SUBMIT2]" id="submitAuth"
class="primButton" style="visibility: hidden;"></td>
</tr>
<tr>
<td class="section_content"><input type="submit"
name="Submit_8" value="[BUTTON.SUBMIT2]" id="submitMailAuth"
class="primButton" style="visibility: hidden;"></td>
</tr>
</tbody>
</table>
</form>
I have tried the following solutions,
new WebDriverWait(driver, 500)
.ignoring(StaleElementReferenceException.class)
.until(new Predicate<WebDriver>() {
public boolean apply(#Nullable WebDriver driver) {
Select selectLanguage;
try {
selectLanguage = new Select(getWebElement("apj.newdoa.language"));
selectLanguage.selectByValue("EN");
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return true;
}
});
2nd Solution,
Wait<WebDriver> wait = new FluentWait<WebDriver>(driver)
.withTimeout( 120, TimeUnit.SECONDS )
.pollingEvery( 20, TimeUnit.SECONDS )
.ignoring( NoSuchElementException.class, StaleElementReferenceException.class );
// using a customized expected condition
Select foo1 = wait.until(new Function<WebDriver, Select>() {
Select selectLanguage;
public Select apply(WebDriver driver) {
try {
selectLanguage = new Select(getWebElement("apj.newdoa.language"));
logger.info("Value of Option:\t" +selectLanguage.toString());
return selectLanguage = new Select(getWebElement("apj.newdoa.language"));
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return selectLanguage;
}
});
foo1.selectByValue("EN");
Thanks in advance
Related
How to set table cells values independently with using x-for alpine.js?
I am trying to make a table includes table in every row, and nested x-for is used with alpine.js.With clicking the button located in the lower right corner of the table, new row is added and all cells in the rows have the same value. I couldn't set the rows' values independently. Could you please help? Thanks in advance for your help, Cem function handler() { return { fields1: [], fields: [], rows: [], addRate() { this.fields1.push({ value1: '', value2: '', value3: '', rType: '', typeA: '', value4: '', typeBDateFrom: '', typeBDateTo: '' }); }, listField() { this.fields.splice(0); this.fields1.splice(0); this.rows.push({ id: this.id++ }); this.fields1.push({ value1: '', value2: '', value3: '', rType: '', typeA: '', value4: '', typeBDateFrom: '', typeBDateTo: '' }); this.fields.push({ value5: '3', value6: '20', value7: 'DC', value8: '40', value9: '523', value10: '654', value11: 'TEST', value12: 'true', value13: 'Class1', value14: '5656', value15: 'TRM78799', id:'1' }); }, } }; function setDecimal(event) { this.value = parseFloat(this.value).toFixed(3); }; <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css"> <div class="container col-md-10 offset-md-1"> <div class="row" x-data="handler()" x-init="listField()"> <div class="col"> <table class="table align-items-center table-sm" style="text-align: center;"> <tr> <template x-for="(row, index) in rows" :key="index"> <p> <table class="table align-items-center table-sm table-bordered" style="text-align: center;"> <tbody> <template x-for="(field1, index) in fields1" :key="index"> <tr class="table-success"> <td style="width:100px;"><b>Type</b></td> <td style="width:100px;"> <select x-model="field1.rType" class="custom-select" name="rType" id="rType" required> <option selected>---</option> <option value="Type A">Type A</option> <option value="Type B">Type B</option> </select> </td> <td x-show="field1.rType==='Type A'" style="width:120px;"> <b>Type A Name</b> </td> <td x-show="field1.rType==='Type A'"> <input x-model="field1.typeA" type="text" class="form-control" name="typeA" id="typeA"> </td> <td x-show="field1.rType==='Type A'" style="width:150px;"> <b>Value4</b> </td> <td x-show="field1.rType==='Type A'"> <input x-model="field1.value4" type="text" class="form-control" name="value4" id="value4"> </td> <td x-show="field1.rType==='Type B'" style="width:120px;"> <b>From</b> </td> <td x-show="field1.rType==='Type B'"> <input x-model="field1.typeBDateFrom" type="Type B" class="form-control" name="typeBDateFrom" id="typeBDateFrom"> </td> <td x-show="field1.rType==='Type B'" style="width:150px;"> <b>To</b> </td> <td x-show="field1.rType==='Type B'"> <input x-model="field1.typeBDateTo" type="Type B" class="form-control" name="typeBDateTo" id="typeBDateTo"> </td> </tr> </template> </tbody> </table> </p> <p> <table class="table align-items-center table-sm table-bordered" style="text-align: center;"> <thead class="thead-dark"> <tr> <th>No</th> <th style="width:20px;">Value5</th> <th style="width:80px;">Value6</th> <th style="width:150px;">Value7</th> <th style="width:120px;">Value8</th> <th style="width:120px;">Value9</th> <th style="width:130px;">Value11</th> <th style="width:180px;">Value12</th> <th style="width:180px;">Value1</th> <th style="width:180px;">Value2</th> <th style="width:180px;">Value3</th> </tr> </thead> <tbody> <template x-for="(field, index) in fields" :key="index"> <tr> <td x-text="index + 1"></td> <td x-text="field.value5"></td> <td x-text="field.value6"></td> <td> <p x-text="field.value7"></p> <p x-show="field.value7==='RFR' | field.value7==='RFRHC'"> <span x-text="field.value8"></span><span> ℃</span> </p> </td> <td x-text="field.value9"></td> <td x-text="field.value10"></td> <td x-text="field.value11"></td> <td x-show="field.value12"> <p> <label><b>Value13 </b><span x-text="field.value13"></span></label> </p> <p> <label><b>Value14 </b><span x-text="field.value14"></span></label> </p> </td> <td x-show="!field.value12"> <p> </p> </td> <td class="table-success"> <input x-model="field.value1" type="number" class="form-control" onchange="setDecimal" min="0" max="10000000" name="value1" id="value1" step="0.001" value="0.000" required> </td> <td class="table-success"> <select x-model="field.value2" class="custom-select" name="value2" id="value2" required> <option selected>---</option> <option value="USD">USD</option> <option value="EUR">EUR</option> </select> </td> <td class="table-success"> <input x-model="field.value3" type="text" class="form-control" name="value3" id="value3"> </td> </tr> </template> </tbody> </table> </p> </template> </tr> <tr> <td colspan="12" class="text-right"><button type="button" class="btn btn-info" #click="listField()">+ Add Row</button></td> </tr> </table> </div> </div> </div> <script src="https://code.jquery.com/jquery-1.12.4.js"></script> <script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script> <script src="https://cdn.jsdelivr.net/gh/alpinejs/alpine#v2.8.2/dist/alpine.min.js" defer></script>
how to remove validation message created by validator when reseting form in laravel octobercms
form validation: Component public function onContact() { $input = post(); //$contact = Contact::create($input); $rules = [ 'name' => 'required|alpha', 'designation' => 'required', 'note' => 'required', 'contactNo' => 'required|numeric|max:10', 'emailIdText' => 'required|email', 'companyName' => 'required' ]; $validator = Validator::make($input, $rules); if ($validator->fails()) { throw new ValidationException($validator); } else { $contact = new Contact; $contact->name = $input['name']; $contact->designation = $input['designation']; $contact->note = $input['note']; $contact->inquiry_about = $input['option']; $contact->email_id = $input['emailIdText']; $contact->contact_no = $input['contactNo']; $contact->company_name = $input['companyName']; $contact->save(); } } default.htm <form id="myform" autocomplete="off" action="{{ 'contactUs'|page }} " data-request="{{ __SELF__ }}::onContact" data-request-validate data-request-flash method="post" name="myform" class="contact-form"> <table height="" cellpadding="0" cellspacing="15" class="contactUs"> <tbody> <tr > <td class="Fieldname" >Inquiry About : </td> <td valign="top" > <select class="comboFieldontact" name="option" id="option" > <option value="Existing Client" selected>Existing Client</option> <option value="Prospect">Prospect</option> <option value="Media">Media</option> <option value="Investor">Investor</option> <option value="Association">Association</option> <option value="Career">Career</option> </select> <span class="Error" data-validate-for="inquiry_about" id="optionTextError" ></span> </td> </tr> <tr> <td valign="top" class="Fieldname">Name :</td> <td valign="top"> <input type="text" id="name" name="name" class="textFieldContact"> <span class="Error" data-validate-for="name" id="nameTextError" ></span></td> </tr> <tr> <td valign="top" class="Fieldname">Email : </td> <td valign="top"> <input type="text" id="contactemailIdText" name="emailIdText" class="textFieldContact" > <span class="Error" data-validate-for="emailIdText" id="contactemailIdTextError" ></span></td> </tr> <tr> <td valign="top" class="Fieldname">Contact No : </td> <td valign="top"> <input type="text" maxlength="15" id="contactNo" name="contactNo" class="textFieldContact" > <span class="Error" data-validate-for="contactNo" id="contactNoTextError" ></span></td> </tr> <tr> <td valign="top" class="Fieldname">Company Name :</td> <td valign="top"> <input type="text" id="companyName" name="companyName" class="textFieldContact" > <span class="Error" data-validate-for="companyName" id="companyNameTextError" ></span></td> </tr> <tr> <td valign="top" class="Fieldname">Designation :</td> <td valign="top"> <input type="text" id="designation" name="designation" class="textFieldContact" > <span class="Error" data-validate-for="designation" id="designationTextError" ></span></td> </tr> <tr> <td class="Fieldname"> Note :</td> <td valign="top"> <textarea class="textarea" name="note" id="note" style="color: #000;" ></textarea> <span class="Error" data-validate-for="note" id="fromTextError" ></span></td> </tr> <tr> <td class="Fieldname"></td> <td valign="top"> <input type="submit" class="contactBtn" value="Submit" > <input type="reset" id="resetbtn" class="contactBtn" value="Reset"> </td> </tr> </tbody> </table> </form> form validation is perfectly fine but i want to reset form along with validation error message how can i do this? when clicking to reset button input in input fields resets but error msgs are still shown...................................................... what should i do
Here, use this JavaScript code to clear out all of your tags that have an error class. <script> function clearErrors() { var form = document.getElementById('myform').querySelectorAll('span.Error'); for (i=0; i<=form.length; i++) { form[i].innerText = ''; } } </script> <form id="myform" autocomplete="off" action="{{ 'contactUs'|page }} " data-request="{{ __SELF__ }}::onContact" data-request-validate data-request-flash method="post" name="myform" class="contact-form"> <table height="" cellpadding="0" cellspacing="15" class="contactUs"> <tbody> <tr > <td class="Fieldname" >Inquiry About : </td> <td valign="top" > <select class="comboFieldontact" name="option" id="option" > <option value="Existing Client" selected>Existing Client</option> <option value="Prospect">Prospect</option> <option value="Media">Media</option> <option value="Investor">Investor</option> <option value="Association">Association</option> <option value="Career">Career</option> </select> <span class="Error" data-validate-for="inquiry_about" id="optionTextError" ></span> </td> </tr> <tr> <td valign="top" class="Fieldname">Name :</td> <td valign="top"> <input type="text" id="name" name="name" class="textFieldContact"> <span class="Error" data-validate-for="name" id="nameTextError" ></span></td> </tr> <tr> <td valign="top" class="Fieldname">Email : </td> <td valign="top"> <input type="text" id="contactemailIdText" name="emailIdText" class="textFieldContact" > <span class="Error" data-validate-for="emailIdText" id="contactemailIdTextError" ></span></td> </tr> <tr> <td valign="top" class="Fieldname">Contact No : </td> <td valign="top"> <input type="text" maxlength="15" id="contactNo" name="contactNo" class="textFieldContact" > <span class="Error" data-validate-for="contactNo" id="contactNoTextError" ></span></td> </tr> <tr> <td valign="top" class="Fieldname">Company Name :</td> <td valign="top"> <input type="text" id="companyName" name="companyName" class="textFieldContact" > <span class="Error" data-validate-for="companyName" id="companyNameTextError" ></span></td> </tr> <tr> <td valign="top" class="Fieldname">Designation :</td> <td valign="top"> <input type="text" id="designation" name="designation" class="textFieldContact" > <span class="Error" data-validate-for="designation" id="designationTextError" ></span></td> </tr> <tr> <td class="Fieldname"> Note :</td> <td valign="top"> <textarea class="textarea" name="note" id="note" style="color: #000;" ></textarea> <span class="Error" data-validate-for="note" id="fromTextError" ></span></td> </tr> <tr> <td class="Fieldname"></td> <td valign="top"> <input type="submit" class="contactBtn" value="Submit" > <button type="reset" onclick="clearErrors()">Reset</button> </td> </tr> </tbody> </table> </form>
Did you try to hide the elements with the class 'error' with jQuery by clicking on the reset button ? Another method is to change the reset button with an empty href. By clicking on the button it will refresh the page and the form I guess.
Extracting and restricting time from the date object in a textbox
I have searched everywhere but cannot find an answer for this particular question that I have. I'm making a pizza ordering website and instead of having a simple drop-down option for the time of pick-up or delivery field, we are required to have a text field so that the customer can manually enter the time themselves. I then need to validate the value of time by using DATE object to make sure it is between 6am and 11pm. Time must include am or pm. Here is what I have so far: <html> <head> <title> Pizza Form </title> </head> <body> <script> //Creating the function to extract the time function getTime() { var d = new Date(); d.setHours(); document.getElementById("pickTime").innerHTML = d; } } </script> <h1>Pizza Order Form</h1> <form> <fieldset><Legend>Is this for delivery or carryout?</legend> <table > <tr> <td><input type="radio" name="DoC" id="forDelivery">Delivery <font color="red" size="1.px">extra 30% of total</font></input></td> <td><input type="radio"name="DoC" id="forCarry">Carryout</td> </tr> <tr> <td>Delivery/Pickup Time</td> <td><input type="text" id="pickTime" value= "" onkeypress="return getTime()"> <font color="red" size="1.px" >Time should be between 6am and 11pm</font></td> </tr> </table> </fieldset> <fieldset><legend>Customer Info</legend> <table > <tr> <td>First and Last Name</td> <td><input type="text" id="flname"></td> </tr> <tr> <td align="left">Address<br/ ><font color="red" size="1.px" id="address">Not required if takeout</font></td> <td><textarea rows="4" cols="50" id="address"></textarea></td> </tr> <tr> <td>Phone Number</td> <td><input type="text" id="phonenumber"></td> </tr> <tr> <td>Email Address</td> <td><input type="text" id="email"></td> </tr> </table> </fieldset> <fieldset><legend>Choose Size and Crust</legend> <table style="width:100%" > <tr> <th align="left">Hand Tossed</th> <th align="left">Handmade Pan</th> <th align="left">Crunchy Thin crust</th> <th align="left">Brooklyn Style</th> </tr> <tr> <td><input type="radio"name="type" id="SHT" value="8">Small (10"-$8)</td> <td><input type="radio"name="type" id="MHP" value"10">Medium (12"-$10)</td> <td><input type="radio"name="type" id="MCTC" value="10">Medium (12"-$10)</td> <td><input type="radio"name="type" id="LBS" value="13">Large (14"-13$)</td> </tr> <tr> <td><input type="radio"name="type" id="MHT" value="9">Medium (12"-$9)</td> <td></td> <td><input type="radio"name="type" id="LCTC" value="12">Large (14"-$12)</td> <td><input type="radio"name="type" id="XLBS" value="15">X-Large (16"-$15)</td> </tr> <tr> <td><input type="radio"name="type" id="LHT" value="10">Large (14"-$10)</td> <td></td> <td></td> <td></td> </tr> <tr> <td><input type="radio"name="type" id="XLHT" value="11">X-Large (16"-$11)</td> <td></td> <td></td> <td></td> </tr> </table> </fieldset> <fieldset><legend> Choose Cheese & Sauce</legend> <table > <tr> <td width="58%">Cheese?</td> <td>Sauce?</td> </tr> <tr> <td> <select size="6"> <option id="nocheese" value="0">No Cheese</option> <option id="lightcheese" value="1">Light - $1.00</option> <option id="normalcheese" value="1.25">Normal - $1.25</option> <option id="extracheese" value="1.5">Extra - $1.50</option> <option id="dblcheese" value="1.75">Double - $1.75</option> <option id="tplcheese" value="2">Triple - $2.00</option> </select> </td> <td valign="top"> <select size="4"> <option id="nosauce" value="0">No Sauce</option> <option id="lightsauce" value="0.5">Light - $0.50</option> <option id="normalsauce" value="1">Normal - $1.00</option> <option id="extrasauce" value="1.5">Extra - $1.50</option> </select> </td> </tr> </table> </fieldset> <fieldset><legend> Toppings (You can choose more than one - $2 each)</legend> <table > <tr> <td width="50%" ><input type="checkbox" id="pepporoni" value="2">Pepporoni</td> <td><input type="checkbox" id="blackolive" value="2">Black Olives</td> </tr> <tr> <td><input type="checkbox" id="mushroom" value="2">Mushrooms</td> <td><input type="checkbox" id="greenpepper" value="2">Green Peppers</td> </tr> <tr> <td><input type="checkbox" id="onions" value="2">Onions</td> <td><input type="checkbox">Pineapple</td> </tr> <tr> <td><input type="checkbox" id="sausage" value="2">Sausage</td> <td><input type="checkbox" id="spinach" value="2">Spinach</td> </tr> <tr> <td><input type="checkbox" id="bacon" value="2">Bacon</td> </table> </fieldset> <button type="submit" value="Submit">Submit</button> <button type="reset" value="Reset">Reset</button> </form> </body> </html> Here's what the website looks like so far
If you are using HTML5 you can use a time input, like this: <INPUT id="MyId" name="MyName" type="time"> More information on HTML5 input types. If you are not using HTML5, you'll have to write a bit of script, or use one of many jquery time picker plugins available freely.
HTML TR and TD alignment
This is what I've done, but I failed to make the alignment same as next picture. Hope someone can help. <tr> <td > </td> <td ><b>Type Description</b></td> <td align="Center"><b>:</b></td> <td colspan="3"><input name="txtCAEMGE" value="<%=server.HTMLEncode(StrCAEMDE)%>" type="text" class="NormalInputTextField" size="30" > <input name="chkHR" type="checkbox"> Tick for disable update from HR system </td> </tr> <tr> <td > </td> <td > </td> <td colspan="3"> <input name="chkHR2" type="checkbox"> Tick for disable update from HR system </td> </tr>
I would experiment with putting both checkboxes inside a single container (e.g. a DIV). If you want to position them as a single entity then it will be easier if they are organised in the DOM this way. e.g. <body> <table> <tr> <td><b>Type Description</b></td> <td align="Center"><b>:</b></td> <td> <input type="text" value="test value" size="30" > <div style="display: inline-block;"> <div style="display: block;"><input name="chkHR" type="checkbox"> Tick for disable update from HR system</div> <div style="display: block;"><input name="chkHR2" type="checkbox"> Tick for disable update from HR system</div> </div> </td> </tr> </table> </body>
Ajax form redirect to another url
i want to redirect to another url when the form is submitted how can i do it i am new to ajax so please tell where to add the code which can do it here is my code <script type="text/javascript"> function submitForm() { if ($("#fields_fname").val() == "") { $("#fields_fname").focus(); alert("The First Name field is required."); return false; } if ($("#fields_lname").val() == "") { $("#fields_lname").focus(); alert("The Last Name field is required."); return false; } if ($("#fields_email").val() == "") { $("#fields_email").focus(); alert("The Email field is required."); return false; } if ($("#fields_phone").val() == "") { $("#fields_phone").focus(); alert("The Phone field is required."); return false; } if ($("#fields_zip").val() == "") { $("#fields_zip").focus(); alert("The Postal Code field is required."); return false; } if ($("#fields_suffix").val() == "") { $("#fields_suffix").focus(); alert("The 'I'm Interested In' field is required."); return false; } $.ajax({ url: 'zohoprocess.php', type:'POST', data:$('#ContactForm').serialize(), success: function(){ $(".form_result").html('Form 1 submitted successfully'); $.ajax({ url: 'https://app.icontact.com/icp/signup.php', type:'POST', data:$('#ContactForm').serialize(), success: function(){ $(".form_result").html('Form 2 submitted successfully'); }, error:function(){ alert("success"); $(".form_result").html(''); return false; } }); }, error:function(){ alert("failure"); $(".form_result").html(''); return false; } }); return false; } </script> <form id="ContactForm"> <input type="hidden" name="redirect" value="http://tennispronow.com/thanks.html"> <input type="hidden" name="errorredirect" value="http://www.icontact.com/www/signup/error.html"> <div id="SignUp"> <table width="260" class="signupframe" border="0" cellspacing="0" cellpadding="5"> <tr> <td valign="top" align="right"> <span class="required">*</span>Email </td> <td align="left"> <input type="text" name="fields_email" id="fields_email"> </td> </tr> <tr> <td valign="top" align="right"> <span class="required">*</span>First Name </td> <td align="left"> <input type="text" name="fields_fname" id="fields_fname"> </td> </tr> <tr> <td valign="top" align="right"> <span class="required">*</span>Last Name </td> <td align="left"> <input type="text" name="fields_lname" id="fields_lname"> </td> </tr> <tr> <td valign="top" align="right"> <span class="required">*</span>What Level Player are you? </td> <td align="left"> <select name="fields_prefix" id="fields_prefix"> <option></option> <option value="Beginner">Beginner</option> <option value="Upper Beginner">Upper Beginner</option> <option value="Intermediate">Intermediate</option> <option value="Advanced">Advanced</option> </select> </td> </tr> <tr> <td valign="top" align="right"> <span class="required">*</span>I am Interested in: </td> <td align="left"> <select name="fields_suffix" id="fields_suffix"> <option></option> <option value="Private Lessons">Private Lessons</option> <option value="Lessons & Equipment">Lessons & Equipment</option> <option value="Classes">Classes</option> <option value="Equipment">Equipment</option> </select> </td> </tr> <tr> <td valign="top" align="right"> <span class="required">*</span>Other Info: </td> <td align="left"> <input type="text" name="fields_fax" id="fields_fax"> </td> </tr> <tr> <td valign="top" align="right"> <span class="required">*</span>Phone </td> <td align="left"> <input type="text" name="fields_phone" id="fields_phone"> </td> </tr> <tr> <td valign="top" align="right"> <span class="required">*</span>Postal Code </td> <td align="left"> <input type="text" name="fields_zip" id="fields_zip"> </td> </tr> <input type="hidden" name="listid" value="42670"> <input type="hidden" name="specialid:42670" value="D1CQ"> <input type="hidden" name="clientid" value="860526"> <input type="hidden" name="formid" value="4668"> <input type="hidden" name="reallistid" value="1"> <input type="hidden" name="doubleopt" value="0"> <tr> <td></td> <td><span class="required">*</span> = Required Field</td> </tr> <tr> <td></td> <td><input type="submit" name="Submit" value="Submit" onClick="return submitForm()"> </td> </tr> </table> <div class="form_result"> </div> </div> </form> please check it dont know what to write more
Just add action attribute to the form tag.