FRIHOST FORUMS SEARCH FAQ TOS BLOGS COMPETITIONS
You are invited to Log in or Register a free Frihost Account!


subject javascript code please help





devroom
Hi,
Ive downloaded some contact stuff, but my form has a different subject (options).

edit: Im sorry it a lot of stuff, but didnt know any other way to show them easily Cool

Now is the problem i want to make sure people choose the subject. But i dont know how to do that. i hope some knows here.
the pages i use: here they come;

<?php include("contact/config.inc.php"); ?>
<script src="contact/validate.js"></script>
<form action="contact/send.php" name="contact" method="POST">
Hier kan je een formulier invullen waardoor je contact kan opnemen met de webmaster.
<br>Vul alle velden in
<p>
Onderwerp:<select name="subject" size="1">
<option value="0" selected="selected">- Selecteer -</option>
<option>Idee</option>
<option>Wachtwoord</option>
<option>Link</option>
<option>Anders</option>
</select>
</p>
<p>
Naam:<INPUT TYPE="text" NAME="name">
E-mail:<INPUT TYPE="text" NAME="email">
</p>
Geef commentaar:<br>
<textarea name="message" cols="50" rows="10"></textarea>
<p><INPUT TYPE="submit" VALUE="Verstuur">&nbsp;<INPUT TYPE="reset" VALUE="Wissen"></p>
</form><?php include("contact/validate.php"); ?>
devroom
other page

<script language="JavaScript" type="text/javascript">
//You should create the validator only after the definition of the HTML form
var frmvalidator = new Validator("contact");

frmvalidator.addValidation("name","req", "Error : Vul aub uw naam in");
frmvalidator.addValidation("name","maxlen=<?php echo $name['maxlen']; ?>", "Error : Uw naam is te lang \n[De maximale lengte is = <?php echo $name['maxlen']; ?>]");
frmvalidator.addValidation("name","minlen=<?php echo $name['minlen']; ?>", "Error : Uw naam is te kort, vul ook uw achternaam in \n[De minimale lengte is = <?php echo $name['minlen']; ?>]");

frmvalidator.addValidation("email","req", "Error : Vul aub uw email addres in");
frmvalidator.addValidation("email","email", "Error : Uw email addres niet geldig");

frmvalidator.addValidation("message","req", "Error : Geef aub commentaar");
frmvalidator.addValidation("message","maxlen=<?php echo $message['maxlen']; ?>", "Error : Uw commentaar is te groot \n[De maximale lengte is = <?php echo $message['maxlen']; ?>]");
frmvalidator.addValidation("message","minlen=<?php echo $message['minlen']; ?>", "Error : Uw commentaar is te klein (\n[De minimale lengte is = <?php echo $message['minlen']; ?>]");

</script>
devroom
other page


