php and javascript design

borninabarn5

New Member
question relates to PHP and Javascriptfor now every table has a form with input tags that each of them has id="field_from_table"GLOBAL_TABLE=name of that table
GLOBAL_FIELDS=name of fields in that table
GLOBAL_ID=ID value for table.

every field also have a label for im.some of the fields are not text.I want to get/set those input tags.now it's design like this:\[code\] <script> function get() { id=GLOBAL_ID $.post("handle.php",{type:"get",tablename:GLOBAL_TABLE,fields:GLOBAL_FIELDS,id:GLOBAL_ID),function(data) { fieldValues=/*javascript explode data*/; foreach(/*array of fields as idx=>fieldName*/) {$("#"+fieldName)=fieldValues[idx];} } function set() { /*for each GLOBAL_FIELDS as idx=>fieldName values[fieldName]=$("#"+fieldName).val; */ valuesI=/*implode values*/; $.post("handle.php",{type:"set",tablename:GLOBAL_TABLE,fields:GLOBAL_FIELDS,values:valuesI), function(data) { if (data!=null) alert ("error"); } }</script>\[/code\]handle.php updates the information into table and fields.or selects and outputs CSV.problem is that i need to output a field list from php so javascript can use itand i don't think that using javascript that way is a good ideais there a better design.a good answer or an advice is most appreciated.arye
 
Back
Top