PDA

View Full Version : Combobox and PHP?



amegahed
22 Sep 2009, 8:54 AM
Im trying to fill a combobox in a php page (not sure how i can describe what i want) here is the code:
the php page:


.............
<td><div id="my-register-panel" align="center">
<table width="80%" border="0">
<tr bgcolor="#3B80B5">
<td colspan="3"><div align="center" class="style2 style5">Clinic Registration Form</div></td>
</tr>
<tr>
<td width="19%" bgcolor="#F3F3F3"><div align="left" class="style6"><span class="style4">Clinic Name:</span></div></td>
<td width="81%" align="left">
<input type="text" class="style4" name="clinicname" id="clinicname" size="40" /> </td>
</tr>
<tr>
<td bgcolor="#F3F3F3"><div align="left" class="style6"><span class="style4">Address:</span></div></td>
<td align="left">
<input type="text" class="style4" name="address" id="address" size="70" /> </td>
</tr>
<tr>
<td bgcolor="#F3F3F3"><div align="left" class="style6"><span class="style4">City:</span></div></td>
<td><div align="left">
<select name="city" class="style4" id="city">
<option>item1</option>
</select>
</div></td>
</tr>
................


and here is my js page:


// JavaScript Document
Ext.onReady(function(){
// dsMapCities dataStore
var dsMapCities = new Ext.data.JsonStore({
totalProperty : 'total',
root : 'results',
url : '../php/myqueries.php',
baseParams : { queryid: 101 },
method : 'post',
fields : [
{name: 'city', type: 'int'},
'mapname'
]
});
var fieldCity = new Ext.form.ComboBox({
id : 'city',
triggerAction : 'all',
name : 'city',
mode : 'local',
store : dsMapCities,
hiddenName : 'cityid',
displayField : 'mapname',
valueField : 'cityid',
emptyText : 'Select a City ...',
width : 200
});

var loginPanel = Ext.get("my-register-panel");
var submitBtn = Ext.get("submitBtn");
submitBtn.on({'click': { fn: fnSubmit }});
//func: fnSubmit
function fnSubmit(){
var clinicname = Ext.get("clinicname").dom.value;
var address = Ext.get("address").dom.value;
var city = Ext.get("city").dom.value;
var district = Ext.get("district").dom.value;
var tel1 = Ext.get("tel1").dom.value;
var tel2 = Ext.get("tel2").dom.value;
var tel3 = Ext.get("tel3").dom.value;
var fax = Ext.get("fax").dom.value;
var website = Ext.get("website").dom.value;
var email = Ext.get("email").dom.value;

if(validate(clinicname) === false){
alert("Your Clinic's Name is Required!!");
return false;
}
if(validate(address) === false){
alert("Your Clinic's Address is Required!!");
return false;
}
if(validate(tel1) === false && validate(tel2) === false && validate(tel3) === false){
alert("You have to supply atleast 1 Telephone No. !!");
return false;
}


loginPanel.mask('Please wait...', 'x-mask-loading');
}
//func: validate
function validate(field){
if(field === ""){ return false; }
return true;
}
});


my question is, is there a way to fill in the dataset [dsMapCities] into the combobox id'ed by [city] on page load?

29 Sep 2009, 6:28 AM
look at the comboBox examples, specifically, applyTo