function Validator(frmname)
{
this.formobj=document.forms[frmname];
if(!this.formobj)
{
alert("BUG: couldnot get Form object "+frmname);
return;
}
if(this.formobj.onsubmit)
{
this.formobj.old_onsubmit = this.formobj.onsubmit;
this.formobj.onsubmit=null;
}
else
{
this.formobj.old_onsubmit = null;
}
this.formobj.onsubmit=form_submit_handler;
this.addValidation = add_validation;
this.setAddnlValidationFunction=set_addnl_vfunction;
this.clearAllValidations = clear_all_validations;
}
function set_addnl_vfunction(functionname)
{
this.formobj.addnlvalidation = functionname;
}
function clear_all_validations()
{
for(var itr=0;itr < this.formobj.elements.length;itr++)
{
this.formobj.elements[itr].validationset = null;
}
}
function form_submit_handler()
{
for(var itr=0;itr < this.elements.length;itr++)
{
if(this.elements[itr].validationset &&
!this.elements[itr].validationset.validate())
{
return false;
}
}
if(this.addnlvalidation)
{
str =" var ret = "+this.addnlvalidation+"()";
eval(str);
if(!ret) return ret;
}
return true;
}
function add_validation(itemname,descriptor,errstr)
{
if(!this.formobj)
{
alert("BUG: the form object is not set properly");
return;
}//if
var itemobj = this.formobj[itemname];
if(!itemobj)
{
alert("BUG: Couldnot get the input object named: "+itemname);
return;
}
if(!itemobj.validationset)
{
itemobj.validationset = new ValidationSet(itemobj);
}
itemobj.validationset.add(descriptor,errstr);
}
function ValidationDesc(inputitem,desc,error)
{
this.desc=desc;
this.error=error;
this.itemobj = inputitem;
this.validate=vdesc_validate;
}
function vdesc_validate()
{
if(!V2validateData(this.desc,this.itemobj,this.error))
{
this.itemobj.focus();
return false;
}
return true;
}
function ValidationSet(inputitem)
{
this.vSet=new Array();
this.add= add_validationdesc;
this.validate= vset_validate;
this.itemobj = inputitem;
}
function add_validationdesc(desc,error)
{
this.vSet[this.vSet.length]=
new ValidationDesc(this.itemobj,desc,error);
}
function vset_validate()
{
for(var itr=0;itr<this.vSet.length;itr++)
{
if(!this.vSet[itr].validate())
{
return false;
}
}
return true;
}
function validateEmailv2(email)
{
// a very simple email validation checking.
// you can add more complex email checking if it helps
if(email.length <= 0)
{
return true;
}
var splitted = email.match("^(.+)@(.+)$");
if(splitted == null) return false;
if(splitted[1] != null )
{
var regexp_user=/^\"?[\w-_\.]*\"?$/;
if(splitted[1].match(regexp_user) == null) return false;
}
if(splitted[2] != null)
{
var regexp_domain=/^[\w-\.]*\.[A-Za-z]{2,4}$/;
if(splitted[2].match(regexp_domain) == null)
{
var regexp_ip =/^\[\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\]$/;
if(splitted[2].match(regexp_ip) == null) return false;
}// if
return true;
}
return false;
}
function V2validateData(strValidateStr,objValue,strError)
{
var epos = strValidateStr.search("=");
var command = "";
var cmdvalue = "";
if(epos >= 0)
{
command = strValidateStr.substring(0,epos);
cmdvalue = strValidateStr.substr(epos+1);
}
else
{
command = strValidateStr;
}
switch(command)
{
case "req":
case "required":
{
if(eval(objValue.value.length) == 0)
{
if(!strError || strError.length ==0)
{
strError = objValue.name + " : Required Field";
}//if
alert(strError);
return false;
}//if
break;
}//case required

{
if(eval(objValue.value.length) > eval(cmdvalue))
{
if(!strError || strError.length ==0)
{
strError = objValue.name + " : "+cmdvalue+" characters maximum ";
}//if
alert(strError + "\n[Huidige lengte = " + objValue.value.length + " ]");
return false;
}//if
break;
}//case maxlen
case "minlength":
case "minlen":
{
if(eval(objValue.value.length) < eval(cmdvalue))
{
if(!strError || strError.length ==0)
{
strError = objValue.name + " : " + cmdvalue + " characters minimum ";
}//if
alert(strError + "\n[Huidige lengte = " + objValue.value.length + " ]");
return false;
}//if
break;
}//case minlen
case "alnum":
case "alphanumeric":
{
var charpos = objValue.value.search("[^A-Za-z0-9]");
if(objValue.value.length > 0 && charpos >= 0)
{
if(!strError || strError.length ==0)
{
strError = objValue.name+": Only alpha-numeric characters allowed ";
}//if
alert(strError + "\n [Error character position " + eval(charpos+1)+"]");
return false;
}//if
break;
}//case alphanumeric
case "num":
case "numeric":
{
var charpos = objValue.value.search("[^0-9]");
if(objValue.value.length > 0 && charpos >= 0)
{
if(!strError || strError.length ==0)
{
strError = objValue.name+": Only digits allowed ";
}//if
alert(strError + "\n [Error character position " + eval(charpos+1)+"]");
return false;
}//if
break;
}//numeric
case "alphabetic":
case "alpha":
{
var charpos = objValue.value.search("[^A-Za-z]");
if(objValue.value.length > 0 && charpos >= 0)
{
if(!strError || strError.length ==0)
{
strError = objValue.name+": Only alphabetic characters allowed ";
}//if
alert(strError + "\n [Error character position " + eval(charpos+1)+"]");
return false;
}//if
break;
}//alpha
case "alnumhyphen":
{
var charpos = objValue.value.search("[^A-Za-z0-9\-_]");
if(objValue.value.length > 0 && charpos >= 0)
{
if(!strError || strError.length ==0)
{
strError = objValue.name+": characters allowed are A-Z,a-z,0-9,- and _";
}//if
alert(strError + "\n [Error character position " + eval(charpos+1)+"]");
return false;
}//if
break;
}
case "email":
{
if(!validateEmailv2(objValue.value))
{
if(!strError || strError.length ==0)
{
strError = objValue.name+": Geef een geldig email addres";
}//if
alert(strError);
return false;
}//if
break;
}//case email
case "lt":
case "lessthan":
{
if(isNaN(objValue.value))
{
alert(objValue.name+": Should be a number ");
return false;
}//if
if(eval(objValue.value) >= eval(cmdvalue))
{
if(!strError || strError.length ==0)
{
strError = objValue.name + " : value should be less than "+ cmdvalue;
}//if
alert(strError);
return false;
}//if
break;
}//case lessthan
case "gt":
case "greaterthan":
{
if(isNaN(objValue.value))
{
alert(objValue.name+": Should be a number ");
return false;
}//if
if(eval(objValue.value) <= eval(cmdvalue))
{
if(!strError || strError.length ==0)
{
strError = objValue.name + " : value should be greater than "+ cmdvalue;
}//if
alert(strError);
return false;
}//if
break;
}//case greaterthan
case "regexp":
{
if(objValue.value.length > 0)
{
if(!objValue.value.match(cmdvalue))
{
if(!strError || strError.length ==0)
{
strError = objValue.name+": Invalid characters found ";
}//if
alert(strError);
return false;
}//if
}
break;
}//case regexp
case "dontselect":
{
if(objValue.selectedIndex == null)
{
alert("BUG: dontselect command for non-select Item");
return false;
}
if(objValue.selectedIndex == eval(cmdvalue))
{
if(!strError || strError.length ==0)
{
strError = objValue.name+": Please Select one option ";
}//if
alert(strError);
return false;
}
break;
}//case dontselect
}//switch
return true;
}
/*
Copyright 2003 JavaScript-coder.com. All rights reserved.
*/
devroom
this is only a part

