austine_power007 Posted December 13, 2006 Share Posted December 13, 2006 ok this is just for one condition i have more[code]while($row = odbc_fetch_array($query)){ $titl = ($row['title']); $start_dat = ($row['start_date']); $start = date("d/m/y", strtotime($start_dat)); $est_end_date = ($row['est_end_date']); $end = date("d/m/y", strtotime($est_end_date)); $actual_end_date = ($row['actual_end_date']); $actual = date("d/m/y", strtotime($actual_end_date)); $complete = ($row['complete']); $remark = ($row['remark']); if(odbc_num_rows($query)== 0) echo"No Data"; elseif(($complete)<100) { if(($complete)>50 and ($complete) <100) { echo" <tr> <td style=color:blue width='139' height='26'><div align='left'><strong>$titl</strong></dv></td> <td style=color:blue width='80'><div align='center'><strong>$start</strong></dv></td> <td style=color:blue width='94'><div align='center'><strong>$end</strong></dv></td> <td style=color:blue width='91'><div align='center'><strong>$actual</strong></dv></td> <td width='20'><div align='center'><input name='comp1' type='text' id='comp1' value=\"{$complete}\" size='02'></div></td> <td style=color:blue width='237'><div align='left'><strong>$remark</strong></dv></td> </tr> "; } elseif(($complete)<=50) { echo" <tr> <td style=color:red width='139' height='26'><div align='left'><strong>$titl</strong></dv></td> <td style=color:red width='80'><div align='center'><strong>$start</strong></dv></td> <td style=color:red width='94'><div align='center'><strong>$end</strong></dv></td> <td style=color:red width='91'><div align='center'><strong>$actual</strong></dv></td> <td width='20'><div align='center'><input name='comp2' type='text' id='comp2' value=\"{$complete}\" size='02'></div></td> <td style=color:red width='237'><div align='left'><strong>$remark</strong></dv></td> </tr> "; } ...........other codes and HTML [/code]and [code]<td width='20'><div align='center'><input name='comp1' type='text' id='comp1' value=\"{$complete}\" size='02'></div></td>[/code] for showing output in a text field so that user can change the value. i used a [b]java script[/b] so that user don't give the wrong data type. Quote Link to comment Share on other sites More sharing options...
austine_power007 Posted December 13, 2006 Author Share Posted December 13, 2006 here is the script: [code]<script>function formValidator(){ // Make quick references to our fields var comp1 = document.getElementById('comp1'); var comp2 = document.getElementById('comp2'); // Check each input in the order that it appears in the form! if(isNumeric(comp1, "Please enter a valid Number (0-100)")) { if(isNumeric(comp2, "Please enter a valid Number (0-100)")) { } } return false; }function isEmpty(elem, helperMsg){ if(elem.value.length == 0){ alert(helperMsg); elem.focus(); // set the focus to this input return true; } return false;}function isNumeric(elem, helperMsg){ var numericExpression = /^[0-9]+$/; if(elem.value.match(numericExpression)) { if(elem.value < 0) { alert(helperMsg); elem.focus(); return false; } if(elem.value > 100) { alert(helperMsg); elem.focus(); return false; } else return true; } else { alert(helperMsg); elem.focus(); return false; }}</script>[/code]there is [b]two variable[/b] because i have another condition but [color=red][b]the problem is when i insert wrong data it only checks two field but when i fetch db it have more then 2 field because i have while statement so when i change the value of the text field it checks for only two field but for other field it didn't check. why?? [/b][/color] Quote Link to comment Share on other sites More sharing options...
fenway Posted December 16, 2006 Share Posted December 16, 2006 Because you only have comp1 & comp2 hard-coded... Quote Link to comment Share on other sites More sharing options...
austine_power007 Posted December 17, 2006 Author Share Posted December 17, 2006 [quote author=fenway link=topic=118397.msg485858#msg485858 date=1166229804]Because you only have comp1 & comp2 hard-coded...[/quote][quote author=fenway link=topic=118397.msg485858#msg485858 date=1166229804]Because you only have comp1 & comp2 hard-coded...[/quote]so what is the solution for this plzz help me Quote Link to comment Share on other sites More sharing options...
fenway Posted December 18, 2006 Share Posted December 18, 2006 Either hard code whatever other fields you want, or iterate through them all somehow. Quote Link to comment 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.