PHP - SQL INSERT function

well its not the prettiest way to do it but:

if (((tempobj.type=="text"||tempobj.type=="textarea") &&
tempobj.value=='')
take this line and change it to

if (((tempobj.type=="text"||tempobj.type=="textarea") &&
tempobj.value=='' && tempobj.name !="colour3")
 
ok, the script now looks liek this:

PHP:
<script language='javascript'>
function checkrequired(theForm) {

for (i=0;i<theForm.length;i++) {
var tempobj=theForm.elements[i];
if (((tempobj.type=="text"||tempobj.type=="textarea") &&
tempobj.value=='' && tempobj.name !='colour3'))
{
alert("Please make sure the "+tempobj.name+" field was properly completed.");

return false;
}
}
}
</script>

but it doesnt work, it doesnt prompt for an entry in colour 3, which is good, but when it tries to submit the data it jsut goes to a blank screen with notihing on it....

dragon
 
function checkrequired(theForm) {

for (i=0;i<theForm.length;i++) {
var tempobj=theForm.elements;
if (((tempobj.type=="text"||tempobj.type=="textarea") &&
tempobj.value=='' && tempobj.name !='colour3'))
{
alert("Please make sure the "+tempobj.name+" field was properly completed.");

return false;
}
}
}

ok i know what the issue is but i'm going to let you fix it.
When the sumbit button is press the first thing is does is run this function (checkrequired) , if this function returns false then the sumbit action is cancelled and the form is not submitted
if this function returns true then the submit is allowed to contiune and it posts the data to the php script
The problem is that the function above returns false if the conditions of the if statement are met, but it doesn;t return true (yet) if the conditions of the if statement are not met

You need to return true in the 'else' portion if the checkrequired if statement (you also need to add the else portion as i have not done it in my code)
 
Ive been looking at it now for the past 45minutes without a clue of what to do, jsut trying to apply simple PHP syntax to it, but i dont get it, so ill just leave it and enter a space into colour3 if i want it blank
 
try this old chum
<script language='javascript'>
function checkrequired(theForm) {

for (i=0;i<theForm.length;i++) {
var tempobj=theForm.elements;
if ((((tempobj.type=="text"||tempobj.type=="textarea") &&
tempobj.value=='') && tempobj.name !='colour3'))
{
alert("Please make sure the "+tempobj.name+" field was properly completed.");

return false;
}else
{
return true;
}
}
}

</script>
 
sorry for the late reply, got caught up in something that had to be sorted. I tried that code but that doesnt work either, does the same as beofre, it doesnt prompt for colour 3 anymore, but it also doesnt submit the form, just goes to a blank page.

thanks a lot for all this help apj, dragon
 
Back
Top