// Name
$name['maxlen'] = "30"; // Maximum Length
$name['minlen'] = "5"; // Minimum Length


// Message
$message['maxlen'] = "300"; // Maximum Length
$message['minlen'] = "20"; // Minimum Length

//
// Error/Done Pages
//

$donepage = "done.php"; // Thank You/Done page
$errorpage = "error.php"; // Banned IP/Email Page.

?>
devroom
and the last 1

<?php
include("config.inc.php");

$ip = $_SERVER['REMOTE_ADDR'] ;
$date = date("l jS F Y");
$time = date("H:i");
$name = $_REQUEST['name'] ;
$email = $_REQUEST['email'] ;
$subject = $_REQUEST['subject'] ;
$message_get = $_REQUEST['message'] ;

$message = "Hi $sitename,

$name has sent you an email at $time on $date. The message is below including his/her IP address and email address:

ip: $ip

name : $name
email : $email
subject : $subject
message : $message_get

Thanks,

Your Trustworthy MailBot

-----------------------
Powered by MPmailForm 2
http://mpnetwork.co.uk";

if($logs == "1") {
$log = "$date, $time, $ip, $name, $email, $subject, $message_get\r";

// Open the file and erase the contents if any
$fp = fopen("$logsfile", "a");
// Write the data to the file
$log = str_replace("\n", "", $log);
fwrite($fp, $log);
// Close the file
fclose($fp);
}


if($banip == "1") {
if(strstr($banip_list, $ip)) {
echo "<META http-equiv=\"refresh\" content=\"0; URL=$errorpage\">";
}
}
if($banemail == "1") {
if(strstr($banemail_list, $email)) {
echo "<META http-equiv=\"refresh\" content=\"0; URL=$errorpage\">";
}
}

if($autoresponder == "1") {
$autorespond_headers = "From: $sitename($address)";
@mail($email, $autorespondersub, $autorespondermess, $autorespond_headers);
}

@mail( "$address", "$subject", "$message", "From: $email");


echo "<META http-equiv=\"refresh\" content=\"0; URL=$donepage\">";
?>
Related topics
simple php problem, please help...
A good website idea.........Please help PPL
Please help Me
phpBB2 ERROR PLEASE HELP
Please help me!!!! HTML/Flash help needed!
Problem with MySQL Server Please Help!!
Help needed about this contact CGI file
THIS IS DRIVING ME INSANE!! PLEASE HELP!
Please help regarding editing of index file
Anyone please help me!
what is wrong with this query? Please please help!
Help! This small script has logical problems. Please help
Please help about this..
Help Pleasee, My Submit form dont submit on google chrome
Reply to topic    Frihost Forum Index -> Support and Web Hosting -> Web Hosting Support

FRIHOST HOME | FAQ | TOS | ABOUT US | CONTACT US | SITE MAP
© 2005-2011 Frihost, forums powered by phpBB.