JavaScript - Html To Js To Php To Mysql Problem///
Hi all,
I'm having some issues with getting a html form to send data through to my MYSQL database. JS is the one part of the script that I'm least sure about, so I assume the issue lies there... All the data from the text fields in the form go through to the MySQL table fine, but the data from the drop down box and checkbox doesn't make it... So, the html dropdown and checkbox code from the form is: Code: <label for="lettertype" id="lettertype_label">I want my letter to be: </label><br> <select id="lettertype" name="lettertype"> <option value="0"></option> <option value="public">Public, though Anonymous</option> <option value="private">Private</option> </select><br> <label class="error" for="lettertype" id="lettertype_error">Would you like your letter to be public or private?</label> <br> <label for="terms" id="terms_label">I understand thde terms and agreements...</label><br> <input type="checkbox" name="terms" value="Yes" /><br> <label class="error" for="terms" id="terms_error">We know no one ever reads these things, but we need to you at least pretend...</label> When submit is clicked, it calls the following javascript: Code: $(function() { $('.error').hide(); $('input.text-input').css({backgroundColor:"#F6F6F6"}); $('input.text-input').focus(function(){ }); $('input.text-input').blur(function(){ $(this).css({backgroundColor:"#F6F6F6"}); }); $(".button").click(function() { // validate and process form // first hide any error messages $('.error').hide(); var letter = $("textarea#letter").val(); if (letter == "") { $("label#letter_error").show(); $("textarea#letter").focus(); return false; } var firstname = $("input#firstname").val(); if (firstname == "") { $("label#firstname_error").show(); $("input#firstname").focus(); return false; } var surname = $("input#surname").val(); if (surname == "") { $("label#surname_error").show(); $("input#surname").focus(); return false; } var email = $("input#email").val(); if (email == "") { $("label#email_error").show(); $("input#email").focus(); return false; } var lettertype = $("select#lettertype").val(); if (lettertype == "0") { $("label#lettertype_error").show(); $("select#lettertype").focus(); return false; } var terms = $("input#terms").val(); if (terms == "") { $("label#terms_error").show(); $("input#terms").focus(); return false; } var dataString = '&letter=' + letter + '&firstname='+ firstname + '&surname=' + surname + '&email=' + email + '&lettertype' + lettertype + '&terms' + terms; //alert (dataString);return false; $.ajax({ type: "POST", url: "../php/emailform.php", data: dataString, success: function() { $('#replace').html("<div id='message'></div>"); $('#message').html("<br>") .append("") .hide() .fadeIn(1500, function() { $('#message').append("<img id='mailconfirm' src='images/mailconfirm.png' /><br><br>"); }); } }); return false; }); }); runOnLoad(function(){ $("input#firstname").select().focus(); }); Then in terms of the PHP script, this is the excerpt: Code: $letter = $_POST['letter']; $firstname = $_POST['firstname']; $surname = $_POST['surname']; $email = $_POST['email']; $lettertype = $_POST['lettertype']; $terms = $_POST['terms']; $timestamp = date( 'Y-m-d'); $sql = "INSERT INTO ToBeEmailed (letter, firstname, surname, email, lettertype, terms, timestamp) VALUES ('$letter', '$firstname', '$surname', '$email', '$lettertype', '$terms', '$timestamp')"; If anyone could offer any advice that'd be great! Cheers in advance... Similar TutorialsHello, I'm dynamically outputting the contents of a MySQL table using Python, to a HTML table, which users view (obviously) through a web browser. It looks great, but the problem is that I'd like users to be able to update these values. For example, I have the current value of certain fields in text boxes. I'd like users to be able to change those values, then hit a submit button or similar (ideally on-the-fly) to update the dB. I imagine javascript will need to pass values to a Python script, but I don't know what the best way to go about this is. The table is generated with a loop like so: Code: # Python code embedded in a .psp file cursor = db.cursor() cursor.execute("SELECT from_name, from_address, project, orb_proj, app, tier, environment, network, security_zone, datacenter, server_type, num_servers, date, status FROM requests") rows = cursor.fetchall() for row in rows: new_row = """ <td>%s<br></td> ... (line repeated for each column) """ % row[0:15] req.write(new_row) Any ideas? Maybe this whole thing should be rewritten in something else. Thanks! 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> <title>Untitled Page</title> <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 <br /> message will be displayed. Only when you enter something into the <br /> 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" onclick="return send_onclick(frmName)"> </form> </body> </html> Hi there, I would like to know the purpose of having var bolSubmit in the code above. Also, why is it that "form name" allows my code to work even though there is a warning stating that it is outdated, but when I change it from "form name" to "form id", it does not complain of the warning anymore, but instead my code does not work. Please advise. I have two versions of this document. The first version uses only JavaScript and the standard PROMPT(). It works very well, but I would like to insert the name prompt into the page using the input command. For some reason the variable loaded in the HTML statement doesn't get passed to the JavaScript. Any ideas would be appreciated! This is only a small test page. Sorry I don't know about the [code] tag... <!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <meta name="generator" content="CoffeeCup HTML Editor (www.coffeecup.com)"> <meta name="created" content="Sat, 10 Sep 2011 19:40:31 GMT"> <meta name="description" content=""> <meta name="keywords" content=""> <title>Enter golfers name</title> <!--[if IE]> <script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script> <![endif]--> <SCRIPT LANGUAGE="JavaScript" type="text/javascript" src="script1.js"></SCRIPT> <SCRIPT LANGUAGE="JavaScript"> function GetPage(){ document.write("OK") var lab = ""; var result = fullname.toUpperCase(); var word=result.split(" "); fname = word[0] lname = word[1] alpha = lname.slice(0,1); lab = fname.concat("_") lab = lab.concat(lname) if(word[2]){ ext = word[2] lab = lab.concat("_") lab = lab.concat(ext) } var intro = "./Stats_"; page = intro.concat(alpha); page = page.concat("_golfers.html#"); page = page.concat(lab) document.write(page) <!-- window.location.pathname = page } </script> </head> <body> <center> <form action="form_action.asp" method="get"> You can enter the golfersname or select him from the above list.<br><br> <input type="text" name="fullname" /> <button type="submit" onclick="GetPage()">GO</button> </form> </center> <BR><BR><BR> This is the end </body> </html> Hello, I am nearing completion on the modification of a Javascript/Html Order Form. The problem arises when I click on 'Submit Order' after filling in details and choosing a product. For some reason, the pop up box shows the correct product, but it shows the $ Total from the previous box in the table. Thank you all for your time in looking into this: Code: <html> <head> <title>JS Order</title> <script language="JavaScript"> <!-- Start hiding from older browsers. // This function displays the nag screen when a field hasn't been filled in. function nag(form, field, x) { ufield=field.toUpperCase(); alert("Details missed " + ufield + "!" + "\n\nPlease fill in the field and submit the form again."); form.elements[x].focus(); } // This function is used to round the tax amount to the nearest hundreths. function roundPrice(price) { // save a copy of the price in case it is an even dollar amount. var workPrice = price; // Make the price a string by adding a string 0 to the end. workPrice += "0"; // Find out where the decimal point is. var pointIndex = workPrice.indexOf(".",0); // If there is a decimal point now check to see if it needs to be rounded up. if (pointIndex >= "0") { // Set an index for the thousands digit. var thousands = pointIndex +3; // if the third number past the decimal point is greater than or // equal to 5, then we need to round up the hundredth digit. if (workPrice.charAt(thousands) >= "5") { // Turn the price into a number. workPrice=parseFloat(price); // Round up the price. workPrice=workPrice + .01; // Turn it back into a string. workPrice=workPrice + "0"; // Cut off the thousands on down. rPrice = workPrice.substring(0,thousands); } else { // We didn't need to round the price up so cut off the // thousands on down and return the price rPrice = workPrice.substring(0,thousands); } // Its an even dollar amount so just put on the .00 on the end. } else { rPrice = price + ".00"; } // Now return the rounded price. return rPrice; } // This function calculates the form. function updatePrice() { // Reset the subtotal price var addPrice = 0; // Reset the running total prices. var nowPrice = 0; // Reset the nubmer of part ordered. var partcount = 0; // Step through each element in the form. for (i = 0; i < parseInt(self.document.forms[0].elements.length); i++) { // If the form element has "qty" in the name then we need to process it. if (self.document.forms[0].elements[i].name.substring(0,3) == 'qty') { // If the item has a quantity of not 0, then we need to process it. if (self.document.forms[0].elements[i].value != 0) { // Locate the cost costIndex = i + 1; // Increment the part counter. partcount++; // Get the actual value for the quantity. nowQty = eval(self.document.forms[0].elements[i].value); // Get the cost of the item. nowPrice = eval(self.document.forms[0].elements[costIndex].value); // Calculate the extended cost (i.e., quanty * cost). nowPrice = eval(nowPrice * nowQty); // Add to the subtotal. addPrice += nowPrice; } } } // Round off the subTotal price. subTotal=roundPrice(addPrice); // Put the sub total price into the form. self.document.forms[0].subtot.value = subTotal; // Figure the tax. tax = parseFloat(self.document.forms[0].taxrate.value * addPrice); // Round off the tax price. totalTax = roundPrice(tax); // Put the total tax into the form. self.document.forms[0].totaltax.value = totalTax; // Start figuring the total including tax. // Turn the price string into a number. subPrice = parseFloat(addPrice); // Turn the tax string into a number. addTax = parseFloat(totalTax); // Add the tax and subtotal to get the total price. totalPrice = (addTax + subPrice); // Round the total price. finalPrice = roundPrice(totalPrice); // Update the form with the total cost. self.document.forms[0].cost.value = finalPrice; // Update the form with the number of line items. self.document.forms[0].items.value = partcount; } function orderIt(form) { // If the order is zero, display a message. if (form.cost.value == "0.00") { alert("You have not ordered anything. Please select an item and re-submit your order.") } else { if (form.elements[0].value == "") { nag(form, form.elements[0].name,0) } else if (form.elements[1].value == "") { nag(form, form.elements[1].name, 1) } else if (form.elements[2].value == "") { nag(form, form.elements[2].name, 2) } else if (form.elements[4].value == "") { nag(form, form.elements[4].name, 4); } else if (form.elements[5].value == "") { nag(form, form.elements[5].name, 5); } else if (form.elements[6].value == "") { nag(form, form.elements[6].name, 6); } else if (form.elements[10].value == "") { nag(form, form.elements[10].name, 10); } else { var message = "You have ordered the following items:\n"; message = message + "Qty\tCost\tDescription\n"; // Step through each element in the form. for (i = 0; i < parseInt(self.document.forms[0].elements.length); i++) { // If the form element has "qty" in the name then we need to process it. if (self.document.forms[0].elements[i].name.substring(0,3) == 'qty' && self.document.forms[0].elements[i].value !=0) { // Get the quantity. qtyItem = self.document.forms[0].elements[i].value; costItem = self.document.forms[0].elements[i-2].value; // Get the description. descItem = self.document.forms[0].elements[i-1].value; // add the line item to the confirmation message. message = message + qtyItem + "\t" + costItem + "\t" + descItem + "\n"; } } message = message + "\nOrder total: $" + self.document.forms[0].cost.value if (confirm(message)) { self.document.forms[0].submit(); } } } } // end hiding from older browsers --> </script> </head> <body bgcolor="white" text="black" alink="red" vlink="purple" link="blue" background="images/bkgrd.gif"> <p> <table width=440> <tr><td> <p> <form name=options method=post action="/cgi-bin/order.cgi"> <table border="0" width="100%" id="table1"> <tr> <td width="109" align="right"><font face="Arial" size="2"> First Name:</font></td> <td width="15"> </td> <td align="left"><font size="1" face="Arial"> <input type=text name=FirstName size=30 maxlength=40></font></td> </tr> <tr> <td width="109" align="right"><font face="Arial" size="2">Last Name:</font></td> <td width="15"> </td> <td align="left"><font size="1" face="Arial"> <input type=text name=LastName size=30 maxlength=40></font></td> </tr> <tr> <td width="109" align="right"><font face="Arial" size="2">Address Line 1:</font></td> <td width="15"> </td> <td align="left"><font size="1" face="Arial"> <input type=text name=Address1 size=40 maxlength=40></font></td> </tr> <tr> <td width="109" align="right"><font face="Arial" size="2">Address Line 2:</font></td> <td width="15"> </td> <td align="left"><font size="1" face="Arial"> <input type=text name=Address2 size=40 maxlength=40></font></td> </tr> <tr> <td width="109" align="right"><font face="Arial" size="2">Suburb:</font></td> <td width="15"> </td> <td align="left"><font size="1" face="Arial"> <input type=text name=Suburb size=25 maxlength=40></font></td> </tr> <tr> <td width="109" align="right"><font face="Arial" size="2">City:</font></td> <td width="15"> </td> <td align="left"><font size="1" face="Arial"> <input type=text name=City size=25 maxlength=40></font></td> </tr> <tr> <td width="109" align="right"><font face="Arial" size="2">Postal Code:</font></td> <td width="15"> </td> <td align="left"><font size="1" face="Arial"> <input type=text name=PostalCode size=15 maxlength=40></font></td> </tr> <tr> <td width="109" align="right"><font face="Arial" size="2">Country:</font></td> <td width="15"> </td> <td align="left"><font size="1" face="Arial"> <input type=text name=Country size=15 maxlength=40 value=NZ></font></td> </tr> <tr> <td width="109" align="right"><font face="Arial" size="2">Home Phone:</font></td> <td width="15"> </td> <td align="left"><font size="1" face="Arial"> <input type=text name=HomePhone size=20 maxlength=40></font></td> </tr> <tr> <td width="109" align="right"><font face="Arial" size="2">Mobile Phone:</font></td> <td width="15"> </td> <td align="left"><font size="1" face="Arial"> <input type=text name=MobilePhone size=20 maxlength=40></font></td> </tr> <tr> <td width="109" align="right"><font face="Arial" size="2">E-Mail Address:</font></td> <td width="15"> </td> <td align="left"><font size="1" face="Arial"> <input type=text name=EmailAddress size=30 maxlength=40></font></td> </tr> <tr> <td width="109" align="right"><font face="Arial" size="2">Domain Name:</font></td> <td width="15"> </td> <td align="left"><font size="1" face="Arial"> <input type=text name=DomainName size=30 maxlength=40></font></td> </tr> </table><br> <font face="Arial" size="2">Enter a quantity of 1 into the package you require.<br><br> Monthly payments incur a $2 per month administration fee. Set up is <b>free</b> for all packages (for a limited time).</font><br><br> <table border=1 cellpadding=2 width="500" bordercolorlight="#808080"> <tr> <th><font face="Arial" size="2">Description</font></th> <th><font face="Arial" size="2">Qty</font></th> <th><font face="Arial" size="2">Total</font></th> </tr> <tr> <td align=center><font size="1" face="Arial"><input type=hidden name="desc1" value="Basic Monthly"> </font><font face="Arial" size="2">Basic Package <BR><B> Pay Monthly</B></font></td> <td align=center><font size="1" face="Arial"><input type=text name="qty1" size=3 maxlength=3 value="0" onchange="updatePrice()"></font></td> <td align=center><font size="1" face="Arial"><input type=hidden name="cost1" value="11.99"> </font><font face="Arial" size="2">$11.99</font></td> </tr> <tr> <td align=center><font size="1" face="Arial"><input type=hidden name="desc2" value="Basic PrePay 1 Year"> </font><font face="Arial" size="2">Basic Package - $9.99 per month<BR><B> Pre-pay 12 mths (1 month free limited offer) </B> </font></td> <td align=center><font size="1" face="Arial"><input type=text name="qty2" size=3 maxlength=3 value="0" onchange="updatePrice()"></font></td> <td align=center><font size="1" face="Arial"><input type=hidden name="cost2" value="109.89"> </font><font face="Arial" size="2">$109.89</font></td> </tr> <tr> <td align=center><font size="1" face="Arial"><input type=hidden name="desc3" value="Basic PrePay 2 Years"> </font><font face="Arial" size="2">Basic Package - $8.99 per month<BR><B> Pre-pay 24 mths (2 months free limited offer) </B> </font></td> <td align=center><font size="1" face="Arial"><input type=text name="qty3" size=3 maxlength=3 value="0" onchange="updatePrice()"></font></td> <td align=center><font size="1" face="Arial"><input type=hidden name="cost3" value="197.78"> </font><font face="Arial" size="2">$197.78</font></td> </tr> <tr> <td align=center><font size="1" face="Arial"><input type=hidden name="desc4" value="Basic PrePay 3 Years"> </font><font face="Arial" size="2">Basic Package - $7.99 per month<BR><B> Pre-pay 36 mths (3 months free limited offer) </B> </font></td> <td align=center><font size="1" face="Arial"><input type=text name="qty4" size=3 maxlength=3 value="0" onchange="updatePrice()"></font></td> <td align=center><font size="1" face="Arial"><input type=hidden name="cost4" value="263.67"> </font><font face="Arial" size="2">$263.67</font></td> </tr> <tr> <td align=center><font size="1" face="Arial"><input type=hidden name="desc13" value="Deluxe Monthly"> </font><font face="Arial" size="2">Deluxe Package<BR><B> Pay Monthly</B></font></td> <td align=center><font size="1" face="Arial"><input type=text name="qty13" size=3 maxlength=3 value="0" onchange="updatePrice()"></font></td> <td align=center><font size="1" face="Arial"><input type=hidden name="cost13" value="21.99"> </font><font face="Arial" size="2">$21.99</font></td> </tr> <tr> <td align=center><font size="1" face="Arial"><input type=hidden name="desc14" value="Deluxe PrePay 1 Year"> </font><font face="Arial" size="2">Deluxe Package - $19.99 per month<BR><B> Pre-pay 12 mths (1 month free limited offer) </B> </font></td> <td align=center><font size="1" face="Arial"><input type=text name="qty14" size=3 maxlength=3 value="0" onchange="updatePrice()"></font></td> <td align=center><font size="1" face="Arial"><input type=hidden name="cost14" value="219.89"> </font><font face="Arial" size="2">$219.89</font></td> </tr> <tr> <td align=center><font size="1" face="Arial"><input type=hidden name="desc15" value="Deluxe PrePay 2 Years"> </font><font face="Arial" size="2">Deluxe Package - $18.99 per month<BR><B> Pre-pay 24 mths (2 months free limited offer) </B> </font></td> <td align=center><font size="1" face="Arial"><input type=text name="qty15" size=3 maxlength=3 value="0" onchange="updatePrice()"></font></td> <td align=center><font size="1" face="Arial"><input type=hidden name="cost15" value="417.78"> </font><font face="Arial" size="2">$417.78</font></td> </tr> <tr> <td align=center><font size="1" face="Arial"><input type=hidden name="desc16" value="Deluxe PrePay 3 Years"> </font><font face="Arial" size="2">Deluxe Package - $17.99 per month<BR><B> Pre-pay 36 mths (3 months free limited offer) </B> </font></td> <td align=center><font size="1" face="Arial"><input type=text name="qty16" size=3 maxlength=3 value="0" onchange="updatePrice()"></font></td> <td align=center><font size="1" face="Arial"><input type=hidden name="cost16" value="593.67"> </font><font face="Arial" size="2">$593.67</font></td> </tr> </table> <font face="Arial" size="2"> <br> </font> <table border=1 cellpadding=2 width="500" bordercolorlight="#808080"> <tr> <td align=center><font size="1" face="Arial"><input type=hidden name="desc17" value="Blogging Software Installation Service"> </font><font face="Arial" size="2">Installation Service<BR><B> Blogging software (Wordpress etc)</B></font></td> <td align=center width="39"><font size="1" face="Arial"><input type=text name="qty17" size=3 maxlength=3 value="0" onchange="updatePrice()"></font></td> <td align=center width="63"><font size="1" face="Arial"><input type=hidden name="cost18" value="39.00"> </font><font face="Arial" size="2">$39.00</font></td> </tr> <tr> <td align=center><font size="1" face="Arial"><input type=hidden name="desc19" value="Shopping Cart Installation Service"> </font><font face="Arial" size="2">Installation Service<BR><B> Shopping Cart (ZenCart, osCommerce, Cubecart etc)</B></font></td> <td align=center width="39"><font size="1" face="Arial"><input type=text name="qty19" size=3 maxlength=3 value="0" onchange="updatePrice()"></font></td> <td align=center width="63"><font size="1" face="Arial"><input type=hidden name="cost19" value="349.00"> </font><font face="Arial" size="2">$349.00</font></td> </tr> </table> <p> <table width=500> <tr> <td align=right> <div align="left"> <table cellpadding=1 cellspacing=1> <tr> <td colspan=2 align=right><font face="Arial" size="2">Sub Total: $</font><font size="1" face="Arial"><input name=subtot value="0.00" size=10 maxlength=10 onChange="updatePrice()"></font></td> </tr> <tr> <td valign=bottom><font size="1" face="Arial"><input type=hidden value=".15" name=taxrate size=5 maxlength=5 onchange="updatePrice()"> </font></td> <td align=right><font face="Arial" size="2">GST: $</font><font size="1" face="Arial"><input type=text name=totaltax size=10 maxlength=10 value="0.00" onChange="updatePrice()"></font></td> </tr> <tr> <td colspan=2 align=right><font face="Arial" size="2">Total Order: $</font><font size="1" face="Arial"><input name="cost" type=text value="0.00" size=10 maxlength=10 onChange="updatePrice(this.form)"><input type=hidden maxlength=4 size=4 name=items></font></td> </tr> </table> </div> <p> <font size="1" face="Arial"> <input type=button value="Submit Order" onClick="orderIt(this.form);" style="float: left"></font><font face="Arial" size="2"> </font><font size="1" face="Arial"> <input type=reset value="Clear Order" style="float: left"><font face="Arial" size="2"> </form> </font></font> </center> </body> </html> I need some help making a button function do what I want it to do. I have a index page that shows all my projects in a table with tabs you can click on that shows certain parts of all projects (ie tab for finance, project title). For now, every single project is shown on the website when you bring up the index page. Also the top part of the page, where I have the issue, there is a drop down list of all the projects with a "GO" button next to it. I want a user to be able to scroll down that list and click the button and the page would only show that particular project, ie choosing the tabs to go back and forth dealing with the one project only. The tabs are each its own .php file with the exact coding in all of them. Here is what I have on my index page that I need help on in order to make this button work. Any help will be appreciated. My main issue is this coding Code: <input type="button" value="GO" name="proj_list" /> But here is the whole index page Code: <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>2009 Events</title> <link rel="stylesheet" type="text/css" href="../css/dddropdownpanel.css" /> <link rel="stylesheet" type="text/css" href="../css/sortable.css" /> <link rel="stylesheet" type="text/css" href="../css/datepicker.css" /> <link rel="stylesheet" type="text/css" href="../css/main.css" /> <link rel="stylesheet" type="text/css" href="../css/chromestyle.css" /> <link rel="stylesheet" type="text/css" href="../css/ajaxtabs.css" /> <script type="text/javascript" src="../includes/datepicker.js"></script> <script language="javascript" src="../includes/tablesort.js"></script> <script language="javascript" src="../includes/tableActions.js"></script> <script language="javascript" src="../includes/chrome.js"></script> <script language="javascript" src="../includes/ajaxtabs.js"></script> </head> <body> <div id="container"> <div id="header"> <?php include("../header.php"); ?> </div> <div id="navbar2"> <?php include("../menu.php"); ?> </div> <div id="content"> <div id="breadcrumb"> <script language="javascript" src="../includes/breadcrumbs.js"></script> </div> <?php // If the user wants to add a project if (isset($addproject)): else: $dbcnx = @mysql_connect("xxxxx", "xxxxxx", "xxxxxxxx"); if (!$dbcnx) { echo( "<P>Unable to connect to the xxxxxxxxx" . "database server at this time.</P>" ); exit(); } mysql_select_db("techweb", $dbcnx); if (! @mysql_select_db("techweb") ) { echo( "<P>Unable to connect to the xxxxxxx" . "database at this time.</P>" ); exit(); } // If a project has been submitted, // add it to the database. if ("SUBMIT" == $proj_submit) { $sql = "INSERT INTO projects SET " . "proj_priority='$priority', " . "proj_title='$title', " . "proj_bdlead='$bdlead', " . "proj_englead='$englead', " . "proj_objective='$objective', " . "proj_capability='$capability', " . "proj_approach='$approach', " . "proj_venue='$venue', " . "proj_tradeshow='$tradeshow', " . "proj_funding='$funding', " . "proj_src-ds='$src-ds', " . "proj_src-cap='$src-cap', " . "proj_src-irad='$src-irad', " . "proj_status='$status', " ; if (mysql_query($sql)) { echo("<P>Your project has been added.</P>"); } else { echo("<P>Error adding submitted project: " . mysql_error() . "</P>"); } } echo("<h1 style='text-align:left'> 2009 Projects </h1>"); // Request the text of all the projects $result = mysql_query( "SELECT * FROM projects"); if (!$result) { echo("<P>Error performing query: " . mysql_error() . "</P>"); exit(); } ?> <form id="projects" method="post" action="project.php"> <select id="project_list" name="proj_list"> <optgroup label="projects"> <?php // Display the details of each event in a table while ( $option = mysql_fetch_array($result) ) { echo("<option label=" . $option["proj_title"] . "value=" . $option["ID"] . ">" . $option["proj_title"] . "</option>"); } ?> </optgroup> </select> <input type="button" value="GO" name="proj_list" /> <? endif; ?> <div id="tabcontainer"> <ul id='tabs' class='shadetabs'> <?php // Populate tabs with data related to the selected project echo ("<li><a href='project.php' rel='container' class='selected'>Project</a></li>"); echo ("<li><a href='capability.php' rel='container'>Demo Capability</a></li>"); echo ("<li><a href='approach.php' rel='container'>Approach</a></li>"); echo ("<li><a href='venue.php' rel='container'>Venue/Trade Shows</a></li>"); echo ("<li><a href='financials.php' rel='container'>Financials</a></li>"); ?> </ul> <!-- <ul id='tabs' class='shadetabs'> <li><a href='project.php' rel='container' class='selected'>Project</a></li> <li><a href='capability.php' rel='container'>Demo Capability</a></li> <li><a href='approach.php' rel='container'>Approach</a></li> <li><a href='venue.php' rel='container'>Venue/Trade Shows</a></li> <li><a href='financials.php' rel='container'>Financials</a></li> </ul> --> <div id="divcontainer" style="border:1px solid gray; width:600px; margin-bottom: 1em; padding: 5px"> <p>Please select a project using the drop-down menu above. Use the tabs to view information about the selected project.</p> </div> <script type="text/javascript"> var countries=new ddajaxtabs("tabs", "divcontainer") countries.setpersist(true) countries.setselectedClassTarget("link") //"link" or "linkparent" countries.init() </script> </div> i have the code: foreach($product_names as $product_row) { ?> <tr> <td > </td><td width='200px'><?php echo $product_row->getName();?></td> <td width='200px'><input type="checkbox" name="graphic[]" value="<?php echo $product_row->getId();?>" onclick="check()"/></td> <td width='200px'><input type="checkbox" name="text[]" value="<?php echo $product_row->getId();?>" onclick="check()"/></td> </tr> <?php } ?> and a submit button on the page. the i also have the javascript code for the onclick="check()" : <html> <head> <script type="text/javascript"> function check() { var graphics = document.getElementsByName("graphic[]"); for(i=0;i<graphics.length;i++) { if(graphics[i].checked) { if(document.getElementById('submit').style.display=='none') { document.getElementById('submit').style.display='block'; } } } var text = document.getElementsByName("text[]"); for(i=0;i<text.length;i++) { if(text[i].checked) { if(document.getElementById('submit').style.display=='none') { document.getElementById('submit').style.display='block'; } } } } </script> </head> so what all this means is i have two arrays of checkboxes for each product. as soon as i check any checkbox the submit button appears. i click on the submit button and i go to the next form. the problem now comes in if i click on the "back" button to go back to the previous page via the bwrowser..the submit button is disabled althou all my checkboxes that i checked, are still checked....i want the submit button to show??? please help?? thanks Hi, I am new to javascript, Please help me with the issue below. My javascript code below should actually fetch the data from html table on button click. function displaymessage() { alert ("button pressed"); var table_cells = new Array(); var table7 = document.getElementById('Auth'); for (i=0,n=table7.rows.length; i < n ; i++) { var Rowdata = table7.rows[i]; table_cells[i] = new Array(); for(j=0,cols = Rowdata.cells.length; j < cols; j++) { table_cells[i,j] = Rowdata.cells[j].innerHTML; alert (table_cells[i,j]); } } alert (table_cells[1,1]); alert (table_cells[2,1]); alert (table_cells[3,1]); alert (table_cells[4,1]); alert (table_cells[5,1]); alert (table_cells[6,1]); alert (table_cells[7,1]); alert (table_cells[8,1]); } The problem with my code above is that the statement "alert (table_cells[i,j]);" executes properly and shows the correct value. But the other alert statements shows only the value of the last row of the table. i.e., my table has 9 rows. and all the alert statements shows 9th row's 2nd column's value outside the for loop. But inside the for loop it executes fine. I tried it in IE7. I seem to miss something. Could someone please help me out with this? Thanks in advance. I'm almost finished with this app for XUL / HTML Table Generation, and i have a really strange problem... The HTML strings in the Arrays can be changed, and the HTML file saved, and the HTML page reloaded, and the changes will render. However, i have one array, no matter what i change the HTML strings to, it refuses to render the changes made to the HTML strings. It's quite confusing... the array in question is Code: // Humidor InnerHTML HumidorInnerHTML[0] = "<img src='NoImage.gif' style='height:100px; width:100px;'>"; HumidorInnerHTML[1] = "<input type='textbox' id='Others_Caption" + HumidorIndex + "'>"; HumidorInnerHTML[2] = "<input type='textbox' value='85' id='Others_Height" + HumidorIndex +"'>"; HumidorInnerHTML[3] = "<input type='textbox' value='85' id='Others_Width" + HumidorIndex +"'>"; HumidorInnerHTML[4] = "<img src='NoImage.gif' style='height:100px; width:100px;'>"; HumidorInnerHTML[5] = "<img src='NoImage.gif' style='height:100px; width:100px;'>"; HumidorInnerHTML[6] = "<img src='delete.png' onClick=DeleteRow('" + HumidorIndex + "','Humidor_Table');>"; HumidorInnerHTML[7] = "<img src='add.png' onClick=AddRow('" + HumidorIndex + "','Humidor_Table');>"; and the function that generates the HTML Table on the fly (and adds the cell data to them) is he Code: function AddRow(index, DIV) { MyTable = document.getElementById(DIV); var newCell; var newRow = MyTable.insertRow(index); var Length; switch (DIV) { case "Intro_Table" : Length = IntroInnerHTML.length; break; case "Image_Table" : Length = ImageInnerHTML.length; break; case "Watch_Table" : Length = WatchInnerHTML.length; break; case "Others_Table" : Length = OthersInnerHTML.length; break; case "Humidor_Table" : Length = HumidorInnerHTML.length; break; } for (var i = 0; i < Length; i++) { newCell = newRow.insertCell(i); switch (DIV) { case "Intro_Table": newCell.innerHTML = IntroInnerHTML[i]; break; case "Image_Table": newCell.innerHTML = ImageInnerHTML[i]; break; case "Watch_Table": newCell.innerHTML = WatchInnerHTML[i]; break; case "Others_Table": newCell.innerHTML = OthersInnerHTML[i]; break; case "Humidor_Table": newCell.innerHTML = WatchInnerHTML[i]; break; } } // Update the Index Counters switch (DIV) { case "Intro_Table": IntroIndex++; break; case "Image_Table": ImageIndex++; break; case "Watch_Table": WatchIndex++; break; case "Others_Table": OthersIndex++; break; case "Humidor_Table": HumidorIndex++; break; } } when the page is loaded, the Init() function is started, that code is he Code: function Init() { AddRow(1, "Intro_Table"); AddRow(1, "Image_Table"); AddRow(1, "Watch_Table"); AddRow(1, "Humidor_Table"); AddRow(1, "Others_Table"); } Did i miss something? there must be something i've over looking. I have even tried isolating some other external JS, and CSS includes that i have, and isolating them has no change in the result. the html file is live he http://kevinjohnson.clanteam.com/XML...anageSite.html thanks Hi Chaps, I have a Javascript ActiveX function that exports the contents of an HTML table into MS Excel. The script works fine, however, some of the dates have changed from dd/mm/yyyy to mm/dd/yyyy. I do not know why this is happening, especially as it's only to a few. Here is the code: Code: <script language="javascript" type="text/javascript"> function ExportToExcel() { input_box=confirm("Export to Microsoft Excel?"); if (input_box==true) { var xlApp = new ActiveXObject("Excel.Application"); // Silent-mode: xlApp.Visible = true; xlApp.DisplayAlerts = false; var xlBook = xlApp.Workbooks.Add(); xlBook.worksheets("Sheet1").activate; var XlSheet = xlBook.activeSheet; XlSheet.Name="Report"; // Store the sheet header names in an array var rows = tblreport_work.getElementsByTagName("tr"); var columns = tblreport_work.getElementsByTagName("th"); var data = tblreport_work.getElementsByTagName("td"); // Set Excel Column Headers and formatting from array for(i=0;i<columns.length;i++){ XlSheet.cells(1).value= "Projects - Open"; XlSheet.cells(3,i+1).value= columns[i].innerText; //XlSheetHeader[i]; XlSheet.cells(3,i+1).font.color="6"; XlSheet.cells(3,i+1).font.bold="true"; XlSheet.cells(3,i+1).interior.colorindex="37"; XlSheet.Range("B1:F1000").HorizontalAlignment = -4108; XlSheet.Range("H1:H1000").HorizontalAlignment = -4108; XlSheet.Range("J1:J1000").HorizontalAlignment = -4108; } //run over the dynamic result table and pull out the values and insert into corresponding Excel cells var d = 0; for (r=4;r<rows.length+3;r++) { // start at row 2 as we've added in headers - so also add in another row! for (c=1;c<columns.length+1;c++) { XlSheet.cells(r,c).value = data[d].innerText; d = d + 1; } } //autofit the columns XlSheet.columns.autofit; // Make visible: xlApp.visible = true; xlApp.DisplayAlerts = true; CollectGarbage(); //xlApp.Quit(); } } </script> Date Columns: F,G,I If anyone has some ideas on how to correct this, I'd be most grateful! /** The <a> is a list of menu items that when clicked.... a specific gallery-slider-images should been shown in relation to the galleryId....<div class"gallery" is hidden in CSS> I'd like to use jQuery to complete this task if at all possible, I know it's prob SIMPLE to U GURU's but being new i can't seem to .show() the selected 'gallery' w/o showing them all........... BEST REGARDS _ STH <div id="gallery-menu"> <?php foreach ($galleries as $gallery) : ?> <a onclick="showGallery(<?= $gallery['gallery']['id'] ?>); return false;"><?= $gallery['gallery']['name'] ?> <?php endforeach ?> </div> <?php foreach ($galleries as $gallery): ?> <div id="<?= $gallery['gallery']['id'] ?>" class="gallery"> <div class="slider" style="width; 100%; height: 100%;"> <ul> <?php foreach ($gallery['images'] as $image): ?> <li class="galleries-container"> <img src="<?= UCMVC_APP_BASE_URL ?>/gallery/retrieve-image/<?= $image['id'] ?>" alt="<?= $image['name'] ?>" title="<?= $image['name'] ?>" /> </li> <?php endforeach; ?> </ul> </div> </div> <?php endforeach; ?> // javascript // function showGallery(galleryId) { ????!?!?!?!?! } favorite I'd like to modify a form on www.formsite.com (form builder app): username: testuser password: password I would like to use the nicedit.com's inline content editor's js to transform my textarea's into a richtext area. At present the nicedit editor works well in creating the richtextarea. However, the KEY point is that I would like formsite's form to pipe in the the created html and render it with the html component of formsite. Currently, the pipe function in formsite will only put out the html syntax in it's html module. action seen he http://fs8.formsite.com/testform/form1/index.html So this would be: 1. checking out my form on formsite.com 2. the script from nicedit.com is already installed in an html component. 3. changing or telling me the scripts/tags/or whatever for formsite form using formsites form builder (which allows some html/script editing). 4. changed so as to render the rich text entered on page 1 in page 2 instead of the html syntax. Any other solutions using formsite and any other richtextarea solutions would be great too! If I have a javascript var in a webpage(html form textarea VALUE - yui) that contains html code, and want to appear it, in confirmformpage.php, then how to transfer it...? is it really needed go via PHP ...? and ofcourse use innerHTML to write it....yes I usually use an intermitened processform.php script. http://developer.yahoo.com/yui/editor Hi pals, I am really tired in this problem of event keyup. I given same in my keyup function like: $(document).ready(function () { alert("GGG"+parseInt(jQuery.browser.version)); //To display test value working $("#find_text").keyup(function(e) { if(e.which == 13) { alert('Enter key was pressed'); //enter Here alert("FFF"+parseInt(jQuery.browser.version)); //Here got Error } }); }); I got Error : jQuery is not defined alert("FFF"+parseInt(jQuery.browser.version)); I use keycode,which , but no help, It's Work nicely in Chrome Browser but not in FF. Please give a Solution reply ASAP, I am really Tired.The code enter the Condition But that jQuery part make error. Thankfully Anes P.A I have been following a tutorial for an image gallery, i can upload images and use gd to create thumbnails that when clicked display the full sized image, but the full sized image is to big to fit in my design, i have managed to get the rel="lightbox" attached to the thumbnails as they are displayed but it wont load the full image, the loading ring just keeps going round, does anybody know how to fix this? is it even possible. BTW i am a complete beginner so please be gentle.
Hi all, I'm trying to make a digital order sheet for my brother. I made him a database in phpmyadmin, that has 2 tables, called Dishes and Cables. 2 different PHP sites call those tables, and pull the information. I then have an HTML page set to display that information. Here's what it looks like. <html> <head> <script type="text/javascript" > var data = null; var data2 = null; function GETSTUFF(stuff) { function buildList() { function showQuantity() { var supplier = document.getElementById('materials').options[document.getElementById('materials').selectedIndex].value; var amount = 0; for (var i=0;i<data.length;i++) { if (data[i]['Supplier'] == supplier) { amount = (data[i]['Quantity']); } } document.getElementById('quantity').innerHTML = 'Quantity : '+amount; var type = document.getElementById('materials').options[document.getElementById('materials').selectedIndex].value; var amount2 = 0; for (var i2=0;i2<data2.length;i2++) { if (data2[i2]['Type'] == type) { amount2 = (data2[i2]['Quantity (Boxes)']); } } document.getElementById('quantity').innerHTML = 'Quantity (Boxes) : '+amount2; } </script> </head> <body onload="setTimeout('buildList()' ,100)"/> <center> <img src="images.jpg" width=125px height=125px/> <br> <font size="8" color="grey" face="purisa">Home </font> <font size="8" color="red" face="purisa"> Communications</font> <br> <font size="5" color="grey" face="purisa">Order </font> <font size="5" color="red" face="purisa"> Sheet</font> <br> <table border="3" width="100%"> <tr> <th>Material:</th> <th>Quantity in stock:</th> <th>Quantity needed:</th> </tr> <tr> <td> <select id="materials" onchange = "showQuantity()"> <option disabled>Select</option> </select> </td> <td id="quantity"/> <td> <form> <input type = "quantityNeeded" /> </form> </td> </tr> </table> <br> <input type = "button" value="Submit"/> </center> </body> </html> My idea is that if the stuff from Dishes is selected, then display the quantity for that, and if the stuff from Cables is selected, display the quantity for that. This obviously involves an if statement, but nothing I can think of makes it work. I'd really appreciate help on this I am currently trying to put together a AJAX search that searches a MySQL database using PHP. I have created the below scripts. I cannot get it to function properly. Essentially I want someone to type in a partial search term and click submit and see the results. The purpose of this is for it to become part of a mobile app. Any help would be appreciated. Thank you! HTML: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <style type="text/css"> body{font-family:'Lucida Grande', Verdana, sans-serif;; font-size:14px; color:#666666;} h2{color:#000000; margin-bottom:20px;} h3{color:#000000; font-size:14px;} input{font-size:16px; color:#444444;} a:link, a:visited, a:hover{color:#0033CC;} a:hover{text-decoration:none;} div.searchInput{padding:8px; background:#DEDEDE; clear:both;} div.footer{padding:6px; border-top:solid 1px #DEDEDE; font-size:10px;} #msg{background:#FFFFCC; margin-bottom:10px; padding:4px; display:none;} </style> <script type="text/javascript"> function showProducts(str) { if (str=="") * { * document.getElementById("search-result").innerHTML=""; * return; * } if (window.XMLHttpRequest) * {// code for IE7+, Firefox, Chrome, Opera, Safari * xmlhttp=new XMLHttpRequest(); * } else * {// code for IE6, IE5 * xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); * } xmlhttp.onreadystatechange=function() * { * if (xmlhttp.readyState==4 && xmlhttp.status==200) *** { *** document.getElementById("search-result").innerHTML=xmlhttp.responseText; *** } * } xmlhttp.open("GET","search.php?q="+str,true); xmlhttp.send(); } </script> </head> <body> <form id="searchForm" name="searchForm" method="post" action="javascript:searchNameq();"> <div class="searchInput"> <input name="searchq" type="text" id="searchq" size="30" onkeyup="javascript:showProducts()"/> <input type="button" name="submitSearch" id="submitSearch" value="Search" onclick="javascript:showProducts()"/> </div> </form> <h3>Search Results</h3> <div id="msg">Type something into the input field</div> <div id="search-result"></div> </body> </html> PHP: <?php $q=$_GET["q"]; //connect to the database mysql_connect("christianbrogers.db.5646816.hostedresource.com","christianbrogers","GHbn123"); mysql_select_db("christianbrogers"); //explode our search term into separate words $search_exploded = explode(" ",$search); foreach($search_exploded as $search_each) { //construct the query $x++; if ($x==1) $construct .= "name LIKE '%$search_each%'"; else $construct .= " OR name LIKE '%$search_each%'"; } //echo out the constructed query $construct = "SELECT * FROM products WHERE $construct"; $run = mysql_query($construct); $foundnum = mysql_num_rows($run); if ($foundnum==0) echo "No results found."; else { while ($runrows = mysql_fetch_assoc($run)) { //get data $name = $runrows['name']; echo $name; ?> Hi! I'm using this javascript and php/MySQL: http://www.dynamicdrive.com/dynamici...ects/index.htm When I make a selection in all 3 lists I have a button that saves the selections in my MySQL database, like this: set1, Toyota, Cars, Camry Then I want to be able to select set1 in a list and press an "Edit" button that retrieves these 3 selections and auto selects them in the list. How is this possible? Thanks in advance Vigour Hi to all, i have a javascript on my websute that i want to hide from all users , i want put it on a database mysql and recall it, in order to hide the code, how I can make? you have some idea? please help me. Hi, I'm using MySQL/PHP on the server side and I have a database with customers and customer specific products. I have a form where i would like to have a dropdown menu for both customers and products. Customer menu is prepopulated from DB and depending on that selection a new SQL-query will be made with that customers name and ultimately populate the next menu with specific customers products. I am not familiar with JS so im kind of lost with it. I suppose i have to pass a queried customer array from PHP/HTML to JS and so forth. Or is JS a proper tool for this problem in the first place? Below is some simple code I have. Code: . .. ... while ($row=mysql_fetch_array($result)) { $customer=$row["customername"]; $options.="<OPTION VALUE=\"$customer\">".$customer.'</option>'; } echo("<SELECT NAME=customername><OPTION VALUE=0><?=$options?>< /SELECT>"); ... .. . Cheers, Bigfinn |