maliary Posted May 8, 2007 Share Posted May 8, 2007 Hi, I have a form which does a search --- see below -- which works ok, but the problem is I have to click the submit button twice for it to execute. why does it do this? The form values are passed into the function : $encounter2=&$lab_obj->searchLimitEncounterLabResults2($keyword,$pagen->MaxCount(),$pgx,$oitem,$odir,$queryFrom,$queryTo); <FORM action="<?php echo $thisfile; ?>" method="post" name="sform" onSubmit="return checkForm(sform.keyword)"> <B><?php echo 'Enter Date Range' ?></B></font><p> From:<font size=3> <INPUT type="text" name="from_date" size="20" maxlength="40" value=<?php echo '"'.$sBdayBuffer.'" '.$sDateJSfrom.''?> </font> <p></p> To: <font size=3> <INPUT type="text" name="to_date" size="20" maxlength="40" value=<?php echo '"'.$sBdayBuffer.'" '.$sDateJSto.''?> </font> <p></p> <B><?php echo $LDSearchWordPrompt ?></B></font><p> <font size=3> <INPUT type="text" name="keyword" size="20" maxlength="40" value="<?php echo $keyword ?>"></font> <input type=hidden name="search" value=1> <input type=hidden name="sid" value=<?php echo $sid ?>> <input type=hidden name="lang" value=<?php echo $lang ?>> <input type=hidden name="editmode" value=<?php echo $editmode ?>> <INPUT type="image" <?php echo createLDImgSrc($root_path,'searchlamp.gif','0','absmiddle') ?>> <a href="javascript:gethelp('lab.php','search','<?php echo $mode ?>','<?php echo $linecount ?>','<?php echo $datafound ?>')"><img <?php echo createLDImgSrc($root_path,'hilfe-r.gif','0','absmiddle') ?>></a> <?php $from_date = explode ("/",$from_date); $queryFrom = $from_date[2].$from_date[1].$from_date[0]; $to_date = explode ("/",$to_date); $queryTo = $to_date[2].$to_date[1].$to_date[0]; ?> <input type=hidden name="queryFrom" value="<?php echo $queryFrom ?>"> <input type=hidden name="queryTo" value="<?php echo $queryTo ?>"> </FORM> It reason could probably be the orange area - but is there another way of passing the dates to the function ? M Quote Link to comment https://forums.phpfreaks.com/topic/50505-solved-i-need-your-help/ Share on other sites More sharing options...
MadTechie Posted May 8, 2007 Share Posted May 8, 2007 yep the orange area looks like the cause, but your need to post more of your code in the code tags.. Quote Link to comment https://forums.phpfreaks.com/topic/50505-solved-i-need-your-help/#findComment-248226 Share on other sites More sharing options...
maliary Posted May 9, 2007 Author Share Posted May 9, 2007 Thanks, How can I re-edit? Is there another way of working around the code at the orange area? Maliary Quote Link to comment https://forums.phpfreaks.com/topic/50505-solved-i-need-your-help/#findComment-248772 Share on other sites More sharing options...
MadTechie Posted May 9, 2007 Share Posted May 9, 2007 yep the orange area looks like the cause, but your need to post more of your code in the code tags.. Quote Link to comment https://forums.phpfreaks.com/topic/50505-solved-i-need-your-help/#findComment-248840 Share on other sites More sharing options...
maliary Posted May 9, 2007 Author Share Posted May 9, 2007 Hi, I have a form which does a search --- see below -- which works ok, but the problem is I have to click the submit button twice for it to execute. why does it do this? The form values are passed into the function : $encounter2=&$lab_obj->searchLimitEncounterLabResults2($keyword,$pagen->MaxCount(),$pgx,$oitem,$odir,$queryFrom,$queryTo); <FORM action="<?php echo $thisfile; ?>" method="post" name="sform" onSubmit="return checkForm(sform.keyword)"> <B><?php echo 'Enter Date Range' ?></B></font><p> From:<font size=3> <INPUT type="text" name="from_date" size="20" maxlength="40" value=<?php echo '"'.$sBdayBuffer.'" '.$sDateJSfrom.''?> </font> <p></p> To: <font size=3> <INPUT type="text" name="to_date" size="20" maxlength="40" value=<?php echo '"'.$sBdayBuffer.'" '.$sDateJSto.''?> </font> <p></p> <B><?php echo $LDSearchWordPrompt ?></B></font><p> <font size=3> <INPUT type="text" name="keyword" size="20" maxlength="40" value="<?php echo $keyword ?>"></font> <input type=hidden name="search" value=1> <input type=hidden name="sid" value=<?php echo $sid ?>> <input type=hidden name="lang" value=<?php echo $lang ?>> <input type=hidden name="editmode" value=<?php echo $editmode ?>> <INPUT type="image" <?php echo createLDImgSrc($root_path,'searchlamp.gif','0','absmiddle') ?>> <a href="javascript:gethelp('lab.php','search','<?php echo $mode ?>','<?php echo $linecount ?>','<?php echo $datafound ?>')"><img <?php echo createLDImgSrc($root_path,'hilfe-r.gif','0','absmiddle') ?>>[/url] <?php //ORANGE AREA $from_date = explode ("/",$from_date); $queryFrom = $from_date[2].$from_date[1].$from_date[0]; $to_date = explode ("/",$to_date); $queryTo = $to_date[2].$to_date[1].$to_date[0]; ?> <input type=hidden name="queryFrom" value="<?php echo $queryFrom ?>"> <input type=hidden name="queryTo" value="<?php echo $queryTo ?>"> </FORM> It reason could probably be the orange area - but is there another way of passing the dates to the function ? Quote Link to comment https://forums.phpfreaks.com/topic/50505-solved-i-need-your-help/#findComment-249027 Share on other sites More sharing options...
maliary Posted May 10, 2007 Author Share Posted May 10, 2007 I need to eliminate the need to click on the submit button twice? Does this occur often,why? Quote Link to comment https://forums.phpfreaks.com/topic/50505-solved-i-need-your-help/#findComment-249817 Share on other sites More sharing options...
MadTechie Posted May 10, 2007 Share Posted May 10, 2007 yep the orange area looks like the cause,but your need to post more of your code in the code tags.. Quote Link to comment https://forums.phpfreaks.com/topic/50505-solved-i-need-your-help/#findComment-250056 Share on other sites More sharing options...
maliary Posted May 11, 2007 Author Share Posted May 11, 2007 ok, What do you mean? Quote Link to comment https://forums.phpfreaks.com/topic/50505-solved-i-need-your-help/#findComment-250323 Share on other sites More sharing options...
MadTechie Posted May 11, 2007 Share Posted May 11, 2007 erm.. i mean can you post more of your code.. theirs nothing we can do without the complete picture.. we have a form great but without the rest we can't help!!! Quote Link to comment https://forums.phpfreaks.com/topic/50505-solved-i-need-your-help/#findComment-250500 Share on other sites More sharing options...
maliary Posted May 12, 2007 Author Share Posted May 12, 2007 The entire page is quite big. <?php eakfile='labor.php'.URL_APPEND; # Workaround if(!isset($mode)){ $mode=''; }elseif($mode=='edit'){ $editmode=TRUE; } $keyword=trim($keyword); $toggle=0; # Initialize page�s control variables if($mode=='paginate'){ $keyword=$HTTP_SESSION_VARS['sess_searchkey']; }else{ # Reset paginator variables $pgx=0; $totalcount=0; $odir='ASC'; $oitem='name_last'; $queryFrom = 0; $queryTo = 0; # Workaround: Resolve the search key variables if(empty($keyword)&&!empty($searchkey)) $keyword=$searchkey; if(is_numeric($keyword)){ $keyword=(int) $keyword; }else{ # Convert other wildcards $keyword=strtr($keyword,'*&','%_'); } } if($search&&!empty($keyword)){ # Load the date formatter include_once($root_path.'include/inc_date_format_functions.php'); include_once($root_path.'include/care_api_classes/class_lab.php'); $lab_obj=new Lab(); #Load and create paginator object include_once($root_path.'include/care_api_classes/class_paginator.php'); $pagen=& new Paginator($pgx,$thisfile,$HTTP_SESSION_VARS['sess_searchkey'],$root_path); $GLOBAL_CONFIG=array(); include_once($root_path.'include/care_api_classes/class_globalconfig.php'); $glob_obj=new GlobalConfig($GLOBAL_CONFIG); # Get the max nr of rows from global config $glob_obj->getConfig('pagin_patient_search_max_block_rows'); if(empty($GLOBAL_CONFIG['pagin_patient_search_max_block_rows'])) $pagen->setMaxCount(MAX_BLOCK_ROWS); # Last resort, use the default defined at the start of this page else $pagen->setMaxCount($GLOBAL_CONFIG['pagin_patient_search_max_block_rows']); if($editmode){ # Search $encounter=&$lab_obj->searchLimitEncounterBasicInfo($keyword,$pagen->MaxCount(),$pgx,$oitem,$odir,$queryFrom,$queryTo); }else{ $encounter=&$lab_obj->searchLimitEncounterLabResults($keyword,$pagen->MaxCount(),$pgx,$oitem,$odir,$queryFrom,$queryTo); # Get the number of results found } # Get the resulting record count if($linecount=$lab_obj->LastRecordCount()){ if($mode!='paginate') $HTTP_SESSION_VARS['sess_searchkey']=$keyword; $pagen->setTotalBlockCount($linecount); # Count total available data if(isset($totalcount)&&$totalcount){ $pagen->setTotalDataCount($totalcount); }else{ if($editmode){ @$lab_obj->searchEncounterBasicInfo($keyword); }else{ @$lab_obj->searchEncounterLabResults($keyword); } $totalcount=$lab_obj->LastRecordCount(); $pagen->setTotalDataCount($totalcount); } $pagen->setSortItem($oitem); $pagen->setSortDirection($odir); } } ?> <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 3.0//EN" "html.dtd"> <?php html_rtl($lang); ?> <HEAD> <?php echo setCharSet(); ?> <?php require($root_path.'include/inc_js_gethelp.php'); require($root_path.'include/inc_css_a_hilitebu.php'); $sDateJSfrom ='onFocus="this.select();"> <a href="javascript:show_calendar(\'sform.from_date\',\''.$date_format.'\')"> <img '.createComIcon($root_path,'show-calendar.gif','0','absmiddle').'></a> <font size=1>[dd/mm/yyyy]</font>'; $sDateJSto ='onFocus="this.select();"> <a href="javascript:show_calendar(\'sform.to_date\',\''.$date_format.'\')"> <img '.createComIcon($root_path,'show-calendar.gif','0','absmiddle').'></a> <font size=1>[dd/mm/yyyy]</font>'; ?> <script language="JavaScript"> <!-- Script Begin function checkForm(v) { if((v.value=="")||(v.value==" ")){ v.value=""; v.focus(); return false; }else{ return true; } } // Script End --> </script> <script language="javascript" src="<?php echo $root_path; ?>js/setdatetime.js"></script> <script language="javascript" src="<?php echo $root_path; ?>js/checkdate.js"></script> <script language="javascript" src="<?php echo $root_path; ?>js/dtpick_care2x.js"></script> </HEAD> <!-- check on this --> <BODY onLoad="document.sform.keyword.select()"> <img <?php echo createComIcon($root_path,'micros.gif','0','absmiddle') ?>><FONT COLOR="<?php echo $cfg[top_txtcolor] ?>" SIZE=5> <b><?php echo "$LDMedLab - "; if($editmode) echo "$LDNewData"; else echo "$LDSeeData"; ?></b></font> <table width=100% border=0 cellpadding="0" cellspacing="0"> <tr> <td colspan=3><img <?php echo createLDImgSrc($root_path,'such-b.gif') ?>></td> </tr> <tr > <td bgcolor=#333399 colspan=3> </td> </tr> <tr bgcolor="#DDE1EC" > <td bgcolor=#333399> </td> <td valign=top><p><br> <ul> <!-- This is the search entry mask --> <FORM action="<?php echo $thisfile; ?>" method="post" name="sform" > <B><?php echo 'Enter Date Range' ?></B></font><p> From:<font size=3> <INPUT type="text" name="from_date" size="20" maxlength="40" value=<?php echo '"'.$sBdayBuffer.'" '.$sDateJSfrom.''?> </font> <p></p> To: <font size=3> <INPUT type="text" name="to_date" size="20" maxlength="40" value=<?php echo '"'.$sBdayBuffer.'" '.$sDateJSto.''?> </font> <p></p> <B><?php echo $LDSearchWordPrompt ?></B></font><p> <font size=3> <INPUT type="text" name="keyword" size="20" maxlength="40" value="<?php echo $keyword ?>"></font> <input type=hidden name="search" value=1> <input type=hidden name="sid" value=<?php echo $sid ?>> <input type=hidden name="lang" value=<?php echo $lang ?>> <input type=hidden name="editmode" value=<?php echo $editmode ?>> <INPUT type="image" <?php echo createLDImgSrc($root_path,'searchlamp.gif','0','absmiddle') ?>> <a href="javascript:gethelp('lab.php','search','<?php echo $mode ?>','<?php echo $linecount ?>','<?php echo $datafound ?>')"><img <?php echo createLDImgSrc($root_path,'hilfe-r.gif','0','absmiddle') ?>></a> <?php $from_date = explode ("/",$from_date); $queryFrom = $from_date[2].$from_date[1].$from_date[0]; $to_date = explode ("/",$to_date); $queryTo = $to_date[2].$to_date[1].$to_date[0]; ?> <input type=hidden name="queryFrom" value="<?php echo $queryFrom ?>"> <input type=hidden name="queryTo" value="<?php echo $queryTo ?>"> </FORM> <p> <?php $prev_nr=0; # Print the search result message if($search||$mode=='paginate'){ if ($linecount) echo str_replace('~nr~',$totalcount,$LDSearchFound).' '.$LDShowing.' '.$pagen->BlockStartNr().' '.$LDTo.' '.$pagen->BlockEndNr().'.'; else echo str_replace('~nr~','0',$LDSearchFound); } if($linecount){ $dcount=0; $append="&search=1&editmode=$editmode"; $img_male=createComIcon($root_path,'spm.gif','0','',TRUE); $img_female=createComIcon($root_path,'spf.gif','0','',TRUE); $bgimg='tableHeaderbg3.gif'; $tbg= 'background="'.$root_path.'gui/img/common/'.$theme_com_icon.'/'.$bgimg.'"'; # Create the column descriptors ?> <table border=0 cellpadding=3 cellspacing=1> <tr class="wardlisttitlerow"> <td><b> <?php echo $pagen->makeSortLink(TestType,'type',$oitem,$odir,$append); ?></b></td> <td><b> <?php echo $pagen->makeSortLink($LDCaseNr,'encounter_nr',$oitem,$odir,$append); ?></b></td> <td ><b> <?php echo $pagen->makeSortLink($LDSex,'sex',$oitem,$odir,$append); ?></b></td> <td><b> <?php echo $pagen->makeSortLink($LDLastName,'name_last',$oitem,$odir,$append); ?></b></td> <td><b> <?php echo $pagen->makeSortLink($LDName,'name_first',$oitem,$odir,$append); ?></b></td> <td><b> <?php echo $pagen->makeSortLink(TestDate,'test_date',$oitem,$odir,$append); ?></b></td> <td><b> <?php echo $pagen->makeSortLink(FindingsDate,'findings_date',$oitem,$odir,$append); ?></b></td> <td><b> <?php echo $pagen->makeSortLink(PID,'pid',$oitem,$odir,$append); ?></b></td> <td><b> <?php echo $pagen->makeSortLink($LDBday,'date_birth',$oitem,$odir,$append); ?></b></td> <td background="<?php echo createBgSkin($root_path,'tableHeaderbg.gif'); ?>" align=center><font face=arial size=2 color="#ffffff"><b><?php echo $LDSelect; ?></td> </tr> <?php /* for($i=0;$i<sizeof($LDfieldname);$i++) { echo"<td><font face=arial size=2 color=#ffffff><b>".$LDfieldname[$i]."</b></td>"; } */ # List all the stored lab result documents of the patient while($zeile=$encounter->FetchRow()){ if($zeile['encounter_nr']!=$prev_nr){ $prev_nr=$zeile['encounter_nr']; $dcount++; echo ' <tr class='; if($toggle) { echo 'wardlistrow2>';} else {echo 'wardlistrow1>';} $toggle=!$toggle; echo'<td>'; echo ' '.$zeile['type']; echo '</td>'; echo '<td>'; echo ' '.$zeile['encounter_nr']; if($zeile['encounter_class_nr']==2) echo ' <img '.createComIcon($root_path,'redflag.gif','0','',TRUE).'> <font size=1 color="red">'.$LDAmbulant.'</font>'; echo '</td>'; echo '<td>'; switch($zeile['sex']){ case 'f': echo '<img '.$img_female.'>'; break; case 'm': echo '<img '.$img_male.'>'; break; default: echo ' '; break; } echo '</td><td>'; echo ' '.ucfirst($zeile['name_last']); echo '</td> <td>'; echo ' '.ucfirst($zeile['name_first']); echo '</td><td>'; if ( $zeile['test_date'] == '') { echo ' N/A'; } else { echo ' '.$zeile['test_date']; } echo '</td><td>'; if ( $zeile['findings_date'] == '') { echo ' N/A'; } else { echo ' '.$zeile['findings_date']; } echo '</td><td>'; echo ' '.$zeile['pid']; echo '</td><td>'; echo ' '.formatDate2Local($zeile['date_birth'],$date_format); echo '</td>'; # if mode is edit, create the button linked to labor_data_check_arch.php # if mode is not edit, create button linked to labor_datalist_noedit.php (read only list) echo' <td> '; if($editmode){ echo'<a href="labor_data_check_arch.php'.URL_APPEND.'&mode=edit&encounter_nr='.$zeile['encounter_nr'].'&update=1" title="'.$LDEnterData.'"> <button onClick="javascript:window.location.href=\'labor_data_check_arch.php'.URL_REDIRECT_APPEND.'&mode=edit&encounter_nr='.$zeile['encounter_nr'].'&update=1\'"><img '.createComIcon($root_path,'update2.gif','0','absmiddle',FALSE).' alt="'.$LDEnterData.'"><font size=1> '.$LDNewData; }else{ echo' <a href="labor_datalist_noedit.php'.URL_APPEND.'&encounter_nr='.$zeile['encounter_nr'].'&noexpand=1&nostat=1&user_origin=lab" title="'.$LDClk2See.'"> <button onClick="javascript:window.location.href=\'labor_datalist_noedit.php'.URL_REDIRECT_APPEND.'&encounter_nr='.$zeile['encounter_nr'].'&noexpand=1&nostat=1&user_origin=lab\'"><img '.createComIcon($root_path,'update2.gif','0','absmiddle',FALSE).' alt="'.$LDClk2See.'"><font size=1> '.$LDLabReport; } echo '</font></button></a> </td></tr>'; } } if($totalcount>$pagen->MaxCount()){ echo ' <tr><td colspan=5>'.$pagen->makePrevLink($LDPrevious,$append).'</td> <td align=right>'.$pagen->makeNextLink($LDNext,$append).'</td> </tr>'; } echo '</table>'; # If result is more than 15 items, create an additional search entry mask below the list if($dcount>$pagen->MaxCount()){ echo ' <p><font color=red><B>'.$LDNewSearch.':</font> <FORM action="'.$thisfile.'" method="post" name="form2" onSubmit="return checkForm(form2.keyword)"> '.$LDSearchWordPrompt.'</B><p> <INPUT type="text" name="keyword" size="20" maxlength="40" value="'.$keyword.'"> <input type=hidden name="search" value=1> <input type=hidden name="sid" value="'.$sid.'"> <input type=hidden name="lang" value="'.$lang.'"> <input type=hidden name="editmode" value="'.$editmode.'"> <INPUT type="image" '.createLDImgSrc($root_path,'searchlamp.gif','0','absmiddle').'></FORM> <p>'; } } ?> <p> <br> <p> <a href="<?php echo $breakfile ?>"><img <?php echo createLDImgSrc($root_path,'cancel.gif','0') ?>></a> <p> </ul> </FONT> <p> </td> <td bgcolor=#333399> </td> </tr> <tr > <td bgcolor="#333399" colspan=3><font size=1> </td> </tr> </table> <p> <?php require($root_path.'include/inc_load_copyrite.php'); ?> </FONT> </BODY> </HTML> This is the function that performs the search , where the arguments are passed to: function searchLimitEncounterLabResults($key,$len,$so,$sortitem='',$order='ASC',$queryFrom,$queryTo){ if(!empty($sortitem)){ $option=" ORDER BY $sortitem $order"; }else{ $option=''; } return $this->searchEncounterLabResults($key,$option,TRUE,$len,$so,$queryFrom,$queryTo); } function searchEncounterLabResults($key='',$add_opt='',$limit=FALSE,$len=30,$so=0,$queryFrom='',$queryTo=''){ global $db, $sql_LIKE; $pn=$_POST['queryFrom'] ; $cw=$_POST['queryTo'] ; if(empty($key)) return FALSE; $this->sql="SELECT p.*, f.* FROM $this->tb_person AS p LEFT JOIN $this->tb_enc AS e ON p.pid = e.pid LEFT JOIN $this->tb_find_baclabor AS f ON e.encounter_nr = f.encounter_nr "; if(is_numeric($key)){ $key=(int)$key; $this->sql.=" WHERE e.encounter_nr = $key"; }else{ $this->sql.=" WHERE e.encounter_nr = f.encounter_nr AND findings_date BETWEEN $pn AND $cw AND f.status NOT IN ($this->dead_stat) AND (e.encounter_nr $sql_LIKE '$key%' OR p.pid $sql_LIKE '$key%' OR p.name_last $sql_LIKE '$key%' OR p.name_first $sql_LIKE '$key%' OR p.date_birth $sql_LIKE '$key%') "; if($enc_class) $sql.=" AND e.encounter_class_nr=$enc_class"; } # Append the common condition //$this->sql.=" GROUP BY f.encounter_nr, e.encounter_class_nr, p.pid, p.name_last, p.name_first, p.date_birth, p.sex $add_opt"; //echo $this->sql; if($limit){ $this->res['selr']=$db->SelectLimit($this->sql,$len,$so); }else{ $this->res['selr']=$db->Execute($this->sql); } if ($this->res['selr']) { if ($this->record_count=$this->res['selr']->RecordCount()) { # Workaround $this->rec_count=$this->record_count; return $this->res['selr']; }else{return FALSE;} }else{return FALSE;} } Quote Link to comment https://forums.phpfreaks.com/topic/50505-solved-i-need-your-help/#findComment-251197 Share on other sites More sharing options...
MadTechie Posted May 12, 2007 Share Posted May 12, 2007 OK thats a real mess.. and theirs still parts missing...! i'm not filtering that so my suggection would be make sure the form is after the update of date and the update is before the reading of data.. i can't really point you in any realy direction as i find your code quite hard to read! Quote Link to comment https://forums.phpfreaks.com/topic/50505-solved-i-need-your-help/#findComment-251272 Share on other sites More sharing options...
maliary Posted May 13, 2007 Author Share Posted May 13, 2007 Hi, I solved it. I included the following hidden fields in the form to pass both the to-date and from-date to the function. <input type=hidden name="from" value="<?php echo $from_date ?>"> <input type=hidden name="to" value="<?php echo $to_date ?>"> this function $encounter=&$lab_obj->searchLimitEncounterLabResults($keyword,$pagen->MaxCount(),$pgx,$oitem,$odir,$from_date,$to_date); Quote Link to comment https://forums.phpfreaks.com/topic/50505-solved-i-need-your-help/#findComment-251888 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.