PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
<HEAD>
<TITLE>Number of Fields</TITLE>
</HEAD>
<script language="javascript">
function trim(str)
{
return str.replace(/^\s*|\s*$/g,"");
}
function number(tf)
{
for (x=0;x<tf.length;x++)
{
if (!isDigit(tf.charAt(x)))
{
return false;
}
}
return true;
}
function isDigit(dig)
{
return((dig<="9")&&(dig>="0")||dig==".");
}
function validateForm()
{
var validate=true;
var f=document.field;
if (trim(f.no_field.value)=="" && validate)
{
validate=false
alert("Please enter Number of Fields.")
f.no_field.focus()
}
if(!number(f.no_field.value))
{
validate=false
alert("Please enter NUMBERS in Number of Field.")
f.no_field.focus()
}
if (validate==true)
{
f.submit();
}
}
</script>
<BODY>
<form action="field.php" method="post" name="field" onsubmit="validateForm();">
<p></p>
<?php
echo " Please key in number fields you want";
?> <p></p>
<tr>
<td >Number of Fields:</td>
<td ><input type="text" name="no_field" class="ctr2"></td>
</tr>
<td align="right"><input type="button" value="confirm" onclick="validateForm();">
</form>
</BODY>
What is "document.db"? I don't see that property created anywhere.
You call "app()" on submit, but I don't see a function named app.
The JavaScript is definitely pretty broken. I would definitely suggest studying up on JavaScript so that you can understand what is happening in this script.
Cheers
What is "document.db"? I don't see that property created anywhere.
You call "app()" on submit, but I don't see a function named app.
The JavaScript is definitely pretty broken. I would definitely suggest studying up on JavaScript so that you can understand what is happening in this script.
Cheers
Thanks for remind me. I still in the process of learning it.
I had changed the code, and the validate function is work.
But how to pass the variable to db.php?
hi PHPHorizons,
Yes, It does work. Thanks.
But somehow I integrate with my original code, it doesnt show the value. I do not know why it happen like that.