JavaScript - Validations Not Working
Code:
<?php if (isset($_COOKIE["ValidUserAdmin"])) { require "config1.php"; require "config.php"; include "header_vendor.php"; $auth = ($_COOKIE["ValidUserAdmin"]); $sys_date= date("m/d/YY"); $sys_date1= date("Y/m/d"); ?> <html> <head> </head> <body> <table id="page"> <tr><td> <br> <form id="form1" name="form1" method="POST" > <TABLE class="tbl" width="100%" ALIGN="CENTER" CELLPADDING="0" CELLSPACING="1" BGCOLOR="#E4EEE3"> <TR> <TD colspan="4"><strong>Add New vendor </strong></a></TD> </TR> <TR> <TD BGCOLOR="#FFFFFF">Vendor Name <span style="color:#FF0000"> * </span></TD> <TD BGCOLOR="#FFFFFF"> <input type="text" name="ven_name" value="ven_name" size="40" ></TD> <TD BGCOLOR="#FFFFFF">Category <span style="color:#FF0000"> * </span></TD> <TD BGCOLOR="#FFFFFF"> <? $query1 = "SELECT distinct Vendor_category from aa_customize where Vendor_category != ''"; $result1 = mysql_query($query1); if(!$result1) { echo "The query failed " . mysql_error(); } else { echo "<select name='category' >"; ?> <option value=""> Select One </option> <? while($row = mysql_fetch_array($result1, MYSQL_ASSOC)) { $select= $row['Vendor_category']; echo"<option value='". $row['Vendor_category']."'>" .$row['Vendor_category'] . "</option>"; } echo"</select>"; } ?></TD> </TR> <TR><TD colspan="4"><strong>Contact Details </strong></TD></TR> <tr> <TD BGCOLOR="#FFFFFF">Contact Landline No. <span style="color:#FF0000"> * </span></TD> <TD BGCOLOR="#FFFFFF"> <input type="TEXT" name="landline" value="" size="15"> </TD> <TD BGCOLOR="#FFFFFF">Contact Mobile <span style="color:#FF0000"> * </span></TD> <TD BGCOLOR="#FFFFFF"> <INPUT id="mobile" NAME="mobile" TYPE="text" value="" size="15" /></TD> </TR> <TR> <TD BGCOLOR="#FFFFFF">Contact Email <span style="color:#FF0000"> * </span></TD> <TD BGCOLOR="#FFFFFF"> <input type="TEXT" name="email" size="35" value=""> </TD> <td bgcolor="#FFFFFF">Website</td> <td bgcolor="#FFFFFF"> <input type="text" name="website"></td> </TR> <TR> <TD BGCOLOR="#FFFFFF">Address<span style="color:#FF0000"> * </span></TD> <TD BGCOLOR="#FFFFFF" colspan="3"><p> <textarea white-space:nowrap;overflow:auto; rows="3" cols="35" type="TEXT" name="address"><? echo $address ; ?></textarea></p> </TD> </TR> <TR> <TD BGCOLOR="#FFFFFF">State<span style="color:#FF0000"> * </span></TD> <TD BGCOLOR="#FFFFFF"> <? $query1 = "SELECT distinct state from subcategory order by cat_id"; $result1 = mysql_query($query1); if(!$result1) { echo "The query failed " . mysql_error(); } else { echo "<select name='state' onChange='AjaxFunction(document.form1.state.options[document.form1.state.selectedIndex].text);'>"; ?> <option value=""> Select One </option> <? while($row = mysql_fetch_array($result1, MYSQL_ASSOC)) { $select= $row['state']; echo"<option value='". $row['state']."'>" .$row['state'] . "</option>"; } echo"</select>"; } ?> <TD BGCOLOR="#FFFFFF">City <span style="color:#FF0000"> * </span></TD> <TD BGCOLOR="#FFFFFF"> <select name="city"> </select> </TR> <TR> <TD BGCOLOR="#FFFFFF">Country <span style="color:#FF0000"> * </span></TD> <TD BGCOLOR="#FFFFFF"> <select name="country"> <option value="India" selected="selected">India</option> <option value="United States">United States</option> <option value="United Kingdom">United Kingdom</option> </select> <TD BGCOLOR="#FFFFFF">Pincode<span style="color:#FF0000"> * </span></TD> <TD BGCOLOR="#FFFFFF"> <input type="TEXT" name="pin" size="8" value="" ></TD> </TR> <tr><td colspan="4"><strong>Mode Of Transaction</strong></td> </tr> <tr><td bgcolor="#FFFFFF" ><label> <input type="checkbox" id="check1" name="cheque" value="Cheque" onClick="showMe('chq_div','pay_chq', this)" /> Cheque/AtparCheque</label></td> <td colspan="3" bgcolor="#FFFFFF"><div id="chq_div" style="display:none"> In Favour Of <input id="pay_chq" type="TEXT" name="payment_to_chq" size="30" ></div> </td></tr> <tr><td bgcolor="#FFFFFF"><label> <input type="checkbox" id="check2" name="dd" value="DD" onClick="showMe1('dd_div','pay_dd','pay_at',this)"/> Demand Draft</label></td> <td colspan="3" bgcolor="#FFFFFF"><div id="dd_div" style="display:none"> In Favour Of <input id="pay_dd" type="TEXT" name="payment_to_dd" size="30" > Payable At <input id="pay_at" type="TEXT" name="payable_at" size="30" > </div></td> </tr> <tr><td bgcolor="#FFFFFF"><label> <input type="checkbox" id="bktransfer" name="banktransfer" value="Bank Transfer" onClick="showMe2('addBank', this)"/> Bank Transfer</label></td> <td colspan="3" bgcolor="#FFFFFF"> <table id="addBank" style="display:none"> <tr><td BGCOLOR="#E4EEE3" align="center">Account Name</td><td BGCOLOR="#E4EEE3" align="center">Account No.</td><td BGCOLOR="#E4EEE3" align="center">Bank Name</td><td BGCOLOR="#E4EEE3" align="center">Branch Name</td><td BGCOLOR="#E4EEE3"><input type="button" name="add" value="Add Bank" onClick="addRow('addBank')"></td></tr> </table> </td></tr> <tr><td bgcolor="#FFFFFF"><label> <input type="checkbox" id="cash" name="cash" value="Cash" /> Cash</label></td> <td colspan="3" bgcolor="#FFFFFF"> </td></tr> <!-- flooble Expandable Content box start --> <tr><td align="left" colspan="4">[<a title="show/hide" id="exp1254911560_link" href="javascript: void(0);" onClick="toggle(this, 'exp1254911560');"> - </a>] <b>Add Contanct Persons</b></td> </tr> <tr><td bgcolor="#FFFFFF" colspan="4"> <table id="exp1254911560"> <tr><td align="center">Name</td><td align="center">Contact No</td><td align="center">Email Id</td><td align="center">Designation</td><td align="center">Department</td><td><input type="button" name="add" value="Add contanct" onClick="addRow1('exp1254911560')"></td></tr> </table> </td> </tr> <script language="javascript">toggle(getObject('exp1254911560_link'), 'exp1254911560');</script> <!-- flooble Expandable Content box end --> <TR> <TD colspan="4" align="center" bgcolor="E4EEE3" > <input name="submit" type="SUBMIT" value="Add" align="middle" size="30" onClick="return validate();"></TD> </TR> </TABLE> </form> <script language="JavaScript" type="text/javascript"> function validate(){ var rgxa = /^-?\d+(\.\d+)?$/; dml=document.forms['form1']; // get the number of elements from the document len = dml.elements.length; for( i=0 ; i<len ; i++) { //check the textbox with the elements name if (dml.elements[i].name=='bank[]') { // if exists do the validation and set the focus to the textbox if (dml.elements[i].value=="") { alert("Enter the Bank Name "); dml.elements[i].focus(); return false; } } if (dml.elements[i].name=='branch[]') { // if exists do the validation and set the focus to the textbox if (dml.elements[i].value=="") { alert("Enter the Branch Name "); dml.elements[i].focus(); return false; } }if (dml.elements[i].name=='account[]') { // if exists do the validation and set the focus to the textbox if (dml.elements[i].value=="") { alert("Enter the Account No "); dml.elements[i].focus(); return false; } if(!rgxa.test(dml.elements[i].value)) { alert("Not a Valid Account no, Enter in Numerics!!"); dml.elements[i].value=""; dml.elements[i].focus(); return false; } } if (dml.elements[i].name=='account_name[]') { // if exists do the validation and set the focus to the textbox if (dml.elements[i].value=="") { alert("Enter the Account Name "); dml.elements[i].focus(); return false; } } if (dml.elements[i].name=='user[]') { // if exists do the validation and set the focus to the textbox if (dml.elements[i].value=="") { alert("Enter the User Name "); dml.elements[i].focus(); return false; } } if (dml.elements[i].name=='contact[]') { // if exists do the validation and set the focus to the textbox if (dml.elements[i].value=="") { alert("Enter the Contact No "); dml.elements[i].focus(); return false; } if(!rgxa.test(dml.elements[i].value)) { alert("Not a Valid Contact no, Enter in Numerics!!"); dml.elements[i].value=""; dml.elements[i].focus(); return false; } } if (dml.elements[i].name=='emailid[]') { // if exists do the validation and set the focus to the textbox if (dml.elements[i].value=="") { alert("Enter the Email Id "); dml.elements[i].focus(); return false; } } } var frmvalidator = new Validator("form1"); var chq_select = document.getElementById("check1") var chq_fvr = document.getElementById("pay_chq") var dd_select = document.getElementById("check2") var dd_fvr = document.getElementById("pay_dd") var dd_at = document.getElementById("pay_at") var bank_select = document.getElementById("bktransfer") var cash_select = document.getElementById("cash") frmvalidator.addValidation("ven_name","req","Please Enter Vendor Name"); frmvalidator.addValidation("ven_name","maxlen=200"); frmvalidator.addValidation("category","req","Please Select category for Vendor"); frmvalidator.addValidation("landline","req","Please enter your Landline no."); frmvalidator.addValidation("landline","maxlen=15","Landline no. exceeds its maximum length"); frmvalidator.addValidation("landline","numeric","Only digits are allowed in landline no"); frmvalidator.addValidation("mobile","req","Please enter your Mobile no."); frmvalidator.addValidation("mobile","maxlen=13","Mobile no. exceeds its maximum length"); frmvalidator.addValidation("mobile","numeric","Only digits are allowed in Mobile no"); frmvalidator.addValidation("email","email","please Enter Valid Email-Id"); frmvalidator.addValidation("email","maxlen=100"); frmvalidator.addValidation("email","req","Please Enter your Email-Id"); frmvalidator.addValidation("address","req","Please Enter your Address"); frmvalidator.addValidation("address","maxlen=800","Address Field exceeds its maximum length"); frmvalidator.addValidation("city","req","Please select your city"); frmvalidator.addValidation("city","maxlen=100","maximum length allowed for city is 100 alphabets"); frmvalidator.addValidation("state","req","Please select your State"); frmvalidator.addValidation("state","maxlen=100","maximum length allowed for State is 150 alphabets"); frmvalidator.addValidation("country","req","Please select your Country"); frmvalidator.addValidation("country","maxlen=100","maximum length allowed for Country is 150 alphabets"); frmvalidator.addValidation("pin","req","Please enter Your Pin code"); frmvalidator.addValidation("pin","maxlen=6","Pin code must be of 6 digits"); frmvalidator.addValidation("pin","minlen=6","Pin code must be of 6 digits"); frmvalidator.addValidation("pin","numeric","Pin code must be digit"); if(chq_select.checked == false && dd_select.checked== false && bank_select.checked== false && cash_select.checked==false) { alert("Select One mode of Payment"); return false; } if(chq_select.checked == true && chq_fvr.value=="") { chq_fvr.focus(); alert("Enter Cheque In Favour Of"); return false; } if(dd_select.checked == true && dd_fvr.value=="") { dd_fvr.focus(); alert("Enter DD In Favour Of"); return false; } if(dd_select.checked == true && dd_at.value=="") { dd_at.focus(); alert("Enter DD Payable at "); return false; } } </script> <BR> <? $ban = $_POST['bank']; $branch = $_POST['bank']; $v_name=$_POST['ven_name']; if(isset($_POST['submit']) && isset($_POST['banktransfer']) ) { $str="INSERT INTO aa_vendor1(id,ven_name,category,landline,mobile,email,address,city,state,country,pin,cheque,cash,dd,banktransfer,chq_favr,dd_favr,dd_pay,website) VALUES ('','".$_POST['ven_name']."','".$_POST['category']."','".$_POST['landline']."','".$_POST['mobile']."','".$_POST['email']."','".$_POST['address']."','".$_POST['city']."','".$_POST['state']."','".$_POST['country']."','".$_POST['pin']."','".$_POST['cheque']."','".$_POST['cash']."','".$_POST['dd']."','".$_POST['banktransfer']."','".$_POST['payment_to_chq']."','".$_POST['payment_to_dd']."','".$_POST['payable_at']."','".$_POST['website']."')"; mysql_query($str); echo mysql_error(); $bak = $_POST['bank']; $brnch = $_POST['branch']; $acc_name = $_POST['account_name']; $acc_no = $_POST['account']; $count = count($bak); for($i=0 ; $i < count($ban); $i++) { $qry = "INSERT INTO aa_bank (`id`,`acc_name`,`acc_no`,`bank`,`ven_name`,`branch_name`) VALUES ('','".$acc_name[$i]."','".$acc_no[$i]."','".$bak[$i]."','".$_POST['ven_name']."', '".$brnch[$i]."')"; mysql_query($qry); echo mysql_error(); } $desg = $_POST['desg']; $user = $_POST['user']; $contact = $_POST['contact']; $emailid = $_POST['emailid']; $dept = $_POST['dept']; $count11 = count($desg); for($i=0 ; $i < count($desg); $i++) { $qry = "INSERT INTO contacts (`id`,`ven_name`,`desg`,`namee`,`contact`,`emailid`,dept) VALUES ('','".$_POST['ven_name']."','".$desg[$i]."','".$user[$i]."','".$contact[$i]."', '".$emailid[$i]."','".$dept[$i]."')"; mysql_query($qry); echo mysql_error(); } ?> <META HTTP-EQUIV="refresh" content="0;URL=vendor_add_product.php?ven_name=<? echo $v_name; ?>"> <? } else { if(isset($_POST['submit'])) { $str="INSERT INTO aa_vendor1(id,ven_name,category,landline,mobile,email,address,city,state,country,pin,cheque,cash,dd,banktransfer,chq_favr,dd_favr,dd_pay,website) VALUES ('','".$_POST['ven_name']."','".$_POST['category']."','".$_POST['landline']."','".$_POST['mobile']."','".$_POST['email']."','".$_POST['address']."','".$_POST['city']."','".$_POST['state']."','".$_POST['country']."','".$_POST['pin']."','".$_POST['cheque']."','".$_POST['cash']."','".$_POST['dd']."','".$_POST['banktransfer']."','".$_POST['payment_to_chq']."','".$_POST['payment_to_dd']."','".$_POST['payable_at']."','".$_POST['website']."')"; mysql_query($str); echo mysql_error(); $desg = $_POST['desg']; $user = $_POST['user']; $contact = $_POST['contact']; $emailid = $_POST['emailid']; $dept = $_POST['dept']; $count11 = count($desg); for($i=0 ; $i < count($desg); $i++) { $qry = "INSERT INTO contacts (`id`,`ven_name`,`desg`,`namee`,`contact`,`emailid`,dept) VALUES ('','".$_POST['ven_name']."','".$desg[$i]."','".$user[$i]."','".$contact[$i]."', '".$emailid[$i]."','".$dept[$i]."')"; mysql_query($qry); echo mysql_error(); } ?> <META HTTP-EQUIV="refresh" content="0;URL=vendor_add_product.php?ven_name=<? echo $v_name; ?>"> <? } } ?> </td> </tr> </table> <? } else { print "<p>Unauthorised Admin access - <a href=\"http://expense.webhop.org\">Click Here to Login</></p>"; } ?> </td> </tr> </table> <TABLE WIDTH="100%" CELLPADDING="0" CELLSPACING="1" BGCOLOR="<?php print "$HRColour"; ?>"> <TR> <TD></TD> </TR> </TABLE> <P ALIGN="CENTER" CLASS="copyright"><?php print "$Copyright"; ?></P> </body> </html> Similar TutorialsI have been working on a JavaScript form with validation and I cant get it to work right. The form is supposed to validate the name, E-mail, Phone number, Password and confirmation, Drop-down selection, Question reply, yes and no radios, and 3 preferences check-boxes. It is also supposed to verify that the passwords match, not allow any letters or special characters in the phone number box, and remove the default text when a user clicks on the Name, E-mail, and Question reply boxes. I've been checking over the code for almost a month now and I can't figure out why it is not working. This is my entire code. [CODE] <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Contact</title> <script type="text/javascript"> /* <![CDATA[ */ function onlyDigits(objtextbox) { var exp = /[^\d]/g; objtextbox.value = objtextbox.value.replace(exp,""); } function textdisappear(txt) { if (txt.value == txt.defaultValue) { txt.value = "" } function passmatch() { if (document.forms[0].psswrd2.value != document.forms[0].psswrd1.value) { window.alert("You did not enter the same password!"); document.forms[0].psswrd1.focus(); } function validate() { var name = document.form1.Name; var email = document.form1.Email; var phone = document.form1.Telephone; var question = document.form1.selection; var reply = document.form1.questionreply var word1 = document.form1.psswrd1 var word2 = document.form1.psswrd2 var chkradio = false; var chkbox = false; if (name.value == "") { window.alert("Name please."); name.focus(); return false; } if (email.value == "") { window.alert("E-mail is blank."); email.focus(); return false; } if (email.value.indexOf("@", 0) < 0) { window.alert("Enter valid e-mail please."); email.focus(); return false; } if (email.value.indexOf(".", 0) < 0) { window.alert("Enter valid e-mail please."); email.focus(); return false; } if ((phone.value == "")) { window.alert("Telephone number please."); phone.focus(); return false; } if (word1.value == "") { window.alert("Password please."); word1.focus(); return false; } if (word2.value == "") { window.alert("Re-type password please."); word2.focus(); return false; } if (question.selectedIndex < 1) { alert("Choose question please."); question.focus(); return false; } if (reply.value == "" || reply.value == "Question reply") { window.alert("Question reply please."); reply.focus(); return false; } for (var i=0; i<2; ++i) { if (document.form1.confirmreply.checked == true) { chkradio = true; break; } if (chkradio != true) { window.alert("Yes or no please."); confirmrelpy.focus(); return false; } for (var i=0; i<3; ++i) { if (document.form1.hobby.checked == true) { chkbox = true; break; } if (chkbox != true) { window.alert("Choose preference."); hobby.focus(); return false; } return true; } /* ]]> */ </script> </head> <body> <center><h1>Contact</h1></center> <form method="post" action="mailto:someemail@somedomain.com" name="form1" onsubmit="return validate();"> <h3>Your Details</h3> <p>Name:* <input type="text" name="Name" value="Enter Name" onfocus="textdisappear(this)" ></p> <p>E-mail:* <input type="text" name="Email" value="Enter E-mail" onfocus="textdisappear(this)" ></p> <p>Phone Number:* <input type="text" name="Telephone" onkeyup="onlyDigits(this)"><br> <br /> <h3>Password and Secret Question</h3> Password:<br /> <input type="password" name="psswrd1" value="" />*<br /> Confirm:<br /> <input type="password" name="psswrd2" value="" onblur="passmatch()" />*<br /> <p>Choose a question:*<br /> <select type="text" value="" name="selection"> <option> </option> <option>Where was your elementary school?</option> <option>Who was the first person you ever kissed?</option> <option>What was your first car?</option> <option>Who is your favorite author?</option> </select><br /> reply<br /> <input type="text" name="questionreply" value="Question reply" onfocus="textdisappear(this)" />*<br /> <h3>Offers</h3> Do you want any special offers sent to you?*<br /> Yes<input type="radio" name="confirmreply" value="Yes"/>No<input type="radio" name="confirmreply" value="No" /> <h3>Which preference do you have?*</h3> <input type="checkbox" name="hobby" value="check"/>Inside Activities<br /> <input type="checkbox" name="hobby" value="check"/>Outside Activities<br /> <input type="checkbox" name="hobby" value="check"/>Both<br /> <br /> <p><input type="submit" value="Submit" name="submit" /> <input type="reset" value="Reset" name="reset"></p> </form> </body> </html> [CODE] hii i struck ed with problem from last one weak. i want validations for two dropdown menu's... when user click on second dropdown menu by skipping first dropdown menu at that time alert box will come and it should say please select from upper menu.... please help me thanks this is the code but it's not working <HTML><HEAD> <TITLE>drop down validation</TITLE> <script type="text/javascript"> function validateForm(){ if(document.ItemList.Item.selectedIndex==0) { alert("Please select item from first list."); document.ItemList.Item.focus(); return false; } return true; } </SCRIPT> </HEAD> <BODY> Please choose an item from the drop down menu: <form name="ItemList" method="post" action="asp.html" onsubmit="validateForm()"> <table width="100%" border="0"> <tr> <td width="135">Choose a username: </td> <td> <select name="Item"> <option value selected> SELECT </option> <option value>Apples</option> <option value>Oranges</option> </select> <table width="100%" border="0"> <tr> <td width="135">Choose a username: </td> <td> <select name="Item" onchange="validateForm()"> <option value selected> SELECT </option> <option value>Apples</option> <option value>Oranges</option> </select> <input type="submit" name="Submit" value="Submit"> </td></tr></table></form> </BODY> </HTML> use in form fields - onBlur="chkalpha(this)" function chknum(field) { var valid = "0123456789"; var ok = "yes"; var temp; for (var i=0; i<field.value.length && ok == "yes"; i++) { temp = "" + field.value.substring(i, i+1); if (valid.indexOf(temp) == "-1") { var ok = "no"; } } if (ok == "no") { alert("Invalid entry! Only numeric data is accepted!"); field.value=""; field.focus(); field.select(); } } function chkalpha(field) { var valid = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ "; var ok = "yes"; var temp; for (var i=0; i<field.value.length && ok == "yes"; i++) { temp = "" + field.value.substring(i, i+1); if (valid.indexOf(temp) == "-1") { var ok = "no"; } } if (ok == "no") { alert("Invalid entry! Only alphabetic data is accepted!"); field.value=""; field.focus(); field.select(); } } function chkalphanum(field) { var valid = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ@_-. "; var ok = "yes"; var temp; for (var i=0; i<field.value.length && ok == "yes"; i++) { temp = "" + field.value.substring(i, i+1); if (valid.indexOf(temp) == "-1") { var ok = "no"; } } if (ok == "no") { alert("Invalid entry! Only alphanumeric data is accepted!"); field.value=""; field.focus(); field.select(); } } So if both validations work seperatley (if I just put radio buttons validation in the function without the spinner validation then radio buttons validation works and same vise versa), how come when I put both validations in the function, the top validation which is the radio validation works but the bottom validation which is the spinner validation does not display a message when it is suppose to? Code is below: Code: <head> <meta http-equiv="Content-Type" content="text/html;charset=utf-8" /> <title>Create a Session</title> <script type="text/javascript"> function validation() { var errMsgO = document.getElementById("radioAlert"); var btnRadioO = document.getElementsByName("sessionNo"); var isbtnRadioChecked = false; var errQuesMsgO = document.getElementById("numberAlert"); var questionNumberO = document.getElementsByName("txtQuestion"); for(i=0; i < btnRadioO.length; i++){ if(btnRadioO[i].checked){ isbtnRadioChecked = true; } } if(!isbtnRadioChecked) { errMsgO.innerHTML = "Please Select the Number of Sessions you Require"; } else { errMsgO.innerHTML = ""; } return false; if(questionNumberO[0].value == 0){ errQuesMsgO.innerHTML = "Please Set the Number of Questions"; } else { errQuesMsgO.innerHTML = ""; } return false; } </script> </head> <body> <form action="create_session.php" method="post" name="sessionform"> <table> <tr> <th>2: Number of Sessions :</th> <td class="sessionNo"><input type="radio" name="sessionNo" value="1" />1</td> <td class="sessionNo"><input type="radio" name="sessionNo" value="2" />2</td> <td class="sessionNo"><input type="radio" name="sessionNo" value="3" />3</td> <td class="sessionNo"><input type="radio" name="sessionNo" value="4" />4</td> <td class="sessionNo"><input type="radio" name="sessionNo" value="5" />5</td> </tr> </table> <div id="radioAlert"></div> <table> <tr> <th>Number of Questions:</th> <td class="spinner"><textarea class="spinnerQuestion" name="txtQuestion" id="txtQuestion" cols="2" rows="1"></textarea></td> <td><button class="scrollBtn" id="btnQuestionUp"><img src="Images/black_uppointing_triangle.png" alt="Increase" /></button> <button class="scrollBtn" id="btnQuestionDown"><img src="Images/black_downpointing_triangle.png" alt="Decrease" /></button></td> </tr> </table> <div id="numberAlert"></div> <p><input class="questionBtn" type="button" value="Prepare Questions" name="prequestion" onClick="validation()" /></p> <!-- Prepare Questions here--> </form> </body> Ok, here's the page as it is right now: http://www.crackin.com/dev/index.php The paganation for the top 3 images is Sweet Pages: http://tutorialzine.com/2010/05/swee...tion-solution/ The content loading below is a page-replace script I got he http://css-tricks.com/dynamic-page-replacing-content/ And I'm also trying to integrate shadowbox (or lightbox, whichever will work) into the lower set of images. I have 2 problems right now I can't figure out, and I'm sure it somehow has to do with the fact I'm trying to mash 3 different JS addons into a single page, I'm still pretty new to this whole JS thing... First problem I'm having is that IE7 and Opera don't like the links in the upper images. Clicking a gallery image does not load the associated page below from those 2 browsers, however IE8 and FF seem to work fine. Second problem is getting shadowbox/lightbox to work on those lower images. I tried a couple different things but main thing I did is make sure the script is actually working by setting the header text to a link with shadowbox attached and that worked. That same link doesn't work when applied to the lower images (loads image in new window). Lightbox does the same thing. Thanks for any help. I hope I have this post in the right place! Any help would be very much appreciated... I have a feature on my website that allows users to choose the website background (using alternate css sheets) and then uses an externally linked javascript file to store the background choice as a cookie so it is consistent throughout the website. This works perfectly locally (i.e. when previewing my website on my computer) but now it is uploaded to my host it doesn't appear to be working. (with the same browser) My javascript is he http://www. b r p - e n v .com/javascript/backgroundchange.js (with no spaces) The website that the javascript file is linked to is http://www. b r p - e n v .com (with no spaces) In the head I have: <script type="text/javascript" src="../javascript/backgroundchange.js"></script> ...then I have: <body onload="set_style_from_cookie()"> ...and for users to choose which background: <form> <input type="image" src="../images/white-background-thumb.jpg" onclick="switch_style('bg1');return false;" name="theme" value="White" id="bg1"> etc... </form> My problem is: The background reverts back to the default when moving to a different page. This would indicate that the background choice is not being saved in cookies. But this works locally! I have tried putting the javascript directly onto each page but I still had the same problem. I hope someone can help, I will be so grateful if I can get this to work. Many thanks indeed! Hi All, I have two sites using zeroclipboard (hosted at google code) one works only in firefox and barely, the other is not working at all. It does use Flash, but I think the issue is on the js side of things. On both links, clicking the filename below the thumbnail will copy and add the link as an IMG code to a div below. *working* link http://pics.boasbysatyra.com/access/spiders.php This one only works in FF, and the clip area is offset badly. Here is the template for the zc code: Code: <div class="photo" style="float: left; padding: 4px;"> <div class="exif"><a href="[~41~]?dir=[+images_dir+]&file=[+filename+]" rel="shadowbox[exif_[+content_id+]]" title="exif data for [+filename+]" alt="exif data for [+filename+]">EXIF Data</a></div> <a class="thumb" rel="shadowbox[[+content_id+]]" href="[+images_dir+][+filename+]" title="[+title+] | [+description+]"> <img src="[+thumbs_dir+][+filename+]" alt="[+title+]" /> </a> <div class="filecode" id="d_clip_button[+filename+]">[+filename+] <script language="JavaScript"> var clip = new ZeroClipboard.Client(); clip.setText( 'http://pics.boasbysatyra.com[+images_dir+][+filename+]' ); clip.glue( 'd_clip_button[+filename+]' ); clip.addEventListener( 'onComplete', my_complete ); function my_complete( client, text ) { $('.picklist').append('<div class="piclinks">[IMG]' + text + '[/IMG]</div>'); } </script> </div> </div> And the JS for the page: Code: var needRef; //flag for page reload function pEdit(){ needRef = 1; } Shadowbox.init({ handleOversize: "resize", modal: true, initialHeight: 32, initialWidth: 400, overlayOpacity: 0.85, onClose: function(){//check for reload flag and reload if (needRef == 1){window.location.href=window.location.href;} } }); ZeroClipboard.setMoviePath('/js/zc/ZeroClipboard10.swf'); function initMenu() { $('#menu ul').hide(); $('#menu ul:first').show(); $('#menu li a').click(function() { var checkElement = $(this).next(); if ((checkElement.is('ul')) && (checkElement.is(':visible'))) { //return false; } if ((checkElement.is('ul')) && (!checkElement.is(':visible'))) { $('#menu ul:visible').slideUp('normal'); checkElement.slideDown('normal'); return false; } }); } $(document).ready(function() { initMenu(); }); Now on to the totally broken one - it creates the elements required, but gives them a 0x0 area! http://jb.boasbysatyra.com/forum-pic...cs/nature.html Code: div class="photo" style="float: left; margin: 4px;"> <div class="exif"><a href="[~133~]?dir=[+images_dir+]&file=[+filename+]" rel="shadowbox[exif_[+content_id+]]" title="exif data for [+filename+]" alt="exif data for [+filename+]">EXIF Data</a></div> <a class="thumb" rel="shadowbox[[+content_id+]]" href="[+images_dir+][+filename+]" title="[+title+] | [+description+]"> <img src="[+thumbs_dir+][+filename+]" alt="[+title+]" /> </a> <div id="d_clip_container[+filename+]" style="position:relative; width: 120px; height: 0.5em;"> <div class="filecode" id="d_clip_button[+filename+]">[+filename+] <script language="JavaScript"> var clip = new ZeroClipboard.Client(); clip.setText( 'http://jb.boasbysatyra.com[+images_dir+][+filename+]' ); clip.glue( 'd_clip_button[+filename+]','d_clip_container[+filename+]' ); clip.addEventListener( 'onComplete', my_complete ); function my_complete( client, text ) { $('.picklist').append('<div class="piclinks">[IMG]' + text + '[/IMG]</div>'); } </script> </div> </div> </div> On this one I wrapped it as suggested on the zc site, I originally started with the code for the other site - it didn't work, so I went tweaking... Here is the JS: Code: var needRef; //flag for page reload function pEdit(){ needRef = 1; } Shadowbox.init({ handleOversize: "resize", modal: true, initialHeight: 32, initialWidth: 400, overlayOpacity: 0.85, onClose: function(){//check for reload flag and reload if (needRef == 1){needRef = 0; window.location.href=window.location.href;} } }); ZeroClipboard.setMoviePath('/js/zc/ZeroClipboard10.swf'); $(document).ready(function() { $(".dim img").fadeTo("slow", 0.65); $(".dim img").hover(function(){ $(this).fadeTo("slow", 1.0); },function(){ $(this).fadeTo("slow", 0.65); }); $('#mainContent').hide().fadeIn(1200); //When page loads... $(".tab_content").hide(); //Hide all content // $("ul.tabs li:first").addClass("active").show(); //Activate first tab // $(".tab_content:first").show(); //Show first tab content //On Click Event $("ul.tabs li").click(function() { $("ul.tabs li").removeClass("active"); //Remove any "active" class $(this).addClass("active"); //Add "active" class to selected tab $(".tab_content").hide(); //Hide all tab content var activeTab = $(this).find("a").attr("href"); //Find the href attribute value to identify the active tab + content $(activeTab).fadeIn(); //Fade in the active ID content return false; }); }); (function($) { $(document).ready(function(){ $('.menu1').ptMenu(); $('.menu2').ptMenu({vertical:true}); }); })(jQuery); I have taken a look at this for a few days and tried many things with no luck, any help is appreciated. Thanks! I have a usercontrol which get inputs from the user and show the slideshows. I have added jquery.js and jqfancytransitions.js to the control. when i apply the effects dynamically it is working on local iis but the same coding is not working on iis server. The link for the page is http://www.gloriatech.com/slideshow.aspx . Actually it display the images but no effects are applied. I also checked the js files, it is in right path only.When i checked this page in firebug , it shows the error which is " Sys is undefined". I dont know how to solve it. Can anyone help me? Thanx in advance. hereis the html file and javascripton click of this button a html ***************************** <table class=matcolor id=topnav cellspacing=0 cellpadding=0 width=550 border=0 bgcolor="#FFCCCC"> <tbody> <tr align=middle> <td id=menu1 onMouseOver="this.className='mPrimaryOn';showmenu(this);" onClick="this.document.location.href=''" onMouseOut="this.className='mPrimaryOff';hidemenu(this);" class="mat" height="20"> <div align="center"><font color="#FF0000">Desk Top Publishing </font></div> </td> <td width=1 bgcolor=#ff9900 class="mat"></td> <td id=menu2 onMouseOver="this.className='mPrimaryOn';showmenu(this);" onClick="this.document.location.href=''" onMouseOut="this.className='mPrimaryOff';hidemenu(this);" class="mat" height="20"> <div align="center"><font color="#FF0000">Transcription</font></div> </td> <td width=1 bgcolor=#ff9900 class="mat"></td> <td id=menu3 onMouseOver="this.className='mPrimaryOn';showmenu(this);" onClick="this.document.location.href=''" onMouseOut="this.className='mPrimaryOff';hidemenu(this);" class="mat" height="20"> <div align="center"><font color="#FF0000">Accounts Processing </font></div> </td> </tr> </tbody> </table> ***************************************** <script language=JavaScript> ix = document.getElementById('tblmenu1').getBoundingClientRect(); new ypSlideOutMenu("menu1", "right",ix.left + ix.right ,ix.bottom + 10); </script> **any thing i have to alter to work in firefox please help I am trying to use "&&" like in PHP, but JavaScript doesn't like it: Code: if (document.forms["form"]["30"].value == "" && document.forms["form"]["32"].value == "") {foobar;} So, if both these conditions are true, then foobar. Does anyone know why it doesn't work? hi jus want to ask why is the else not working in the showmore and showless function i have two div which shld conduct the same way of working which is to show the rest of the text with the show more and min the text with the show less function anyone know what my mistake is? Code: function showmore() { if (document.getElementById("mydiv1") ){ document.getElementById("mydiv1").innerHTML = ""; document.getElementById("mydiv1").innerHTML = txt1 + "<font color = '#0000FF' size = '1'><a onclick='showless();return false'>.....read less</a>";txt1; } else { document.getElementById("mydiv").innerHTML = ""; document.getElementById("mydiv").innerHTML = txt + "<font color = '#0000FF' size = '1'><a onclick='showless();return false'>.....read less</a>";txt; } } function showless() { if (document.getElementById("mydiv1")){ document.getElementById("mydiv1").innerHTML = shorttxt1 + "<font color = '#0000FF' size = '1'><a onclick='showmore();return false'>.....read more</a>"; } else { document.getElementById("mydiv").innerHTML = shorttxt + "<font color = '#0000FF' size = '1'><a onclick='showmore();return false'>.....read more</a>"; } } thanks Reply asap!!! Script::. Code: <script language="javascript"> function temp(form) { oops = ""; var sum = 0; var fld = (form.level.value); var val = fld.value.replace(/\s/g, "" ); if ( val != "") { var deg = parseFloat(fld.value); if ( isNaN(deg) || deg < 0) { fld.value = "0"; oops += "\nInvalid Level"; } else if ( deg != 0 ) { sum += Math.pow( deg, 3 );} } if ( oops != "" ) { alert("You must correct these errors:\n" + oops); return false; } form.totalexp.value = sum ; } </script> Html::. Code: <form style="text-align:center"> <p>Level</p> <p><input size=30 maxlength=30 value=0 name="level" onfocus="this.value=''"/></p> <input type=button onclick=temp(this.form) value=Calculate /> <input type=reset name=clear id=clear value=Clear /></p> <blockquote><p>Total Exp <input name="totalexp" size=40 maxlength=40 readonly=""/></p></blockquote></form> Can someone help me. Whats wrong with my js code and i am noob to J.S. Your help is most appreciated. This is not working, any idea ? Code: function respuestas1() { var radios=document.getElementsByTagName("input"); var values; for (var i=0; i<radios.length; i++) { if (radios[i].type==="radio" && radios[i].checked) { values=radios[i].value; sum = 0; for (var i=0; i<values.length; i++) { sum = sum + Number(values[i]); alert(sum); } } } } HI, i know this must be old js because 'language' is deprecated but, I would like to know where this script gets the word 'Name:' from for the output after I entered dat to the textbox. Code: <HTML> <HEAD> <script language="javascript"> <!-- function send_onclick(frmName) { var bolSubmit; bolSubmit = true; if (frmName.email.value == "") { alert("You must enter an email address"); bolSubmit = false; } if (bolSubmit == true) { frmName.submit(frmName); } } //--> </script> </HEAD> <BODY> <form name="frmName" method="post" action="validate.asp"> Enter your name in the text box. If nothing is entered, a warning message will be displayed. <br>Only when you enter something into the text box will the page be submitted. <br><br> Please enter your name : <INPUT TYPE="TEXT" name="email" size="20"><br> <INPUT TYPE="button" name="butSent" value="Do it" language="javascript" onclick="return send_onclick(frmName)"> </form> Name : d </BODY> </HTML> I guess its from the 'name' of name='email' but how does it do it. Is this next part grabbing everything that was submitted as if a key/value pair? Code: if (bolSubmit == true) { frmName.submit(frmName); } bazz check out this page http://qa-www.inmarkit.net/cu.php (you might see an ERROR like "Notice: Undefined index: SCRIPT_URI ... on line 23" THAT'S FINE - that page sets a cookie to allow you to see the header with login on homepage) then go to the homepage: http://qa-www.inmarkit.net/ and try to click on "Log In" in top right corner a overlay with iFrame opens IE7 but not in IE8 can anyone point me in the right direction... what's the right way to handle something like this? approach? steps? techniques? tools? Thank you... PS Looking for general advise - but perhaps you are up to the challenge and see the exact cause? In my website, I have a script that I need help to get working. This is my script. Code: <script language="Javascript"> <!-- if (screen.width>=1024) { document.write('<td width="20%"><table border="0" cellpadding="0" cellspacing="0" width="162"> <tr><td height="29" style="background:url("/Custom/Top2.png");color:#116111;" align="center"><b>Newest Tutorial</b></td></tr> <tr><td height="160" style="background:url("/Custom/Middle2.png") #000000;padding:5px 5px 0 5px;">$MYINF_8$</td></tr> <tr><td><img src="/Custom/Bottom2.png" border="0"></td></tr> </table> </td>'); } //--> </script> It is supposed to detect if someone has a widescreen monitor, and then add the extra box if it is widescreen. For some unknown reason, its not working. No extra box appears. Does anyone know where I went wrong? Edit: $MYINF_8$ is what goes inside the box. I think that if there is more space between the columns that it would be easier to read, but whatever I try is not working. Just putting tabs between them is my latest idea, however, the space is not all that big. Is it possible that I have entered it wrong? Thank you, the code is below: <html> <head> <title>Exercise</title> <script type = "text/javascript"> <!-- var row = 0; var cols = 0; var sum = (row + 1); if (row ==0) { document.write("sum   square   cube"); document.write("<br>"); row++; } while((row >= 0) && (row <= 11)) { document.write(row + "\t" + (row * row) + "\t" + (row * row * row)); document.write("<br>"); row++; } // --> </script> </head> <body> <p>what? seriously, this is working?</p> </body> </html> Can you please take a look at this and tell me why it is not getting all the way thru the function and why this is not working totally. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <title>Untitled Document</title> <script type="text/javascript"> function cabFair(start, end, time){ var base = 0; if (start = 1){ if (end = 1){ base = 5; }if (end = 2) { base = 7; }base = 8; }if (start = 2){ if (end = 1){ base = 7; }if (end = 2) { base = 5; }base = 9; }if (end = 1){ base = 8; }if (end = 2) { base = 9; }base = 5; //return(base); if (time > 20){ time1 = (time - 20); time2 = (time1 * (.3)); finalTime = (time2 + 10); }if (time > 10 && time <= 20){ time1 = (time - 10); time2 = (time1 * (.4)); finalTime = (time2 + 6); }if (time >4 && time <= 10){ time1 = (time - 4); time2 = (time1 * (.5)); finalTime = (time2 + 3); }finalTime = (time * .75); var fare = finalTime + base; return fare } </script> </head> <body> <script type="text/javascript"> //Ask user for input var start = parseInt(prompt("Enter the Starting Point", "1")); var end = parseInt(prompt("Enter the Ending Point", "2")); var time = parseInt(prompt("Enter the Total Time", "4")); //output for information document.writeln(cabFair(start, end, time) + " Is the Total Fare."); </script> </body> </html> Won't validate help...pasor error? Wtf i suck at this. Code: <?xml version="1.0" encoding="UTF-8"?> <!--Prolog Above--> <!--dataset is the name of the Root Element--> <!--Artist, Album, and, Publisher are the names of the namespaces, Ar, Al, and, Pu are the prefixes--> <dataset xmlns:Al="Album" xmlns:Ar="Artist" xmlns:Pu="Publisher" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <!--Elements, blank text is data--> <dataset> <Al:Album> <Al:Album ID =""> <Al:Genre =""></Al:Genre> <Al:AmountSold =""></Al:AmountSold> <Al:PublishDate =""></Al:PublishDate> <Al:Artist =""></Al:Artist> </Al:Album> </Al:Album> <Ar:Artist> <Ar:Artist ID =""> <Ar:Awards =""></Ar:Awards> <Ar:Location =""></Ar:Location> <Ar:Region =""></Ar:Region> <Ar:LabelID =""></Ar:LabelID> </Ar:Artist> </Ar:Artist> <Pu:Publisher> <Pu:Publisher ID =""> <Pu:AmountSold =""></Pu:AmountSold> <Pu:Artist = ""></Pu:Artist> <Pu:PublishDate =""></Pu:PublishDate> <Pu:Manager = ""></Pu:Manager> </Pu:Publisher> </Pu:Publisher> </dataset> |