which method disable or read only is not processed in post method?
At first i have created 10 text boxes and set required is true in zend framework. Body onload it's disabling all text boxes.
i have drop down box showing 0 to 10 numbers, when i selecting a number it's creating selected number of text boxes, if i select 8 it's creating 8 text boxes.(using javascript disable true)
after that if i select 5 from drop down it's creating only 5 text boxes . now if i enter values in all text boxes. Data it's not submitting into database . what's the problem ?
At first if i don't change the drop down 2 times data is submitting. If i change drop down 2 times data is not submitting.
php code for this
<?php
class Application_Form_Astroappointment extends Zend_Form {
public function init() {
/* Form Elements & Other Definitions Here ... */
$this->setName('form_fixappointment');
$this->setAction("");
$this->setAttrib('enctype', 'multipart/form-data');
$this->setAttrib('onsubmit', "javascript:hide(document.getElementById(\'no_of_item\').value)");
$firstname = $this->createElement('text', 'first_name');
$firstname->setLabel('First Name:')
->setRequired(true);
$lastname = $this->createElement('text', 'last_name');
$lastname->setLabel('Last Name:')
->setRequired(true);
$email = $this->createElement('text', 'email');
$email->setLabel('Email:')
->setRequired(true)
->addValidator('EmailAddress', true);
$countries = new Application_Model_DbTable_Countries;
$countriesList = $countries->getCountriesList();
$country = new Zend_Form_Element_Select('country_id');
$country->setLabel('Countries:')
->addMultiOptions($countriesList);
$states = $this->createElement('text', 'state');
$states->setLabel('States:')
->setRequired(true);
$cities = $this->createElement('text', 'city');
$cities->setLabel('Cities:')
->setRequired(true);
$cor_address = $this->createElement('textarea', 'cor_address');
$cor_address->setAttrib('rows', '6');
$cor_address->setAttrib('cols', '20');
$cor_address->setLabel('Corresponding Address:')
->setRequired(true);
$per_address = $this->createElement('textarea', 'per_address');
$per_address->setAttrib('rows', '6');
$per_address->setAttrib('cols', '20');
$per_address->setLabel('Permanent Address:');
$landline = $this->createElement('text', 'landline');
$landline->setLabel('Landline:');
$mobile_no = $this->createElement('text', 'mobile_no');
$mobile_no->setLabel('Mobile No:')
->setRequired(true);
$fax_no = $this->createElement('text', 'fax_no');
$fax_no->setLabel('Fax No:');
$dob = $this->createElement('text', 'dob');
$dob->setLabel('Date Of birth:')
->setRequired(true);
$tob = $this->createElement('text', 'tob');
$tob->setLabel('Time Of birth:')
->setRequired(true);
$birth_place = $this->createElement('text', 'birth_place');
$birth_place->setLabel('Birth Place:')
->setRequired(true);
$marriage_date = $this->createElement('text', 'marriage_date');
$marriage_date->setLabel('Marriage date:')
->setRequired(false);
$religion = $this->createElement('text', 'religion');
$religion->setLabel('Religion:')
->setRequired(false);
$deity = $this->createElement('text', 'deity');
$deity->setLabel('Deity (isth dev):')
->setRequired(false);
$occupation = $this->createElement('text', 'occupation');
$occupation->setLabel('Occupation:')
->setRequired(true);
$commu_mode = $this->createElement('radio', 'commu_mode');
$commu_mode->setLabel('Communication Mode:')
->addMultiOptions(array(
'Courier' => 'Courier',
'Mail' => 'Mail',
'Phone' => 'Phone',
'Handdelivery' => 'Hand Delivery',
))
->setSeparator('')
->setValue("Courier");
$appo_date = $this->createElement('text','appo_date');
$appo_date->setLabel('Appointment Date:')
->setRequired(true);
$comm_time_from = $this->createElement('text','commu_time_from');
$comm_time_from->setLabel('Communication time: From:')
->setRequired(true);
$comm_time_to = $this->createElement('text','commu_time_to');
$comm_time_to->setLabel('Communication time: To:')
->setRequired(true);
$kundli = new Zend_Form_Element_File('kundli');
$kundli->setLabel('Upload Kundli:')
->setRequired(false);
$kundli->addValidator('Extension', false, 'jpg,jpeg,png,gif,doc,pdf,docx,txt,rtf')
->addValidator('Size', false, array('min' => 20, 'max' => 409600));
$gen_query = $this->createElement('textarea', 'gen_query');
$gen_query->setAttrib('rows', '6');
$gen_query->setAttrib('cols', '20');
$gen_query->setLabel('General Query:');
$item_array = Array();
for ($i = 0; $i <= 10; $i++) {
$item_array[$i] = $i;
}
$items = new Zend_Form_Element_Select('no_of_item');
$items->setLabel('No of spiritual items you wore:')
->addMultiOptions($item_array)
->setAttrib('onchange', "javascript:show(this.options[this.selectedIndex].value)");
$item1 = $this->createElement('text','item1')
->setLabel('Enter Item 1:')
->setRequired(false)
->addDecorator('Label',array('tag' => 'dt','class'=>'required'));
$item2 = $this->createElement('text','item2')
->setLabel('Enter Item 2:')
->setRequired(true)
->addDecorator('Label',array('tag' => 'dt','class'=>'required'));
$item3 = $this->createElement('text','item3')
->setLabel('Enter Item 3:')
->setRequired(true)
->addDecorator('Label',array('tag' => 'dt','class'=>'required'));
$item4 = $this->createElement('text','item4')
->setLabel('Enter Item 4:')
->setRequired(true)
->addDecorator('Label',array('tag' => 'dt','class'=>'required'));
$item5 = $this->createElement('text','item5')
->setLabel('Enter Item 5:')
->setRequired(true)
->addDecorator('Label',array('tag' => 'dt','class'=>'required'));
$item6 = $this->createElement('text','item6')
->setLabel('Enter Item 6:')
->setRequired(true)
->addDecorator('Label',array('tag' => 'dt','class'=>'required'));
$item7 = $this->createElement('text','item7')
->setLabel('Enter Item 7:')
->setRequired(true)
->addDecorator('Label',array('tag' => 'dt','class'=>'required'));
$item8 = $this->createElement('text','item8')
->setLabel('Enter Item 8:')
->setRequired(true)
->addDecorator('Label',array('tag' => 'dt','class'=>'required'));
$item9 = $this->createElement('text','item9')
->setLabel('Enter Item 9:')
->setRequired(true)
->addDecorator('Label',array('tag' => 'dt','class'=>'required'));
$item10 = $this->createElement('text','item10')
->setLabel('Enter Item 2:')
->setRequired(true)
->addDecorator('Label',array('tag' => 'dt','class'=>'required'));
$div_element = $this->createElement(
'hidden', 'dummy', array(
'required' => false,
'ignore' => true,
'autoInsertNotEmptyValidator' => false,
'decorators' => array(
array(
'HtmlTag', array(
'tag' => 'div',
'id' => 'TextBoxes',
'class' => 'TextBoxes'
)
)
)
)
);
$image = new Zend_Form_Element_File('doc_path');
$image->setLabel('Upload Your Image');
// ->setRequired(true);
$image->addValidator('Extension', false, 'jpg,jpeg,png,gif')
->addValidator('Size', false, array('min' => 20, 'max' => 409600));
$captchaDir = rtrim(APPLICATION_PATH, '/application') . 'public\captcha\\';
$font = rtrim(APPLICATION_PATH, '/application') . 'public\captcha\arial.ttf';
// echo $_SERVER['DOCUMENT_ROOT'];
$captcha = new Zend_Form_Element_Captcha(
'captcha', // This is the name of the input field
array('label' => 'Write the chars to the field',
'captcha' => array(// Here comes the magic...
// First the type...
'captcha' => 'Image',
// Length of the word...
'wordLen' => 6,
// Captcha timeout, 5 mins
'timeout' => 300,
// What font to use...
'font' => $font,
// Where to put the image
'imgDir' => $captchaDir,
// URL to the images
// This was bogus, here's how it should be... Sorry again :S
'imgUrl' => 'http://localhost/vastuprem/public/captcha/',
)));
$register = $this->createElement('submit', 'register');
$register->setLabel('Submit')
->setIgnore(true);
// ->setAttrib('onclick', "javascript: validate(document.getElementById('no_of_item').value)");
$this->addElements(array(
$firstname,
$lastname,
$email,
$country,
$states,
$cities,
$cor_address,
$per_address,
$landline,
$mobile_no,
$fax_no,
$dob,
$tob,
$birth_place,
$marriage_date,
$religion,
$deity,
$occupation,
$commu_mode,
$appo_date,
$comm_time_from,
$comm_time_to,
$kundli,
$gen_query,
$items,
$item1,
$item2,
$item3,
$item4,
$item5,
$item6,
$item7,
$item8,
$item9,
$item10,
$div_element,
$image,
$captcha,
$register
));
//$this->dummy->clearValidators();
}
}
javascript code for
function show(count){
// document.getElementById("item1").style.display="none" ;
document.getElementById("item1").disabled = true ;
document.getElementById("item1-label").style.display="none" ;
document.getElementById("item1-element").style.display="none";
// document.getElementById("item2").style.display="none" ;
document.getElementById("item2").disabled = true ;
document.getElementById("item2-label").style.display="none" ;
document.getElementById("item2-element").style.display="none";
// document.getElementById("item3").style.display="none" ;
document.getElementById("item3").disabled = true ;
document.getElementById("item3-label").style.display="none";
document.getElementById("item3-element").style.display="none";
//
// document.getElementById("item4").style.display="none" ;
document.getElementById("item4").disabled = true ;
document.getElementById("item4-label").style.display="none" ;
document.getElementById("item4-element").style.display="none";
// document.getElementById("item5").style.display="none" ;
document.getElementById("item5").disabled = true ;
document.getElementById("item5-label").style.display="none";
document.getElementById("item5-element").style.display="none";
//
// document.getElementById("item6").style.display="none" ;
document.getElementById("item6").disabled = true ;
document.getElementById("item6-label").style.display="none" ;
document.getElementById("item6-element").style.display="none";
// document.getElementById("item7").style.display="none" ;
document.getElementById("item7").disabled = true ;
document.getElementById("item7-label").style.display="none" ;
document.getElementById("item7-element").style.display="none";
// document.getElementById("item8").style.display="none" ;
document.getElementById("item8").disabled = true ;
document.getElementById("item8-label").style.display="none" ;
document.getElementById("item8-element").style.display="none";
// document.getElementById("item9").style.display="none" ;
document.getElementById("item9").disabled = true ;
document.getElementById("item9-label").style.display="none" ;
document.getElementById("item9-element").style.display="none";
// document.getElementById("item10").style.display="none" ;
document.getElementById("item10").disabled = true ;
document.getElementById("item10-label").style.display="none" ;
document.getElementById("item10-element").style.display="none" ;
for (i=1;i<=count;i++){
document.getElementById("item"+i).style.display="block";
document.getElementById("item"+i).disabled = false ;
document.getElementById("item"+i+"-label").style.display="block";
document.getElementById("item"+i+"-element").style.display="block";
}
}
function hide(count){
// document.getElementById("item1").style.display="none" ;
document.getElementById("item1").disabled = true ;
document.getElementById("item1-label").style.display="none" ;
document.getElementById("item1-element").style.display="none";
// document.getElementById("item2").style.display="none" ;
document.getElementById("item2").disabled = true ;
document.getElementById("item2-label").style.display="none" ;
document.getElementById("item2-element").style.display="none";
// docum开发者_Python百科ent.getElementById("item3").style.display="none" ;
document.getElementById("item3").disabled = true ;
document.getElementById("item3-label").style.display="none";
document.getElementById("item3-element").style.display="none";
//
// document.getElementById("item4").style.display="none" ;
document.getElementById("item4").disabled = true ;
document.getElementById("item4-label").style.display="none" ;
document.getElementById("item4-element").style.display="none";
// document.getElementById("item5").style.display="none" ;
document.getElementById("item5").disabled = true ;
document.getElementById("item5-label").style.display="none";
document.getElementById("item5-element").style.display="none";
//
// document.getElementById("item6").style.display="none" ;
document.getElementById("item6").disabled = true ;
document.getElementById("item6-label").style.display="none" ;
document.getElementById("item6-element").style.display="none";
// document.getElementById("item7").style.display="none" ;
document.getElementById("item7").disabled = true ;
document.getElementById("item7-label").style.display="none" ;
document.getElementById("item7-element").style.display="none";
// document.getElementById("item8").style.display="none" ;
document.getElementById("item8").disabled = true ;
document.getElementById("item8-label").style.display="none" ;
document.getElementById("item8-element").style.display="none";
// document.getElementById("item9").style.display="none" ;
document.getElementById("item9").disabled = true ;
document.getElementById("item9-label").style.display="none" ;
document.getElementById("item9-element").style.display="none";
// document.getElementById("item10").style.display="none" ;
document.getElementById("item10").disabled = true ;
document.getElementById("item10-label").style.display="none" ;
document.getElementById("item10-element").style.display="none" ;
//
//
show(count);
}
Try manual debug as follows,
- Check whether you have got the values of text boxes by $_POST. Use
echo
to print those values. - If values are not getting printed then check your Javascript code which generates text boxes.
- If you get correct values then try to print the complete INSERT query, run the complete query on the MySQL prompt. If there is an error in the query, it will tell you what's wrong.
- If query is correct, check database connection status.
精彩评论