how to remove validation message created by validator when reseting form in laravel octobercms - laravel

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.

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>

Selenium Webdriver: stale element reference

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

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.

Issue with form:select, all labels are selected

I am using spring 3 JSP tab lib to generate HTML. I have a select box with following code -
<form:select path="categoryList" multiple="false">
<form:option value="" label="--" selected="selected"/>
<form:options items="${categoryList}" itemValue="catId" itemLabel="catName"/>
</form:select>
HTML getting generated is -
<select id="categoryList" name="categoryList">
<option selected="selected" value="">--</option>
<option value="1" selected="selected">S</option>
<option value="2" selected="selected">Ster</option>
<option value="3" selected="selected">ice</option>
<option value="4" selected="selected">Cees</option>
</select>
Issue is all options getting generated has selected="selected" which makes "Cees" selected on page rather then "--". Can someone please let me know ohw to fix this?
complete page -
<form:form modelAttribute="productManagerVO" name="productManager" id="productManager">
<jsp:directive.include file="../common/header.jsp" />
<div class="MainDiv">
<div class="ManagerHeadline">Product Manager</div>
<table cellspacing="2px" cellpadding="0" width="100%">
<tr>
<td width="100%">
<fieldset>
<legend class="checkoutlegend">Category Information</legend>
<table align="left" id="addCategoryTable">
<tr><td><input type="button" id="addCat" value="Add New Category" /></td></tr>
</table>
<c:if test="${not empty productManagerVO.categoryList}">
<table cellspacing="2px" cellpadding="0" class="timeTable" id="categoryTable">
<th>Name</th>
<th>Order</th>
<th>Active</th>
<th> </th>
<c:forEach var="categoryListVO" items="${productManagerVO.categoryList}" varStatus="item">
<tr>
<td><c:out value="${categoryListVO.catName}" /></td>
<td><c:out value="${categoryListVO.catOrder}" /></td>
<td><c:if test="${categoryListVO.categoryActive}">Yes</c:if>
<c:if test="${!categoryListVO.categoryActive}">No</c:if>
</td>
<td>edit</td>
</tr>
</c:forEach>
</table>
</c:if>
</fieldset>
</td>
</tr>
<tr>
<td width="100%">
<fieldset>
<legend class="checkoutlegend">Product Information</legend>
<table align="left" id="addProductTable">
<tr>
<td><input type="button" id="addPro" value="Add New Product"/></td>
</tr>
</table>
<table cellspacing="2px" cellpadding="0" class="timeTable" id="productTable">
<col width="10%" />
<col width="7%" />
<col width="40%" />
<col width="10%" />
<col width="5%" />
<col width="6%" />
<col width="7%" />
<col width="10%" />
<col width="5%" />
<tr>
<th>Name</th>
<th>Subname</th>
<th>Description</th>
<th>Veg</th>
<th>Spicy</th>
<th>Is Active</th>
<th>Price</th>
<th>Category</th>
<th> </th>
</tr>
<c:if test="${not empty productManagerVO.productList}">
<c:forEach var="productListVO" items="${productManagerVO.productList}" varStatus="item">
<tr>
<td><c:out value="${productListVO.fName}" /></td>
<td><c:out value="${productListVO.fSubname}" /></td>
<td><c:out value="${productListVO.fDesc}" /></td>
<td><c:if test="${productListVO.fVeg}">Yes</c:if>
<c:if test="${!productListVO.fVeg}">No</c:if></td>
<td><c:if test="${productListVO.fSpicy}">Yes</c:if>
<c:if test="${!productListVO.fSpicy}">No</c:if></td>
<td><c:if test="${productListVO.fActive}">Yes</c:if>
<c:if test="${!productListVO.fActive}">No</c:if></td>
<td><c:out value="${productListVO.fPrice}" /></td>
<td><c:out value="${productListVO.categoryName}" /></td>
<td><a id="product" href="#editProduct" onclick="editProductData('${productListVO.fId}')">edit</a></td>
</tr>
</c:forEach>
</c:if>
</table>
</fieldset>
</td>
</tr>
</table>
</div>
<div style="display:none">
<div id="addCategory">
<table cellspacing="2px" cellpadding="0" class="adminTable" style="border:1px solid #dadada;">
<tr>
<td style="font-weight:bold;">Category Name</td>
<td><input type="text" id="caddName" /></td>
</tr>
<tr>
<td style="font-weight:bold;">Category Description</td>
<td><input type="text" id="caddDesc" /></td>
</tr>
<tr>
<td style="font-weight:bold;">Category Order</td>
<td><input type="text" id="caddOrder" /></td>
</tr>
<tr>
<td style="font-weight:bold;">Is Active</td>
<td>Yes <input type="radio" value="y" name="catActive"/> No <input type="radio" value="n" name="catActive"/></td>
</tr>
<tr>
<td colspan="2"><input type="button" id="cSave" name="catSave" value="Submit" onclick="addNewCategory();"/></td>
</tr>
</table>
</div>
<div id="editCategory">
<table cellspacing="2px" cellpadding="0" class="adminTable" style="border:1px solid #dadada;">
<tr>
<td style="font-weight:bold;">Category Name</td>
<td><input type="text" id="ceName" name="ceName"/></td>
</tr>
<tr>
<td style="font-weight:bold;">Category Description</td>
<td><input type="text" id="ceDesc" name="ceDesc"/></td>
</tr>
<tr>
<td style="font-weight:bold;">Category Order</td>
<td><input type="text" id="ceOrder" /></td>
</tr>
<tr>
<td style="font-weight:bold;">Is Active</td>
<td><input type="radio" id="ceActiveY" name="cateActive" value="y"/> Yes
<input type="radio" id="ceActiveN" name="cateActive" value="n"/> No</td>
</tr>
<tr><td colspan="2"><input type="button" id="cSave" name="catSave" value="Submit" onClick="editSaveCategory();"/></td>
<td><input type="hidden" id="ceId"/></td>
</tr>
</table>
</div>
<div id="addProduct">
<table cellspacing="2px" cellpadding="0" class="adminTable" style="border:1px solid #dadada;">
<tr>
<td style="font-weight:bold;">Product Name</td>
<td><input type="text" id="paName" /></td>
</tr>
<tr>
<td style="font-weight:bold;">Product SubName</td>
<td><input type="text" id="paSubName" /></td>
</tr>
<tr>
<td style="font-weight:bold;"> Product Description</td>
<td><input type="text" id="paDesc" /></td>
</tr>
<tr>
<td style="font-weight:bold;">Price</td>
<td><input type="text" id="paPrice" /></td>
</tr>
<tr>
<td style="font-weight:bold;">Is Vegetarian</td>
<td>Yes <input type="radio" id="paVeg" name="proVeg" value="y"/> No <input type="radio" id="paVeg" name="proVeg" value="n"/></td>
</tr>
<tr>
<td style="font-weight:bold;">Is Spicy</td>
<td>Yes <input type="radio" id="paSpicy" name="proSpicy" value="y"/> No <input type="radio" id="paSpicy" name="proCpicy" value="n"/></td>
</tr>
<tr>
<td style="font-weight:bold;">Is Active</td>
<td>Yes <input type="radio" id="paActive" name="proActive" value="y"/> No <input type="radio" id="paActive" name="proActive" value="n"/></td>
</tr>
<tr>
<td style="font-weight:bold;">Category</td>
<td>
<form:select path="categoryList" multiple="single">
<form:option value="" label="--"/>
<form:options items="${productManagerVO.categoryList}" itemValue="catId" itemLabel="catName"/>
</form:select>
</td>
</tr>
<tr>
<td colspan="2"><input type="button" id="caSave" name="cataSave" value="Submit"/></td>
</tr>
</table>
</div>
<div id="editProduct">
<table cellspacing="2px" cellpadding="0" class="adminTable" style="border:1px solid #dadada;">
<tr>
<td style="font-weight:bold;">Product Name</td>
<td><input type="text" id="peName" /></td>
</tr>
<tr>
<td style="font-weight:bold;">Product SubName</td>
<td><input type="text" id="peSubName" /></td>
</tr>
<tr>
<td style="font-weight:bold;"> Product Description</td>
<td><input type="text" id="peDesc" /></td>
</tr>
<tr>
<td style="font-weight:bold;">Price</td>
<td><input type="text" id="pePrice" /></td>
</tr>
<tr>
<td style="font-weight:bold;">Is Vegetarian</td>
<td>Yes <input type="radio" id="peVegY" name="proeVeg" value="y"/> No <input type="radio" id="peVegN" name="proeVeg" value="n"/></td>
</tr>
<tr>
<td style="font-weight:bold;">Is Spicy</td>
<td>Yes <input type="radio" id="peSpicyY" name="proeSpicy" value="y"/> No <input type="radio" id="peSpicyN" name="proeSpicy" value="n"/></td>
</tr>
<tr>
<td style="font-weight:bold;">Is Active</td>
<td>Yes <input type="radio" id="peActiveY" name="proeActive" value="y"/> No <input type="radio" id="peActiveN" name="proeActive" value="n"/></td>
</tr>
<tr>
<td style="font-weight:bold;">Category</td>
<td>
<form:select path="categoryList" multiple="single" id="peCat">
<form:option value="" label="--"/>
<form:options items="${productManagerVO.categoryList}" itemValue="catId" itemLabel="catName"/>
</form:select>
</td>
</tr>
<tr><td>
<td colspan="2"><input type="button" id="peSave" name="proeSave" value="Submit" onClick="editSaveProduct();"/></td>
<input type="text" id="peId"/></td>
</tr>
</table>
</div>
</div>
</form:form>
Try removing the selected=selected on your first item. I don't think its necessary as the list will display in the order you specified - unless you want -- to be the default selection if the form is submitted without this select being touched?
Try this:
<form:select path="categoryList" multiple="single">
<form:option value="" label="--"/>
<form:options items="${categoryList}" itemValue="catId" itemLabel="catName"/>
</form:select>
I've only changed the multiple attribute and removed the selected attribute from the option. This works for me...and i think, must also work for you.
edit:
It seems to be okay, only your last <tr> is wrong...you have two <td> in a row, without </td>
<tr>
<td>
<td colspan="2">
<input type="button" id="peSave" name="proeSave" value="Submit" onClick="editSaveProduct();"/>
</td>
<input type="text" id="peId"/>
</td>
</tr>
must be something like
<tr>
<td>
<input type="button" id="peSave" name="proeSave" value="Submit" onClick="editSaveProduct();"/>
</td>
<td colspan="2">
<input type="text" id="peId"/>
</td>
</tr>
Second, why are you using c:out? You can replace <td><c:out value="${categoryListVO.catName}" /></td> with <td>${categoryListVO.catName}</td>...
Third - this construction
<td><c:if test="${productListVO.fActive}">Yes</c:if>
<c:if test="${!productListVO.fActive}">No</c:if></td>
can you replace with
<c:choose>
<c:when test="${productListVO.fActive}">
Yes
</c:when>
<c:otherwise>
No
</c:otherwise>
</c:choose>
I find this way better...the rest seems to be okay, i can't find anything, what can cause the problem. Search for other not properly closed tags. Is there any warnings/messages from the jsp editor?
I had this problem, and after a lot of digging around in Spring I found what was causing it for me. It was something very specific in my case but there is a general point, which is this.
Spring goes to a great deal of trouble to try to work out what the selected option should be. I started digging around in the OptionWriter and then moved down into the SelectedValueComparator. This tries all manner of comparisons to work out if the current option value should be selected. In the end it falls back to the Propertyeditors and Converters (which is where my mistake was).
So I wonder if your CategoryList class had a badly implemented equals method or a converter that doesn't convert properly (mine always converted into the same object)?

