SitePoint Sponsor

User Tag List

Results 1 to 17 of 17
  1. #1
    I LOVE THIS SITE ! ! ! DougD's Avatar
    Join Date
    May 2000
    Location
    San Diego, CA
    Posts
    463
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi,

    Go to: http://www.dotdealers.com/quote.php

    I am creating this form for a friend. It's an all-in-one script that give you errors if you do not fill in the required fields. It works great except for one thing. If someone forgets to enter something, the 3 drop-down menus revert to the default "Please Select". Everything else is saved but those 3 menus... Anybody know how to make them save the info?

    Thanks,

    Doug

    Script below as well...

    <?

    $form_block = "
    <FORM METHOD=\"post\" ACTION=\"$PHP_SELF\">
    <TABLE WIDTH=500>

    <TR BGCOLOR=BLUE><TD ALIGN=CENTER COLSPAN=2>
    <FONT SIZE=+1 COLOR=WHITE>
    <B>OLIGO INFORMATION</B>

    <TR><TD VALIGN=CENTER ALIGN=RIGHT>

    <TR><TD VALIGN=CENTER ALIGN=RIGHT><B>Number of Oligos/B>
    <TD VALIGN=CENTER ALIGN=LEFT>
    <INPUT type=\"text\" NAME=\"oligino\" VALUE=\"$oligino\" SIZE=10>

    <TR><TD VALIGN=CENTER ALIGN=RIGHT><B>Number of Bases/B>
    <TD VALIGN=CENTER ALIGN=LEFT>
    <INPUT type=\"text\" NAME=\"baseno\" VALUE=\"$baseno\" SIZE=10>

    <TR><TD VALIGN=TOP ALIGN=RIGHT><B>Modifications or Labels/B>
    <TD VALIGN=CENTER ALIGN=LEFT>
    <TEXTAREA NAME=\"mods\" COLS=30 ROWS=6 WRAP=virtual>$mods</TEXTAREA>
    </TD></TR>

    <TR><TD VALIGN=CENTER ALIGN=RIGHT>
    <B>Backbone/B></FONT></TD>
    <TD VALIGN=CENTER ALIGN=LEFT>
    <select name=\"backbone\">$backbone<option value=\"none\">Please Select&nbsp;&nbsp;</option>
    <option value=\"DNA\">DNA</option>
    <option value=\"RNA\">RNA</option>
    </SELECT>
    </TD></TR>

    <TR><TD VALIGN=CENTER ALIGN=RIGHT>
    <B>Scale (uMol)/B></FONT></TD>
    <TD VALIGN=CENTER ALIGN=LEFT>
    <select name=\"scale\">$scale<option value=\"none\">Please Select&nbsp;&nbsp;</option>
    <option value=\"0.05\">&nbsp;0.05</option>
    <option value=\"0.20\">&nbsp;0.20</option>
    <option value=\"1.00\">&nbsp;1.00</option>
    <option value=\"10.00\">&nbsp;10.00</option>
    <option value=\"100.00\">&nbsp;100.00</option>
    </SELECT>
    </TD></TR>


    <TR><TD VALIGN=CENTER ALIGN=RIGHT>
    <B> Purification/B></FONT></TD>
    <TD VALIGN=CENTER ALIGN=LEFT>
    <select name=\"purification\">$purification<option value=\"none\">Please Select&nbsp;&nbsp;</option>
    <option value=\"Desalt\">&nbsp;De-salt</option>
    <option value=\"HPLC\">&nbsp;HPLC</option>
    <option value=\"PAGE\">&nbsp;PAGE</option>
    <option value=\"OPCCART\">&nbsp;OPC Cart</option>
    </SELECT>
    <BR><BR>
    </TD></TR>

    <TR><TD VALIGN=TOP ALIGN=CENTER COLSPAN=2><B>Please Include Any Additional
    Information Below/B><BR>
    <TEXTAREA NAME=\"other\" COLS=60 ROWS=6 WRAP=virtual>$other</TEXTAREA>
    </TD></TR>
    </TABLE><BR><BR>

    <TABLE WIDTH=500>

    <TR BGCOLOR=BLUE><TD COLSPAN=2 ALIGN=CENTER>
    <FONT SIZE=+1 COLOR=WHITE>
    <B>YOUR INFORMATION/B>

    <TR>
    <TD VALIGN=CENTER ALIGN=RIGHT><B>Name/FONT>
    <TD VALIGN=CENTER ALIGN=LEFT>
    <INPUT type=\"text\" NAME=\"sender_name\" VALUE=\"$sender_name\" SIZE=40>
    <TR>
    <TD VALIGN=CENTER ALIGN=RIGHT><B>Institution/FONT>
    <TD VALIGN=CENTER ALIGN=LEFT>
    <INPUT type=\"text\" NAME=\"sender_iname\" VALUE=\"$sender_iname\" SIZE=40>

    <TR>
    <TD VALIGN=CENTER ALIGN=RIGHT><B>Department/FONT>
    <TD VALIGN=CENTER ALIGN=LEFT>
    <INPUT type=\"text\" NAME=\"sender_dname\" VALUE=\"$sender_dname\" SIZE=40>


    <TR>
    <TD ALIGN=RIGHT VALIGN=MIDDLE><B>Address/FONT>
    <TD VALIGN=CENTER ALIGN=LEFT>
    <TEXTAREA NAME=\"address\" COLS=36 ROWS=2>$address</TEXTAREA>

    <TR>
    <TD VALIGN=CENTER ALIGN=RIGHT><B>Phone/FONT>
    <TD VALIGN=CENTER ALIGN=LEFT>
    <INPUT type=\"text\" NAME=\"sender_phone\" VALUE=\"$sender_phone\" SIZE=40>

    <TR>
    <TD VALIGN=CENTER ALIGN=RIGHT><B>E-Mail/FONT>
    <TD VALIGN=CENTER ALIGN=LEFT>
    <INPUT type=\"text\" NAME=\"sender_email\" VALUE=\"$sender_email\" SIZE=40>

    <TR>
    <TD VALIGN=CENTER ALIGN=CENTER colspan=\"2\">
    <B>How did you find about Synthetic Genetics?</FONT><br>
    <INPUT type=\"text\" NAME=\"referral\" VALUE=\"$referral\" SIZE=40>

    </TABLE>


    <TABLE WIDTH=500>
    <TR><TD ALIGN=CENTER>
    <TABLE>
    <TR><TD ALIGN=CENTER VALIGN=TOP>



    <INPUT type=\"hidden\" name=\"op\" value=\"ds\">

    <p><INPUT TYPE=\"submit\" NAME=\"submit\" VALUE=\"Submit Quote Request\">&nbsp;<input type=\"reset\" value=\"Clear Request\"></p>

    </TABLE>
    <tr>
    <td align=\"left\" valign=\"middle\">
    ";

    if ($op != "ds") {

    // they need to see the form
    echo "$form_block";

    } else if ($op == "ds") {

    if ($oligino == "") {
    $oligino_err = "<font face=verdana,arial,helvetica size=-1 color=red><b>Please enter Number of Oligos!</b></font><br>";
    $send = "no";
    }

    if ($baseno == "") {
    $baseno_err = "<font face=verdana,arial,helvetica size=-1 color=red><b>Please enter Number of Bases!</b></font><br>";
    $send = "no";
    }

    if ($backbone == "none") {
    $backbone_err = "<font face=verdana,arial,helvetica size=-1 color=red><b>Please select Backbone!</b></font><br>";
    $send = "no";
    }

    if ($scale == "none") {
    $scale_err = "<font face=verdana,arial,helvetica size=-1 color=red><b>Please select Scale!</b></font><br>";
    $send = "no";
    }

    if ($purification == "none") {
    $purification_err = "<font face=verdana,arial,helvetica size=-1 color=red><b>Please select Purification!</b></font><br>";
    $send = "no";
    }

    if ($sender_name == "") {
    $name_err = "<font face=verdana,arial,helvetica size=-1 color=red><b>Please enter your Name!</b></font><br>";
    $send = "no";
    }

    if ($sender_iname == "") {
    $iname_err = "<font face=verdana,arial,helvetica size=-1 color=red><b>Please enter your Instuitution!</b></font><br>";
    $send = "no";
    }

    if ($sender_dname == "") {
    $dname_err = "<font face=verdana,arial,helvetica size=-1 color=red><b>Please enter your Department!</b></font><br>";
    $send = "no";
    }

    if ($address == "") {
    $address_err = "<font face=verdana,arial,helvetica size=-1 color=red><b>Please enter your Address!</b></font><br>";
    $send = "no";
    }

    if ($sender_phone == "") {
    $phone_err = "<font face=verdana,arial,helvetica size=-1 color=red><b>Please enter your Phone Number!</b></font><br>";
    $send = "no";
    }

    if ($sender_email == "") {
    $email_err = "<font face=verdana,arial,helvetica size=-1 color=red><b>Please enter your Email Address!</b></font><br>";
    $send = "no";
    }

    if ($send != "no") {

    // it's ok to send!
    $msg = "(Oligo Synthesis Quote Request)\n\n\n";
    $msg .= "Number of Oligos: $oligino\n";
    $msg .= "Number of Bases: $baseno\n";
    $msg .= "Label - Modification: $mods\n";
    $msg .= "Backbone: $backbone\n";
    $msg .= "Scale: $scale\n";
    $msg .= "Purification: $purification\n";
    $msg .= "Additional Info: $other\n\n";
    $msg .= "Name: $sender_name\n";
    $msg .= "Institution: $sender_iname\n";
    $msg .= "Department: $sender_dname\n";
    $msg .= "Address: $address\n";
    $msg .= "Phone: $sender_phone\n";
    $msg .= "Email: $sender_email\n\n";
    $msg .= "Referred by: $referral\n";


    $to = "howsthis@dotdealers.com";
    $subject = "Please Send Me Oligo Synthesis Quote";
    $mailheaders = "From: Synthetic Genetics Web Site <quote@syntheticgenetics.com> \n";
    $mailheaders .= "Reply-To: $sender_email\n\n";

    mail($to, $subject, $msg, $mailheaders);

    echo "
    <table width=\"90%\" valign=\"top\">
    <tr>
    <td height=\"100%\" valign=\"top\" align=\"center\">
    <P><font face=verdana,arial,helvetica size=4 color=blue><br><b>Thank you for your request</b>.</font><p>
    Your request has been submitted to Synthetic Genetics and will be processed immediately.</font>
    </td>
    </tr>
    <tr>
    <td align=\"center\"><img src=\"sygelogo.jpg\" width=84 height=51 border=0></td>
    </tr>
    ";

    } else if ($send == "no") {
    echo "<br><font size=\"+1\"><b>The following fields have been missed...</b><p></font>";
    echo "$oligino_err";
    echo "$baseno_err";
    echo "$backbone_err";
    echo "$scale_err";
    echo "$purification_err";
    echo "$fname_err";
    echo "$name_err";
    echo "$iname_err";
    echo "$dname_err";
    echo "$address_err";
    echo "$phone_err";
    echo "$email_err";
    echo "$form_block";

    }

    }

    ?>

  2. #2
    SitePoint Zealot HotDog's Avatar
    Join Date
    May 2000
    Location
    Salt Lake City, UT
    Posts
    108
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    The best way that I know of is to put all our drop down options in a their own lookup table instead of hard coding them into the form. Setup the lookup table with 2 columns, the option value and the option name. Then setup your code in the form to query the table and write out the code for the drop down menu.

    Code:
    <?php
    $backBone = $backbone
    $result=mysql_query("SELECT * FROM lookupTable");
    	print("<select name=backbone> \n");
    	print("<option>Please Select\n");
    	while ($row = mysql_fetch_array($result)) {
    		$backboneID[] = $row["backboneID"];
    		$backboneName = $row["backboneName"];
    		while (list($key, $val) = each ($backboneID)) {
    			if ($val==$backBone) {
    				printf("<option value='%s' selected>%s \n", $val, $backboneName );
    			}
    			else {
    				printf("<option value='%s'>%s \n", $val, $backboneName );
    			} 
    			
    		}
    	} 
    	print("</select>\n");
    
    ?>
    Then you need to give $backBone the value of the input field of backbone when it repassed to the page. This will then hold the value of the drop down field from the previous page and when the $val value matches the $backBone value it will write the option as selected.

    You will need to work with it a little to make it work, but give it a try.
    Joe Eliason
    Just a dog learnin' PHP from cat.

  3. #3
    SitePoint Addict
    Join Date
    Dec 2000
    Location
    BOSTON MA
    Posts
    335
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    i had to deal with this same exact issue a little while ago. i'm not saying HotDog's way isn't good, but this is how i did:

    take this line for example :

    <select name=\"backbone\">$backbone<option value=\"none\">Please Select </option>

    <option value=\"DNA\">DNA</option>
    <option value=\"RNA\">RNA</option>

    </SELECT>
    i would put in a variable right after " value= " like this:

    <select name=\"backbone\">$backbone<option value=\"none\">Please Select </option>

    <option value=\"DNA\" $backbone_1 >DNA</option>
    <option value=\"RNA\" $backbone_2>RNA</option>

    </SELECT>
    then you're going to have the following code somewhere near the top of your page : (i personally have it all in an include file right after the connection info at the top of my script)

    if($backbone== "DNA") {

    $backbone_1 = "selected";
    $backbone_2 = "";

    } elseif ($backbone == "RNA") {

    $backbone_1 = "";
    $backbone_1 = "selected";
    }
    what that's going to do is replace either $backbone_1 or $backbone_2 (depending on what was selected) with the word "selected" which will obviously make the option selected should there be an error in the form and you need to carry the info over.

    does that make sense? i hope so. if it doesn't please let me know because i know this will work.

    so now, you need to write the if else statement for the other select boxes and you're done.
    . . . chris

  4. #4
    Dumb PHP codin' cat
    Join Date
    Aug 2000
    Location
    San Diego, CA
    Posts
    5,460
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    In my opinion the best thing to do here is to make arrays out of the dropdown listrs unless the values are stored in a db already then use HotDog's advice, if not do this:
    (I bascially redid parts of the $form_block chunk and added some stuff above it.

    PHP Code:
    <?


    $backbonel 
    = array("none" => "Please Select",
                      
    "DNA" => "DNA",
                      
    "RNA" => "RNA"
                      
    );
    $scalesl = array("none" => "Please Select",
                      
    "0.05" => "0.05",
                      
    "0.20" => "0.20",
                      
    "1.00" => "1.00",
                      
    "10.00" => "10.00",
                      
    "100.00" => "100.00"
                      
    );
    $purifyl = array("none" => "Please Select",
                      
    "Desalt" => "De-Salt",
                      
    "HPLC" => "HPLC",
                      
    "PAGE" => "PAGE",
                      
    "OPCCART" => "OPCCART"
                      
    );
                      
    $sel1 .= '<select name="backbone">';
    foreach(
    $backbonel as $key => $val) {
        
    $sel1 .= sprintf('<option value="%s" %s>%s%s'$key, ($backbone == $key) ? "selected" ""$backbonel[$key], "\n");
        }
    $sel1 .= '</SELECT>';

    $sel2 .= '<select name="scale">';
    foreach(
    $scalesl as $key => $val) {
        
    $sel2 .= sprintf('<option value="%s" %s>%s%s'$key, ($scale== $key) ? "selected" ""$scalesl[$key], "\n");
        }
    $sel2 .= '</SELECT>';

    $sel3 .= '<select name="purification">';
    foreach(
    $purifyl as $key => $val) {
        
    $sel3 .= sprintf('<option value="%s" %s>%s%s'$key, ($purification == $key) ? "selected" ""$purifyl[$key], "\n");
        }
    $sel3 .= '</SELECT>';




    $form_block 
    <FORM METHOD=\"post\" ACTION=\"
    $PHP_SELF\"> 
    <TABLE WIDTH=500> 

    <TR BGCOLOR=BLUE><TD ALIGN=CENTER COLSPAN=2> 
    <FONT SIZE=+1 COLOR=WHITE> 
    <B>OLIGO INFORMATION</B> 

    <TR><TD VALIGN=CENTER ALIGN=RIGHT> 

    <TR><TD VALIGN=CENTER ALIGN=RIGHT><B>Number of Oligos:</B> 
    <TD VALIGN=CENTER ALIGN=LEFT> 
    <INPUT type=\"text\" NAME=\"oligino\" VALUE=\"
    $oligino\" SIZE=10> 

    <TR><TD VALIGN=CENTER ALIGN=RIGHT><B>Number of Bases:</B> 
    <TD VALIGN=CENTER ALIGN=LEFT> 
    <INPUT type=\"text\" NAME=\"baseno\" VALUE=\"
    $baseno\" SIZE=10> 

    <TR><TD VALIGN=TOP ALIGN=RIGHT><B>Modifications or Labels:</B> 
    <TD VALIGN=CENTER ALIGN=LEFT> 
    <TEXTAREA NAME=\"mods\" COLS=30 ROWS=6 WRAP=virtual>
    $mods</TEXTAREA> 
    </TD></TR> 

    <TR><TD VALIGN=CENTER ALIGN=RIGHT> 
    <B>Backbone:</B></FONT></TD> 
    <TD VALIGN=CENTER ALIGN=LEFT> 
    $sel1
    </TD></TR> 

    <TR><TD VALIGN=CENTER ALIGN=RIGHT> 
    <B>Scale (uMol):</B></FONT></TD> 
    <TD VALIGN=CENTER ALIGN=LEFT> 
    $sel2
    </TD></TR> 


    <TR><TD VALIGN=CENTER ALIGN=RIGHT> 
    <B> Purification:</B></FONT></TD> 
    <TD VALIGN=CENTER ALIGN=LEFT> 
    $sel3
    <BR><BR> 
    </TD></TR> 

    <TR><TD VALIGN=TOP ALIGN=CENTER COLSPAN=2><B>Please Include Any Additional 
    Information Below:</B><BR> 
    <TEXTAREA NAME=\"other\" COLS=60 ROWS=6 WRAP=virtual>
    $other</TEXTAREA> 
    </TD></TR> 
    </TABLE><BR><BR> 

    <TABLE WIDTH=500> 

    <TR BGCOLOR=BLUE><TD COLSPAN=2 ALIGN=CENTER> 
    <FONT SIZE=+1 COLOR=WHITE> 
    <B>YOUR INFORMATION:</B> 

    <TR> 
    <TD VALIGN=CENTER ALIGN=RIGHT><B>Name:</FONT> 
    <TD VALIGN=CENTER ALIGN=LEFT> 
    <INPUT type=\"text\" NAME=\"sender_name\" VALUE=\"
    $sender_name\" SIZE=40> 
    <TR> 
    <TD VALIGN=CENTER ALIGN=RIGHT><B>Institution:</FONT> 
    <TD VALIGN=CENTER ALIGN=LEFT> 
    <INPUT type=\"text\" NAME=\"sender_iname\" VALUE=\"
    $sender_iname\" SIZE=40> 

    <TR> 
    <TD VALIGN=CENTER ALIGN=RIGHT><B>Department:</FONT> 
    <TD VALIGN=CENTER ALIGN=LEFT> 
    <INPUT type=\"text\" NAME=\"sender_dname\" VALUE=\"
    $sender_dname\" SIZE=40> 


    <TR> 
    <TD ALIGN=RIGHT VALIGN=MIDDLE><B>Address:</FONT> 
    <TD VALIGN=CENTER ALIGN=LEFT> 
    <TEXTAREA NAME=\"address\" COLS=36 ROWS=2>
    $address</TEXTAREA> 

    <TR> 
    <TD VALIGN=CENTER ALIGN=RIGHT><B>Phone:</FONT> 
    <TD VALIGN=CENTER ALIGN=LEFT> 
    <INPUT type=\"text\" NAME=\"sender_phone\" VALUE=\"
    $sender_phone\" SIZE=40> 

    <TR> 
    <TD VALIGN=CENTER ALIGN=RIGHT><B>E-Mail:</FONT> 
    <TD VALIGN=CENTER ALIGN=LEFT> 
    <INPUT type=\"text\" NAME=\"sender_email\" VALUE=\"
    $sender_email\" SIZE=40> 

    <TR> 
    <TD VALIGN=CENTER ALIGN=CENTER colspan=\"2\"> 
    <B>How did you find about Synthetic Genetics?</FONT><br> 
    <INPUT type=\"text\" NAME=\"referral\" VALUE=\"
    $referral\" SIZE=40> 

    </TABLE> 


    <TABLE WIDTH=500> 
    <TR><TD ALIGN=CENTER> 
    <TABLE> 
    <TR><TD ALIGN=CENTER VALIGN=TOP> 



    <INPUT type=\"hidden\" name=\"op\" value=\"ds\"> 

    <p><INPUT TYPE=\"submit\" NAME=\"submit\" VALUE=\"Submit Quote Request\"> <input type=\"reset\" value=\"Clear Request\"></p> 

    </TABLE> 
    <tr> 
    <td align=\"left\" valign=\"middle\"> 
    "


    ?>
    Please don't PM me with questions.
    Use the forums, that is what they are here for.

  5. #5
    SitePoint Addict
    Join Date
    Dec 2000
    Location
    BOSTON MA
    Posts
    335
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    freddy knows best but i had couple of minutes so you get this. your script + my post and voila :

    <?

    ///////////////////////////////////////////////////////////////////////////////////////////////////////
    //THE IF-ELSE STATEMENTS START HERE
    //WITH BACKBONE
    ///////////////////////////////////////////////////////////////////////////////////////////////////////

    if($backbone== "DNA") {
    $backbone_1 = "selected";
    $backbone_2 = "";
    } elseif ($backbone == "RNA") {
    $backbone_1 = "";
    $backbone_1 = "selected";
    }


    //SCALE

    if($scale== "0.05") {
    $scale_1 = "selected";
    $scale_2 = "";
    $scale_3 = "";
    $scale_4 = "";
    $scale_5 = "";
    } elseif ($scale == "0.20") {
    $scale_1 = "";
    $scale_2 = "selected";
    $scale_3 = "";
    $scale_4 = "";
    $scale_5 = "";
    } elseif ($scale == "1.00") {
    $scale_1 = "";
    $scale_2 = "";
    $scale_3 = "selected";
    $scale_4 = "";
    $scale_5 = "";
    } elseif ($scale == "10.00") {
    $scale_1 = "";
    $scale_2 = "";
    $scale_3 = "";
    $scale_4 = "selected";
    $scale_5 = "";
    } elseif ($scale == "100.00") {
    $scale_1 = "";
    $scale_2 = "";
    $scale_3 = "";
    $scale_4 = "";
    $scale_5 = "selected";
    }


    //PURIFICATION

    if($purification== "Desalt") {
    $pure_1 = "selected";
    $pure_2 = "";
    $pure_3 = "";
    $pure_4 = "";
    } elseif ($purification == "HPLC") {
    $pure_1 = "";
    $pure_2 = "selected";
    $pure_3 = "";
    $pure_4 = "";
    } elseif ($purification == "PAGE") {
    $pure_1 = "";
    $pure_2 = "";
    $pure_3 = "selected";
    $pure_4 = "";
    } elseif ($purification == "OPCCART") {
    $pure_1 = "";
    $pure_2 = "";
    $pure_3 = "";
    $pure_4 = "selected";
    }

    //////////////////////////////////////////////////////////////////////////////////////////////////////////////
    //////////////////////////////////////////////////////////////////////////////////////////////////////////////
    $form_block = "
    <FORM METHOD=\"post\" ACTION=\"$PHP_SELF\">
    <TABLE WIDTH=500>

    <TR BGCOLOR=BLUE><TD ALIGN=CENTER COLSPAN=2>
    <FONT SIZE=+1 COLOR=WHITE>
    <B>OLIGO INFORMATION</B>

    <TR><TD VALIGN=CENTER ALIGN=RIGHT>

    <TR><TD VALIGN=CENTER ALIGN=RIGHT><B>Number of Oligos/B>
    <TD VALIGN=CENTER ALIGN=LEFT>
    <INPUT type=\"text\" NAME=\"oligino\" VALUE=\"$oligino\" SIZE=10>

    <TR><TD VALIGN=CENTER ALIGN=RIGHT><B>Number of Bases/B>
    <TD VALIGN=CENTER ALIGN=LEFT>
    <INPUT type=\"text\" NAME=\"baseno\" VALUE=\"$baseno\" SIZE=10>

    <TR><TD VALIGN=TOP ALIGN=RIGHT><B>Modifications or Labels/B>
    <TD VALIGN=CENTER ALIGN=LEFT>
    <TEXTAREA NAME=\"mods\" COLS=30 ROWS=6 WRAP=virtual>$mods</TEXTAREA>
    </TD></TR>

    <TR><TD VALIGN=CENTER ALIGN=RIGHT>
    <B>Backbone/B></FONT></TD>
    <TD VALIGN=CENTER ALIGN=LEFT>
    <select name=\"backbone\">$backbone<option value=\"none\">Please Select </option>
    <option value=\"DNA\" $backbone_1 >DNA</option>
    <option value=\"RNA\" $backbone_2 >RNA</option>
    </SELECT>
    </TD></TR>

    <TR><TD VALIGN=CENTER ALIGN=RIGHT>
    <B>Scale (uMol)/B></FONT></TD>
    <TD VALIGN=CENTER ALIGN=LEFT>
    <select name=\"scale\">$scale<option value=\"none\">Please Select </option>
    <option value=\"0.05\" $scale_1 > 0.05</option>
    <option value=\"0.20\" $scale_2 > 0.20</option>
    <option value=\"1.00\" $scale_3> 1.00</option>
    <option value=\"10.00\" $scale_4> 10.00</option>
    <option value=\"100.00\" $scale_5> 100.00</option>
    </SELECT>
    </TD></TR>


    <TR><TD VALIGN=CENTER ALIGN=RIGHT>
    <B> Purification/B></FONT></TD>
    <TD VALIGN=CENTER ALIGN=LEFT>
    <select name=\"purification\">$purification<option value=\"none\">Please Select </option>
    <option value=\"Desalt\" $pure_1 > De-salt</option>
    <option value=\"HPLC\" $pure_2 > HPLC</option>
    <option value=\"PAGE\" $pure_3 > PAGE</option>
    <option value=\"OPCCART\" $pure_4 > OPC Cart</option>
    </SELECT>
    <BR><BR>
    </TD></TR>

    <TR><TD VALIGN=TOP ALIGN=CENTER COLSPAN=2><B>Please Include Any Additional
    Information Below/B><BR>
    <TEXTAREA NAME=\"other\" COLS=60 ROWS=6 WRAP=virtual>$other</TEXTAREA>
    </TD></TR>
    </TABLE><BR><BR>

    <TABLE WIDTH=500>

    <TR BGCOLOR=BLUE><TD COLSPAN=2 ALIGN=CENTER>
    <FONT SIZE=+1 COLOR=WHITE>
    <B>YOUR INFORMATION/B>

    <TR>
    <TD VALIGN=CENTER ALIGN=RIGHT><B>Name/FONT>
    <TD VALIGN=CENTER ALIGN=LEFT>
    <INPUT type=\"text\" NAME=\"sender_name\" VALUE=\"$sender_name\" SIZE=40>
    <TR>
    <TD VALIGN=CENTER ALIGN=RIGHT><B>Institution/FONT>
    <TD VALIGN=CENTER ALIGN=LEFT>
    <INPUT type=\"text\" NAME=\"sender_iname\" VALUE=\"$sender_iname\" SIZE=40>

    <TR>
    <TD VALIGN=CENTER ALIGN=RIGHT><B>Department/FONT>
    <TD VALIGN=CENTER ALIGN=LEFT>
    <INPUT type=\"text\" NAME=\"sender_dname\" VALUE=\"$sender_dname\" SIZE=40>


    <TR>
    <TD ALIGN=RIGHT VALIGN=MIDDLE><B>Address/FONT>
    <TD VALIGN=CENTER ALIGN=LEFT>
    <TEXTAREA NAME=\"address\" COLS=36 ROWS=2>$address</TEXTAREA>

    <TR>
    <TD VALIGN=CENTER ALIGN=RIGHT><B>Phone/FONT>
    <TD VALIGN=CENTER ALIGN=LEFT>
    <INPUT type=\"text\" NAME=\"sender_phone\" VALUE=\"$sender_phone\" SIZE=40>

    <TR>
    <TD VALIGN=CENTER ALIGN=RIGHT><B>E-Mail/FONT>
    <TD VALIGN=CENTER ALIGN=LEFT>
    <INPUT type=\"text\" NAME=\"sender_email\" VALUE=\"$sender_email\" SIZE=40>

    <TR>
    <TD VALIGN=CENTER ALIGN=CENTER colspan=\"2\">
    <B>How did you find about Synthetic Genetics?</FONT><br>
    <INPUT type=\"text\" NAME=\"referral\" VALUE=\"$referral\" SIZE=40>

    </TABLE>


    <TABLE WIDTH=500>
    <TR><TD ALIGN=CENTER>
    <TABLE>
    <TR><TD ALIGN=CENTER VALIGN=TOP>



    <INPUT type=\"hidden\" name=\"op\" value=\"ds\">

    <p><INPUT TYPE=\"submit\" NAME=\"submit\" VALUE=\"Submit Quote Request\"> <input type=\"reset\" value=\"Clear Request\"></p>

    </TABLE>
    <tr>
    <td align=\"left\" valign=\"middle\">
    ";

    if ($op != "ds") {

    // they need to see the form
    echo "$form_block";

    } else if ($op == "ds") {

    if ($oligino == "") {
    $oligino_err = "<font face=verdana,arial,helvetica size=-1 color=red><b>Please enter Number of Oligos!</b></font><br>";
    $send = "no";
    }

    if ($baseno == "") {
    $baseno_err = "<font face=verdana,arial,helvetica size=-1 color=red><b>Please enter Number of Bases!</b></font><br>";
    $send = "no";
    }

    if ($backbone == "none") {
    $backbone_err = "<font face=verdana,arial,helvetica size=-1 color=red><b>Please select Backbone!</b></font><br>";
    $send = "no";
    }

    if ($scale == "none") {
    $scale_err = "<font face=verdana,arial,helvetica size=-1 color=red><b>Please select Scale!</b></font><br>";
    $send = "no";
    }

    if ($purification == "none") {
    $purification_err = "<font face=verdana,arial,helvetica size=-1 color=red><b>Please select Purification!</b></font><br>";
    $send = "no";
    }

    if ($sender_name == "") {
    $name_err = "<font face=verdana,arial,helvetica size=-1 color=red><b>Please enter your Name!</b></font><br>";
    $send = "no";
    }

    if ($sender_iname == "") {
    $iname_err = "<font face=verdana,arial,helvetica size=-1 color=red><b>Please enter your Instuitution!</b></font><br>";
    $send = "no";
    }

    if ($sender_dname == "") {
    $dname_err = "<font face=verdana,arial,helvetica size=-1 color=red><b>Please enter your Department!</b></font><br>";
    $send = "no";
    }

    if ($address == "") {
    $address_err = "<font face=verdana,arial,helvetica size=-1 color=red><b>Please enter your Address!</b></font><br>";
    $send = "no";
    }

    if ($sender_phone == "") {
    $phone_err = "<font face=verdana,arial,helvetica size=-1 color=red><b>Please enter your Phone Number!</b></font><br>";
    $send = "no";
    }

    if ($sender_email == "") {
    $email_err = "<font face=verdana,arial,helvetica size=-1 color=red><b>Please enter your Email Address!</b></font><br>";
    $send = "no";
    }

    if ($send != "no") {

    // it's ok to send!
    $msg = "(Oligo Synthesis Quote Request)\n\n\n";
    $msg .= "Number of Oligos: $oligino\n";
    $msg .= "Number of Bases: $baseno\n";
    $msg .= "Label - Modification: $mods\n";
    $msg .= "Backbone: $backbone\n";
    $msg .= "Scale: $scale\n";
    $msg .= "Purification: $purification\n";
    $msg .= "Additional Info: $other\n\n";
    $msg .= "Name: $sender_name\n";
    $msg .= "Institution: $sender_iname\n";
    $msg .= "Department: $sender_dname\n";
    $msg .= "Address: $address\n";
    $msg .= "Phone: $sender_phone\n";
    $msg .= "Email: $sender_email\n\n";
    $msg .= "Referred by: $referral\n";


    $to = "howsthis@dotdealers.com";
    $subject = "Please Send Me Oligo Synthesis Quote";
    $mailheaders = "From: Synthetic Genetics Web Site <quote@syntheticgenetics.com> \n";
    $mailheaders .= "Reply-To: $sender_email\n\n";

    mail($to, $subject, $msg, $mailheaders);

    echo "
    <table width=\"90%\" valign=\"top\">
    <tr>
    <td height=\"100%\" valign=\"top\" align=\"center\">
    <P><font face=verdana,arial,helvetica size=4 color=blue><br><b>Thank you for your request</b>.</font><p>
    Your request has been submitted to Synthetic Genetics and will be processed immediately.</font>
    </td>
    </tr>
    <tr>
    <td align=\"center\"><img src=\"sygelogo.jpg\" width=84 height=51 border=0></td>
    </tr>
    ";

    } else if ($send == "no") {
    echo "<br><font size=\"+1\"><b>The following fields have been missed...</b><p></font>";
    echo "$oligino_err";
    echo "$baseno_err";
    echo "$backbone_err";
    echo "$scale_err";
    echo "$purification_err";
    echo "$fname_err";
    echo "$name_err";
    echo "$iname_err";
    echo "$dname_err";
    echo "$address_err";
    echo "$phone_err";
    echo "$email_err";
    echo "$form_block";

    }

    }

    ?>
    i didn't test it so you might want to look it over real quick just to make sure. and if it's a bad solution then i'm sure someone will let me know
    . . . chris

  6. #6
    I LOVE THIS SITE ! ! ! DougD's Avatar
    Join Date
    May 2000
    Location
    San Diego, CA
    Posts
    463
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hey Guys... You are all AWESOME! I totally appreciate the thought and TIME you took to help me out. I actually learned a lot of stuff from each of you! The PHP stuff is great.

    Chris thanks for making the entire script... It works perfectly. I had some start and ending tags in the wrong place so the thank-you page was going to have to be redone... Not anymore (Thanks)

    Again thank you all.

    One more question if you don't mind. I have one other page I need to redo. It is very similar to that page. It is a request form for literature. It has the general contact info stuff, which I know how to do. But it also has 2 check boxes so they can order "Informational Literature" and/or Pricing Literature".

    I cannot figure out how to get it to create an error message saying "Please select at least one type of Literature!"

    I am not sure what to name checkboxes and send them. I hope this makes sense...

    Thanks,

    Doug

  7. #7
    SitePoint Zealot HotDog's Avatar
    Join Date
    May 2000
    Location
    Salt Lake City, UT
    Posts
    108
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Doug

    Try this. You can use this for any number of checkboxes.

    Code:
    <HTML>
    <HEAD>
    <script language=javascript>
    var count=1;
    
    //This is the number of total checkboxes you have
    var checkboxes=5;
    function check() {
    	do {
    		if (document.myform.elements['checkbox' + count].checked==true) {
    			document.write("You picked a box");
    			//More code to do whatever you want
    			
    			break;
    		}
    		if ((document.myform.elements['checkbox' + count].checked!=true)&&(count==checkboxes)) {
    			document.write("Please pick a box.");
    			//Or whatever error message you want to write
    		}
    		count++;
    	}
    	while(count<=checkboxs);
    }
    </script>
    <TITLE> type_Document_Title_here </TITLE>
    </HEAD>
    <BODY>
    <form name="myform">
    
    <!--You have to name your checkboxes in an array order inorder for this to work.-->
    
    <input type="checkbox" name="checkbox1">
    <input type="checkbox" name="checkbox2">
    <input type="checkbox" name="checkbox3" >
    <input type="checkbox" name="checkbox4" >
    <input type="checkbox" name="checkbox5" >
    <input type="button" onclick="return check()" value="Click Me">
    </form>
    </body>
    Hope this helps.

    Ruff!!!
    Last edited by HotDog; Mar 7, 2001 at 11:46.
    Joe Eliason
    Just a dog learnin' PHP from cat.

  8. #8
    SitePoint Addict
    Join Date
    Dec 2000
    Location
    BOSTON MA
    Posts
    335
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally posted by DougD
    One more question if you don't mind. I have one other page I need to redo. It is very similar to that page. It is a request form for literature. It has the general contact info stuff, which I know how to do. But it also has 2 check boxes so they can order "Informational Literature" and/or Pricing Literature".

    I cannot figure out how to get it to create an error message saying "Please select at least one type of Literature!"

    I am not sure what to name checkboxes and send them. I hope this makes sense...
    try HotDog's method first to see if it works with your existing script. if you can't make it work or you'd rather do it in php instead, then let us know.
    . . . chris

  9. #9
    I LOVE THIS SITE ! ! ! DougD's Avatar
    Join Date
    May 2000
    Location
    San Diego, CA
    Posts
    463
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks guys... Yes, I was hoping to do it in PHP Chris. If you have a simple solution that would be great.

    The form is at http://www.dotdealers.com/literature.php.

    I can do all the "Your Information" obviously. I just do not know how to implement the check boxes.

    Thanks,

    Doug

  10. #10
    Dumb PHP codin' cat
    Join Date
    Aug 2000
    Location
    San Diego, CA
    Posts
    5,460
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Doug is this an either or, or can they check both boxes? If it is an either or Iwould use radio buttons if it is either or both I would use checkboxes. Please clarify and we can whip something up for you I am sure
    Please don't PM me with questions.
    Use the forums, that is what they are here for.

  11. #11
    SitePoint Zealot HotDog's Avatar
    Join Date
    May 2000
    Location
    Salt Lake City, UT
    Posts
    108
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Plus, wouldn't it be me efficient to have javascript work the logic since you don't have to pass the page back to the server? Once the page is already loaded, the javascript is already there to test the values before the form is sent. Just let the client's browser handle the work. It's cross-browser complient so you don't have that issue.

    Plus, since you'll need to reference the form properties, you'll need to use javascript in your PHP script, so why not just stick with a javascript solution?

    I guess it really doesn't matter one way or the other, I'm just curious why you prefer to have it a strictly php solution.
    Joe Eliason
    Just a dog learnin' PHP from cat.

  12. #12
    Dumb PHP codin' cat
    Join Date
    Aug 2000
    Location
    San Diego, CA
    Posts
    5,460
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Actually Joe you can access the form elements directly in PHP, you won't need to use javascript. I think it is best to have both, never know who has javascript turned off, I normally do client side and server side validation to catch everyone.
    Please don't PM me with questions.
    Use the forums, that is what they are here for.

  13. #13
    I LOVE THIS SITE ! ! ! DougD's Avatar
    Join Date
    May 2000
    Location
    San Diego, CA
    Posts
    463
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    They can choose either or both.

    Thanks again!

  14. #14
    SitePoint Zealot HotDog's Avatar
    Join Date
    May 2000
    Location
    Salt Lake City, UT
    Posts
    108
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Good point. I guess I've just programmed javascript for so long that's how I think. One BIG advantage with doing it in PHP is you don't have to worry so much about which browser the client is using. Since you have to program javascript for every browser out there, it more like 5 languages instead of one. And now there's Netscape 6 in the mix. Is there no end to the maddness???

    BTW, have you been able to take a look at my post with the dropdown box problem??
    Joe Eliason
    Just a dog learnin' PHP from cat.

  15. #15
    Dumb PHP codin' cat
    Join Date
    Aug 2000
    Location
    San Diego, CA
    Posts
    5,460
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    So make them checboxes and name them both type[] and give each one a different value like literature and price like

    Code:
    <TR><TD ALIGN=CENTER WIDTH=20%> </TD>
    <TR><TD VALIGN=TOP ALIGN=RIGHT WIDTH=10%><INPUT NAME="type[]" TYPE="checkbox" VALUE="Literature" id="Please"></TD>
    <TD VALIGN=TOP WIDTH=60%><FONT SIZE=+1 COLOR=BLUE><B>2001 Product Information</B></FONT><BR>Literature on all of our products, including custom services, probes & primers and more!
    <TD WIDTH=10% VALIGN=TOP> </TD>
    <TR><TD ALIGN=CENTER WIDTH=20%> </TD>
    <TR><TD VALIGN=TOP ALIGN=RIGHT WIDTH=10%><INPUT NAME="type[]" TYPE="checkbox" VALUE="Price"></TD>
    <TD VALIGN=TOP WIDTH=60%><FONT SIZE=+1 COLOR=BLUE><B>2001 Order Form and Price List</B></FONT><BR>
    An up-to-date price list on our Custom Synthesis procedures.
    <TD WIDTH=10% VALIGN=TOP> </TD>

    Then when you process the form just check for the array type having more than 0 elements if it does loop through the array and see the checked items.
    PHP Code:
        if (count($type) > 0) {
            foreach(
    $type as $val) {
                print 
    $val."<br>";
                }
            }
        else {
            print 
    "Please Check a type";
            } 
    Please don't PM me with questions.
    Use the forums, that is what they are here for.

  16. #16
    SitePoint Zealot HotDog's Avatar
    Join Date
    May 2000
    Location
    Salt Lake City, UT
    Posts
    108
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hey...my 1,000 lines of code is better than freddy's 8.

    Again freddy, you're good.
    Joe Eliason
    Just a dog learnin' PHP from cat.

  17. #17
    I LOVE THIS SITE ! ! ! DougD's Avatar
    Join Date
    May 2000
    Location
    San Diego, CA
    Posts
    463
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Again... You guys are My Heros!

    It is exactly what I need...

    Thanks a ton,

    Doug


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •