Jump to content

Checking error & update


austine_power007

Recommended Posts

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.
Link to comment
Share on other sites

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]
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.