Hi,
I’m not a programmer and have many limitations in JavaScript.
I’m creating in HTML a registation of data in a form all in Jquery Mobile (i’m a Tradicional Chinese Medicine Doctor and this is for collect data to investigation)
I have a form in a JS file that have all database creation and registation but i want to have a Dinamic Form that i can change dinamicaly and use a external file for that. my first problem is :
Insted of having this in my app.js to create a form:
var diagnoseForm = [//Astenia
{ input_type: 'config', id: 'Astenia', lable: 'Astenia' }
//,{ input_type: 'input', input_id: 'AsteniaOutro', input_lable: 'Outro' }
,{ input_type: 'checkbox', input_id: 'AsteniaType', input_lable: 'Tipo de Astenia', input_list: [{refname:'AsteniaMental', input_lable:'Astenia Mental'},{refname:'AsteniaFisica', input_lable:'Astenia Fisica'},{refname:'Asteniaquepioracomoesforço', input_lable:'Astenia que piora com o esforço'},{refname:'Asteniaaoacordar', input_lable:'Astenia ao acordar'},{refname:'Lentidão', input_lable:'Lentidão'},{refname:'Esgotamentopeloesforço', input_lable:'Esgotamento pelo esforço'},{refname:'AusênciadeAsteniaMental', input_lable:'Ausência de Astenia Mental'},{refname:'AusênciadeAsteniaFísica', input_lable:'AusênciadeAsteniaFísica'}] }
]
Can i have only this?That load a external JSON file?..
var diagnoseForm = [{'url':'js/TCMForm2014.json'}]
I’m asking this because i have a data container for html file that i can’t load (i’m using XAMPP to simulate)
My index.html file have this lines:
</head>
<body>
<div data-role="page" id="home" data-theme="b">
<div data-role="header" data-position="fixed">
<h3>TCM Diagnosis</h3>
<div data-role="navbar" data-iconpos="top">
<ul id="subNavPage">
<li><a class="btn-footer" href="parts/home.html" >Home</a></li>
<li><a class="btn-footer" href="parts/client.html" >Client</a></li>
<li><a class="btn-footer" href="parts/diagnose.html" >Diagnose</a></li>
<li><a class="btn-footer" href="parts/config.html" >Config</a></li>
<li><a class="btn-footer" href="parts/helper.html" >Helper</a></li>
</div>
</div>
<div data-role="content" id="MainContainer">
</div>
</div>
</body>
</html>
<script src="js/app.js"></script>
<script>
// Home script
</script>
and it should in the main container open other pages like the form…but it returns a blank page without any error…
What i am doing wrong?
Here is the Diagnose.HTML:
<div id="contentTitle"></div>
<div id="contentList"></div>
<script>
$(document).ready(function() {
setContentTable();
$("#submitform").die("click");
$("#submitform").live("click", function(e) {
Diagnose.onSave( $("#appform").serialize() );
e.preventDefault();
});
});
function setContentTable() {
var html_form = Diagnose.modelForm();
$('#contentList').html(html_form).trigger("create");
}
</script>
And here is the JS file that create the HTML:
/* App Functions */
function PageClick(onEvent) {
var idClick = onEvent.attr('href').replace('#','');
if ( idClick.match(/(.*).html/) ) {
ajaxReq({'url':'parts/'+idClick, 'datatype':'html'}, 'successAddPart');
}
}
function configClick(onEvent) {
var action = onEvent.attr('href').replace('#','');
createInitialDB(action);
}
function successAddPart(msg) {
$('#MainContainer').html(msg);
}
function successAddPartOnErrorAjaxReq(msg) {}
function successClientDetail(msg) {
$('#MainContainer').html(msg);
}
function successAddPartOnErrorAjaxReq(msg) {}
var Diagnose = {
db: {},
datarow: '',
onClick: function(onEvent) {
var action = onEvent.attr('href').replace('#','');
},
onAdd: function(msg) {
},
onEdit: function(msg) {
},
onDelete: function(msg) {
},
modelForm: function(idType) {
html = '<form id="appform">';
html += myForm.field_select('id_client', 'Cliente', Client.getselect(), '', Client.id_client);
html += myForm.formBuilder(App.config['diagnose_form']);
html += '<a id="submitform" data-role="button" data-direction="reverse" data-rel="back" data-theme="a" href="#" data-icon="gear" data-iconpos="right">Save</a>';
html += '</form>';
return html;
},
onSave: function(msg) {
// Make insert on DB / Model
var json_msg = toJsonString($.unserialize(msg));
var jdata = $.parseJSON(json_msg);
if (jdata.id_client!=undefined && jdata.id_client!='') {
Client.id_client = jdata.id_client;
}
this.datarow = '['+json_msg.toString()+']';
db.transaction(this.onDiagnoseSave2DB, db_error, this.onDiagnoseSave2DBSuccess);
// $('#contentList').html().trigger("create");
$('#contentList').html('<div><h3>New diagnose saved!</h3></div>').trigger("create");
},
onDiagnoseSave2DB: function(tx) {
tx.executeSql('INSERT INTO DIAGNOSTIC (id_diagnose, id_client, diagnostic_date, json_data) VALUES (null, "'+Client.id_client+'", datetime(), "'+escape(Diagnose.datarow)+'")');
},
onDiagnoseSave2DBSuccess: function(tx, results) {
createInitialDB('select');
setTimeout("ajaxReq({'url':'parts/clientdetail.html', 'datatype':'html'}, 'Client.requestModelDetail')",1500);
},
isActive: true
}
Can Anyone Help me?..why can i load this content in the HTML…Why it returns Empty whithout Error??