reCAPTCHA keep saying incorrect-captcha-sol

I have this form
<form action="" method="post" enctype="multipart/form-data" name="form1" id="form1">
<tr>
<td width="32%" valign="top"> <strong class="main_title">Select Category: </strong></td>
<td width="68%" valign="top" class=""><? $qu="SELECT `id`,`name` FROM `linkvideos_category` WHERE `status` = '1'"; $rs=$Q($qu); ?>
<select name="category" class="blacktext" >
<option>Choose Category</option>
<? while($dis=$F($rs)) { ?>
<option value="<?=$dis['id']?>"> <?=$dis['name'];?></option>
<? } ?>
</select></td>
</tr>
<tr>
<td colspan="2" valign="top" class=""> </td>
</tr>
<tr>
<td valign="top"> <strong class="main_title">Upload Image: </strong></td>
<td valign="top" class=""><input type="file" name="imagefile" /> </td>
</tr>
<tr>
<td colspan="2" valign="top" class=""> </td>
</tr>
<tr>
<td valign="top"> <strong class="main_title"> Your Link : </strong></td>
<td valign="top" class=""><input name="link" type="text" size="50" /></td>
</tr>
<tr>
<td colspan="2" valign="top" class=""> </td>
</tr>
<tr>
<td valign="top"> <strong class="main_title"> Link Title : </strong></td>
<td valign="top" class=""><input name="linkname" type="text" size="50" /></td>
</tr>
<tr>
<td colspan="2" valign="top" class=""> </td>
</tr>
<tr>
<td valign="top"> <strong class="main_title">Description:</strong></td>
<td valign="top"><label>
<textarea name="desc" cols="40" rows="10"></textarea>
</label></td>
</tr>
<tr>
<td valign="top"> <strong class="main_title">Security Code:</strong></td>
<td valign="top">
<? if ($error==3) { ?>
<font color="red">Invalid Code Entered</font>
<?}?>
<?php
require_once('captcha/recaptchalib.php');
echo recaptcha_get_html($public_key);
?></td>
</tr>
<tr>
<td colspan="2" valign="top" class=""> </td>
</tr>
<tr>
<td colspan="2" valign="top" class=""> </td>
</tr>
<tr>
<td colspan="2" align="center" valign="top" class=""><input type="submit" name="Submit" value="Submit" class="btns" onclick="javascript:return check();" /></td>
</tr>
</form>
and i'm verifying the captcha with this
$resp = recaptcha_check_answer ($private_key,
$_SERVER["REMOTE_ADDR"],
$_POST["recaptcha_challenge_field"],
$_POST["recaptcha_response_field"]);
if (!$resp->is_valid) {
$error = 3;
echo"<script>window.location='submit_linkvideo.php?error=3';</script>";
}
and every time it's telling me the captchas invalid and saying incorrect-captcha-sol, am I missing something? I've tested it and the recaptcha values arn't being submitted.
Fixed it by ending a table before the form then starting the table again once inside the form.

Resources