PHP - Change A Submit Button Into A Text Link With A Class
Hi,
I have the following submit button and would like to change it into a link with a class.
<input type="image" alt="Click here to Continue" name="I2" src="altimages/buttons/continue.gif" id="submit">How would I do this using jQuery? Thanks! Similar Tutorialshow do I make a link as a submit button? action is dashboard.php. help please Hello all , here is another problem of my project. I need to create a textarea , drop down list and submit button . At first , I can type whatever I want in the textarea , but for certain part I can just choose the word I want from drop down list and click submit , then the word will appear in the textarea as my next word . But I have no idea how to make this works , is there any simple example for this function ? Thanks for any help provided . Hope someone can help put with this - I have inherited a site and am trying to modify some PHP that I am unfamiliar with. I have gotten so far with it, but still have a problem with it.
Its a page on an online store offering optional extras depending on the product. The products are furniture, so and there was an option to buy cushions for some. The change I am trying to make is to have an option for two different sizes of cushion depending on the product.
So there was a field 'cushions' in the product table, and a page 'accessories.php' that offered the option to add cushions.
I have added a new field 'cushions2' and a new page 'accessories2.php' to cover the new size of cushions.
The site is here, with this example product:
http://www.lloydloom...oduct.php?id=32
If you click 'Add to cart' the next page offers you the option to add custom paintwork.
If you enter something there, and click on 'Add colour to order' it works - i.e. the next page is the one offering the cushions.
But if you just click on 'No thank you, proceed with order' it just reloads the page - basically the URL isn't being puled through as it should be.
On that page the PHP at the top of the page looks like this:
<?php session_start(); change link text Code: [Select] <?php require 'connect.php'; ?> <html> <head><title>Admin</title> <link rel="stylesheet" type="text/css" href="tab_style.css"> <script type="text/javascript"> function getXMLHTTP() { var xmlhttp=false; try{ xmlhttp=new XMLHttpRequest(); } catch(e) { try{ xmlhttp= new ActiveXObject("Microsoft.XMLHTTP"); } catch(e){ try{ xmlhttp = new ActiveXObject("Msxml2.XMLHTTP"); } catch(e1){ xmlhttp=false; } } } return xmlhttp; } function approve(e) { var req = getXMLHTTP(); if (req) { req.onreadystatechange = function() { if (req.readyState == 4) { // only if "OK" if (req.status == 200) { document.getElementById("appr <?php echo $fet['s_id']; ?>").innerHTML=req.responseText; } else { alert("There was a problem while using XMLHTTP:\n" + req.statusText); } } } req.open("GET", "approve.php?stu="+e, true); req.send(null); } } function block(b) { var req = getXMLHTTP(); if (req) { req.onreadystatechange = function() { if (req.readyState == 4) { // only if "OK" if (req.status == 200) { document.getElementById('blok').innerHTML=req.responseText; } else { alert("There was a problem while using XMLHTTP:\n" + req.statusText); } } } req.open("GET", "block.php?blo="+b, true); req.send(null); } } </script> </head> <body> <?php $admin_err=''; $pass_err=''; if (isset ($_REQUEST['submit'])) { require 'connect.php'; $admin = $_REQUEST['admin']; $pass = $_REQUEST['password']; $err=0; if($admin=="") { $admin_err="enter username"; $err=1; } if($pass=="") { $pass_err="enter password"; $err=1; } if ($err == 0) { $check = mysql_query("SELECT admin FROM admin_login WHERE admin='".$admin."' and password='".$pass."' "); $exi = mysql_num_rows ($check); if($exi == 0) $err_msg = "Username/password combination incorrect."; else { $sel = mysql_query("SELECT * FROM stud"); echo "<h4 class='table-caption'>Students</h4>"; while ($fet = mysql_fetch_array($sel)) { ?> <div class="base-layer"> <div class="table-row"> <div class="c_one"><p class="text"> <? echo $fet['name']; ?></p></div> <div class="c_two"><p class="text"> <? echo $fet['email']; ?></p></div> <div class="c_three"><p class="text"> <? echo $fet['school']; ?></p></div> <div class="c_four"><p class="text"> <? echo $fet['subject']; ?></p></div> <div class="c_five"><p class="text"> <? echo $fet['class']; ?></p></div> <div class="c_six"><p class="text"> <? echo $fet['teacher']; ?></p></div> <div class="c_seven" id="appr <?php echo $fet['s_id']; ?>"><p class="text"> <?php if ($fet['approve'] == 0) ?> <a href="#" onClick="return approve(<?php echo $fet['s_id']; ?>);" style="text-decoration:none"> Approve</a> </p> </div> <div class="c_eight" id="block"><p class="text"> <?php if($fet['approve'] == 1) ?> <a href="#" onClick="block(<?php echo $fet['s_id']; ?>);" style="text-decoration:none"> Block </a> </p> </div> <div class="space-line"> </div> </div> </div> <?php } die(mysql_error()); } } } ?> <form id="formid" method="post" name="myform" action=""> <p> <label for="username">Admin:</label> <input name="admin" type="text" size="20" value="<?php if(isset($admin)) echo $admin; ?>" /> <?php echo $admin_err; ?> </p> <p> <label for="pass">Password:</label> <input name="password" type="password" value="<?php if(isset($pass)) echo $pass;?>" /> <?php echo $pass_err; ?> </p> <p> <input name="submit" type="submit" value="Log in" > </p> <?php if(isset($err_msg)) echo $err_msg; ?> </form> </body> </html> approve.php Code: [Select] <?php require_once 'connect.php'; $id = $_REQUEST['stu']; $upd = mysql_query ("UPDATE stud SET approve = '1' WHERE s_id = ".$id." "); if (!$upd) die(mysql_error()); //header("Location:administrator.php"); echo "Approved"; //echo "<h3>Student Approved</h3>"; ?> the info posts beautifully i just canst seem to get the button to auto click or submit, tried numerous ways! help Code: [Select] <?php require_once "../store/paypal/utility.php"; require_once "../store/paypal/constants.php"; $url = "https://www.".DEFAULT_ENV.".paypal.com/cgi-bin/webscr"; $postFields = "cmd=".urlencode("_notify-synch"). "&tx=".urlencode(htmlspecialchars($_GET["tx"])). "&at=".urlencode(DEFAULT_IDENTITY_TOKEN); $ppResponseAr = Utils::PPHttpPost($url, $postFields, true); if(!$ppResponseAr["status"]) { Utils::PPError($ppResponseAr["error_msg"], $ppResponseAr["error_no"]); exit; } $httpParsedResponseAr = $ppResponseAr["httpParsedResponseAr"]; // assign posted variables to local variables $item_name = $httpParsedResponseAr['item_name']; $item_number = $httpParsedResponseAr['item_number']; $receiver_email = $httpParsedResponseAr['receiver_email']; $receiver_id = $httpParsedResponseAr['receiver_id']; $quantity = $httpParsedResponseAr['quantity']; $first_name = $httpParsedResponseAr['first_name']; $last_name = $httpParsedResponseAr['last_name']; $payer_email = $httpParsedResponseAr['payer_email']; $txn_type = $httpParsedResponseAr['txn_type']; $address_street = $httpParsedResponseAr['address_street']; $address_city = $httpParsedResponseAr['address_city']; $address_state = $httpParsedResponseAr['address_state']; $address_zip = $httpParsedResponseAr['address_zip']; $item_number = $httpParsedResponseAr['item_number']; $option_name1 = $httpParsedResponseAr['option_name1']; $option_selection1 = $httpParsedResponseAr['option_selection1']; $option_name2 = $httpParsedResponseAr['option_name2']; $option_selection2 = $httpParsedResponseAr['option_selection2']; $invoice = $httpParsedResponseAr['invoice']; $custom = $httpParsedResponseAr['custom']; $payer_id =$httpParsedResponseAr['payer_id']; ?> <html lang="en"> <head> <title>Rec</title> <link REL="stylesheet" href="include/style.css" type="text/css"> <!--[if IE]> <link REL="stylesheet" href="include/styleIE.css" type="text/css"> <![endif]--> <style> #center_block {width:50%;margin:0 auto;min-width:500px;} #contents_block {text-align:center;} #header_block {white-space:nowrap;height:25px;padding:0 10px 5px;text-align:center;} #fields_block {width:100%;margin:0;padding:10px} #header_block span {margin:0 5px} #buttons_block {padding:10px 10px 5px} #buttons_block div {padding:3px} #delimiter {margin:2px} #fields_block td {padding:3px 14px} #username_block td {padding-top:13px;white-space:nowrap;} #remember_block td {padding-bottom:13px;white-space:nowrap;} #required_block {text-align:left;padding:5px} </style> <!--[if IE]> <style> #main_block {width:100%} </style> <![endif]--> </head> <body> <script language="JavaScript" src="include/jquery.js"></script> <script language="JavaScript" src="include/jsfunctions.js"></script> <script language="JavaScript" src="include/runnerJS/RunnerBase.js"></script> <form action="rec.php" method="post" id="rec" name="rec.php"> <table id="center_block" align="center"> <tr><td id="contents_block"> <div class="main_table_border2 loginshade" id="main_block"> <table cellpadding=0 cellspacing=0 border=0 id="fields_block" class="loginshade"> <tr id="email_fieldblock"> <td align=left width=50% class=loginshade> <div align="left"><label for="value_email_1">Email:</label></div> </td> <td width=50% class=loginshade> <span id="edit1_email_0" style="white-space: nowrap;"><input id="value_email_1" style="" type="text" name="value_email_1" maxlength=50 value="<?php echo urldecode($httpParsedResponseAr["payer_email"]) ?>"> <font color="red">*</font></span> <div class="error"></div> </td> </tr> <tr id="pass_fieldblock"> <td align=left width=50% class=loginshade> <div align="left"><label for="value_pass_1">Pass:</label></div> </td> <td width=50% class=loginshade> <span id="edit1_pass_0" style=""><input style="" id="value_pass_1" type="Password" name="value_pass_1" maxlength=50 value="1234"> <font color="red">*</font></span> <div class="error"></div> </td> </tr> <tr id="confirm_block"> <td align=left width=50% class=loginshade> <div align="left"><label for="value_confirm_1">Re-enter password:</label></div> </td> <td width=50% class=loginshade> <span id="edit1_confirm_0" style=""><input style="" id="value_confirm_1" type="Password" name="value_confirm_1" value="1234"> <font color="red">*</font></span> <div class="error"></div> </td> </tr> <tr id="fname_fieldblock"> <td align=left width=50% class=loginshade> <div align="left"><label for="value_fname_1">First Name:</label></div> </td> <td width=50% class=loginshade> <span id="edit1_fname_0" style="white-space: nowrap;"><input id="value_fname_1" style="" type="text" name="value_fname_1" maxlength=50 value="<?php echo urldecode($httpParsedResponseAr["first_name"]) ?>"> <font color="red">*</font></span> </td> </tr> <tr id="lname_fieldblock"> <td align=left width=50% class=loginshade> <div align="left"><label for="value_lname_1">Last Name:</label></div> </td> <td width=50% class=loginshade> <span id="edit1_lname_0" style="white-space: nowrap;"><input id="value_lname_1" style="" type="text" name="value_lname_1" maxlength=50 value="<?php echo urldecode($httpParsedResponseAr["last_name"]) ?>"> <font color="red">*</font></span> </td> </tr> <tr id="address_fieldblock"> <td align=left width=50% class=loginshade> <div align="left"><label for="value_address_1">Address:</label></div> </td> <td width=50% class=loginshade> <span id="edit1_address_0" style="white-space: nowrap;"><input id="value_address_1" style="" type="text" name="value_address_1" maxlength=50 value="<?php echo urldecode($httpParsedResponseAr["address_street"]) ?>"> <font color="red">*</font></span> </td> </tr> <tr id="city_fieldblock"> <td align=left width=50% class=loginshade> <div align="left"><label for="value_city_1">City:</label></div> </td> <td width=50% class=loginshade> <span id="edit1_city_0" style="white-space: nowrap;"><input id="value_city_1" style="" type="text" name="value_city_1" maxlength=50 value="<?php echo urldecode($httpParsedResponseAr["address_city"]) ?>"> <font color="red">*</font></span> </td> </tr> <tr id="state_fieldblock"> <td align=left width=50% class=loginshade> <div align="left"><label for="value_state_1">State:</label></div> </td> <td width=50% class=loginshade> <span id="edit1_state_0" style="white-space: nowrap;"><input id="value_state_1" style="" type="text" name="value_state_1" maxlength=50 value="<?php echo urldecode($httpParsedResponseAr["address_state"]) ?>"> <font color="red">*</font></span> </td> </tr> <tr id="zip_fieldblock"> <td align=left width=50% class=loginshade> <div align="left"><label for="value_zip_1">Zip:</label></div> </td> <td width=50% class=loginshade> <span id="edit1_zip_0" style="white-space: nowrap;"><input id="value_zip_1" style="" type="text" name="value_zip_1" maxlength=50 value="<?php echo urldecode($httpParsedResponseAr["address_zip"]) ?>"> <font color="red">*</font></span> </td> </tr> <tr id="cosponsor_fieldblock"> <td align=left width=50% class=loginshade> <div align="left"><label for="value_cosponsor_1">Cosponsor:</label></div> </td> <td width=50% class=loginshade> <span id="edit1_cosponsor_0" style=""><input id="type_cosponsor_1" type="hidden" name="type_cosponsor_1" value="checkbox"><input id="value_cosponsor_1" type="Checkbox" name="value_cosponsor_1" ></span> </td> </tr> <tr id="recipients_fieldblock"> <td align=left width=50% class=loginshade> <div align="left"><label for="value_recipients_1">Recipients:</label></div> </td> <td width=50% class=loginshade> <span id="edit1_recipients_0" style="white-space: nowrap;"><input id="value_recipients_1" style="" type="text" name="value_recipients_1" maxlength=50 value="<?php echo urldecode($httpParsedResponseAr["quantity"]) ?>"> <font color="red">*</font></span> </td> </tr> <tr id="clients_fieldblock"> <td align=left width=50% class=loginshade> <div align="left"><label for="value_clients_1">Clients:</label></div> </td> <td width=50% class=loginshade> <span id="edit1_clients_0" style=""><input id="type_clients_1" type="hidden" name="type_clients_1" value="checkbox"><input id="value_clients_1" type="Checkbox" name="value_clients_1" ></span> </td> </tr> <tr id="space_block"></tr> </table> </div> </td></tr> </table> <input type=submit value="Submit" class=button id="saveButton1" onload="Submit"></form> </body> </html> Hi. I have just one question (I have searched for an answer for this but have not been able to locate one): How do you go about changing the text on a "Submit Query" button to display simply "Submit"? Below is the current code for the page that displays said button. Thank-you in advance for any help or direction. <?php include 'connection.php'; $query = "SELECT * FROM people"; $result = mysql_query($query) or die(mysql_error()); while ($person = mysql_fetch_array($result)){ echo $person ['name']; echo $person ['descrip']; } ?> <H1>Add Your Review:</H1> <form action="create.php" method="post"> Subject <input type="text" name="inputName" value=""/> </br > Review <textarea cols="50" rows="4" name="inputDesc" value=""/></textarea> </br > <input type= "submit" name= "submit"/> </form> <html> <head></head> <body> <p>The current second is <span style='font-size:16px;font-weight:bold;color:red;position:absolute;right:25px;'><?php echo time(); ?></span> on this computer.</p> </body> </html> Hello everyone, I am working on a form that is similar to a shopping cart system and I am thinking of creating a button that submits the checked value and saves them to a $_SESSION variable. And also a link that links to a cart.html that takes the values of a $_SESSION variable. I am have trouble figuring what tag/attribute should I use in order to achieve that.
Right now my code attached below submits the checked values to cart.html directly. However I want my submit button to save the checked box to a $_SESSION variable and STAY on the same page. And then I will implement a <a> to link to the cart.php.
I researched a little bit about this subject and I know it's somewhat related to ajax/jquery. I just wanted to know more about it from you guys. I appreciate your attention for reading the post and Thanks!
Below is the form that I currently have:
<form name= "finalForm" method="POST" action="cart.php"> <input type="Submit" name="finalSelected"/> <?php foreach($FinalName as $key => $item) {?> <tr> <td><input type="checkbox" name="fSelected[]" value="<?php echo htmlspecialchars($FinalID[$key])?>" /> <?php echo "$FinalID[$key] & $item";?> </td> </tr> <?php } ;?>Below is the code for cart.php <?php require ('connect_db.php'); if(isset($_POST['finalSelected'])) { if(!empty($_POST['fSelected'])) { $chosen = $_POST['fSelected']; foreach ($chosen as $item) echo "aID selected: $item </br>"; $delimit = implode(", ", $chosen); print_r($delimit); } } if(isset($delimit)) { $cartSQL = "SELECT * from article where aID in ($delimit)"; $cartQuery = mysqli_query($dbc, $cartSQL) or die (mysqli_error($dbc)); while($row = mysqli_fetch_array($cartQuery, MYSQLI_BOTH)) { $aTitle[] = $row[ 'name' ]; } } ?> <table> <?php if(isset($delimit)) { $c=0; foreach($aTitle as $item) {?> <tr> <td> <?php echo $aTitle[$c]; $c++;?> </td> </tr> <?php }}?> </table> Friends I am new to php and i have to submit my coursework in php by 3rd dec, I stuck at one place where i have to upload multiple photo and one can see all the photo he has uploaded and can edit or delete that photo so i have done uploading now i am showing those pics in table by running loop and generating tr and td but now i have two buttons with each row edit and delete now when i clicked on one delete or edit that pic should be delete or give text box to edit description of pic, Please help me how to do that....... We have a form Code: [Select] <div class="element"> <div class="option-container"> <span class="title " style="color:#26ADE4;font-family:Arial;font-size:2.2em;font-weight:bold;">Contact us</span></div> </div> <div class="element"> <div class="option-container"><div class="paragraph " name="element[]" id="element[]" style="color:#000000;font-family:Verdana;font-size:0.8em;font-weight:normal;width:300px;">To contact us, use the form below.<br>We will get back to you as soon as possible.</div></div> </div> <div class="element"> <label id="label-element-7" class="label" style="color:#4DBCE9;font-family:Trebuchet MS;font-size:1.2em;font-weight:normal;"> <span class="labelelementvalue">Email</span> <span class="required">*</span></label> <div class="errormessage" id="errormessage-element-7"></div> <div class="option-container"> <input class="af-inputtext af-email af-formvalue " type="text" name="element[]" id="element[]" value="" style="color:#000000;font-family:Verdana;font-size:0.8em;font-weight:normal;width:260px;border-style:solid; border-color:#dcdcdc;-moz-border-radius:5px;-khtml-border-radius:5px;-webkit-border-radius:5px;border-radius:5px;border-width:1px;padding:5px;"></div> </div> <div class="element"> <label id="label-element-8" class="label" style="color:#4DBCE9;font-family:Trebuchet MS;font-size:1.2em;font-weight:normal;"> <span class="labelelementvalue">Textarea</span></label> <div class="errormessage" id="errormessage-element-8"></div> <div class="option-container"> <textarea class="af-textarea af-formvalue " name="element[]" id="element[]" style="color:#000000;font-family:Verdana;font-size:0.8em;font-weight:normal;width:300px;border-style:solid; border-color:#dcdcdc;-moz-border-radius:5px;-khtml-border-radius:5px;-webkit-border-radius:5px;border-radius:5px;border-width:1px;padding:5px;" rows="6"></textarea></div></div> Now, when this is submitted, our script grabs the values and sends the values through an email What we need to do, is grab every value that is in the <span class> This form is built dynamically, and then pulled from the database, so each <span class> value will be different. Each span class will have the name "labelelementvalue". What I need to accomplish is that when the form is submitted, how do I go about grabbing everything that is between Code: [Select] <span class="labelelementvalue"></span> and displaying it? I know this has to deal with javascript and php, so I'm not sure where to post this. Thanks in advance Hey, I'm trying to add an class so I can have different background colors on my tabs. This is the nav code for my site Code: [Select] <?php function art_get_menu_auto($theme_location = 'primary-menu', $source='Pages', $Subitems = 'true', $menu = null) { $depth = (!$Subitems ? 1 : 0); if (($source != 'Custom Menu') && function_exists('wp_nav_menu')) { $locations = get_nav_menu_locations(); if ($locations && isset( $locations[ $theme_location ] ) ) { $nav = wp_get_nav_menu_object($locations[$theme_location]); if($nav){ $source = 'Custom Menu'; $menu = $nav; } } } return art_get_menu($source, $depth, $menu); } function art_get_menu($source='Pages', $depth = 0, $menu = null) { if ($source == 'Custom Menu' && function_exists('wp_nav_menu') && $menu) { return art_get_list_menu( array( 'menu' => $menu, 'depth' => $depth)); } if ($source == 'Pages') { return art_get_list_pages(array('depth' => $depth, 'sort_column' => 'menu_order, post_title')); } if ($source == 'Categories') { return art_get_list_categories(array('title_li'=> false, 'depth' => $depth)); } return "Error in menu source ".$source. "."; } /* menus */ function art_get_list_menu($args = array()) { $menu = $args['menu']; $menu_items = wp_get_nav_menu_items($menu->term_id); if(empty($menu_items)) { return sprintf( '<li><a>' .art_option('menu.topItemBegin') .__("Empty menu (%s)", THEME_NS) .art_option('menu.topItemEnd') .'</a></li>', $menu->slug); } $nav_menu = ''; $items = ''; _art_menu_item_classes_by_context($menu_items); $sorted_menu_items = array(); foreach ((array) $menu_items as $key => $menu_item) $sorted_menu_items[$menu_item->menu_order] = wp_setup_nav_menu_item($menu_item); $walker = new art_MenuWalker(); $items .= $walker->walk($sorted_menu_items, 0, array()); $items = apply_filters('wp_nav_menu_items', $items, $args); $items = apply_filters("wp_nav_menu_{$menu->slug}_items", $items, $args); $nav_menu .= $items; $nav_menu = apply_filters('wp_nav_menu', $nav_menu, $args); return $nav_menu; } function _art_menu_item_classes_by_context( &$menu_items ) { global $wp_query; $home_page_id = (int) get_option( 'page_for_posts' ); $queried_object = $wp_query->get_queried_object(); $queried_object_id = (int) $wp_query->queried_object_id; $active_ID = null; $IdToKey = array(); foreach ( (array) $menu_items as $key => $menu_item ) { $IdToKey[$menu_item->ID] = $key; if ( $menu_item->object_id == $queried_object_id && ( ( ! empty( $home_page_id ) && 'post_type' == $menu_item->type && $wp_query->is_home && $home_page_id == $menu_item->object_id ) || ( 'post_type' == $menu_item->type && $wp_query->is_singular ) || ( 'taxonomy' == $menu_item->type && ( $wp_query->is_category || $wp_query->is_tag || $wp_query->is_tax ) ) ) ) { $active_ID = $menu_item->ID; } elseif ( 'custom' == $menu_item->object ) { $current_url = ( is_ssl() ? 'https://' : 'http://' ) . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']; $item_url = strpos( $menu_item->url, '#' ) ? substr( $menu_item->url, 0, strpos( $menu_item->url, '#' ) ) : $menu_item->url; if ( $item_url == $current_url ) { $active_ID = $menu_item->ID; } } } $currentID = $active_ID; while ($currentID !== null && isset($IdToKey[$currentID])) { $current_item = $menu_items[$IdToKey[$currentID]]; $current_item->classes[] = 'active'; $currentID = $current_item->menu_item_parent; if ($currentID === '0') break; } } class art_MenuWalker extends Walker { var $tree_type = array('post_type', 'taxonomy', 'custom'); var $db_fields = array('parent' => 'menu_item_parent', 'id' => 'db_id'); var $is_active = false; function start_lvl(&$output, $depth) { $indent = str_repeat("\t", $depth); $output .= "\n$indent<ul"; if ($this->is_active){ $output .= ' class="active" '; } $output .= ">\n"; $this->is_active = false; } function end_lvl(&$output, $depth) { $indent = str_repeat("\t", $depth); $output .= "$indent</ul>\n"; } function start_el(&$output, $item, $depth, $args) { global $wp_query; $indent = ($depth) ? str_repeat("\t", $depth) : ''; $classes = empty( $item->classes ) ? array() : (array) $item->classes; $class_names = join( ' ', apply_filters( 'nav_menu_css_class', array_filter( $classes ), $item ) ); $active = in_array('active', $classes); $output .= $indent . '<li'; if ($active) { $this->is_active = true; $output .= ' class="active" '; } else { $output .= ' class="1" '; // This line..... } $output .= '>'; $attributes = ! empty($item->attr_title) ? ' title="' . attribute_escape($item->attr_title) .'"' : ''; $attributes .= ! empty($item->target) ? ' target="' . attribute_escape($item->target) .'"' : ''; $attributes .= ! empty($item->xfn) ? ' rel="' . attribute_escape($item->xfn) .'"' : ''; $attributes .= ! empty($item->url) ? ' href="' . attribute_escape($item->url) .'"' : ''; $attributes .= ! empty($class_names) ? ' class="' . attribute_escape($class_names) .'"' : ''; $item_output .= '<a'. $attributes .'>'; if ($depth == 0) $item_output .= art_option('menu.topItemBegin'); $item_output .= apply_filters('the_title', $item->title, $item->ID); if ($depth == 0) $item_output .= art_option('menu.topItemEnd'); $item_output .= '</a>'; $output .= apply_filters( 'walker_nav_menu_start_el', $item_output, $item, $depth, $args ); } function end_el(&$output, $item, $depth) { $output .= "</li>\n"; $this->is_active = false; } } /* pages */ function art_get_list_pages($args = array()) { global $wp_query; $pages = &get_pages($args); $IdToKey = array(); $currentID = null; foreach ($pages as $key => $page) { $IdToKey[$page->ID] = $key; } if ($wp_query->is_page) { $currentID = $wp_query->get_queried_object_id(); } $frontID = null; $blogID = null; if ('page' == get_option('show_on_front')) { $frontID = get_option('page_on_front'); if ($frontID && isset($IdToKey[$frontID])) { $frontKey = $IdToKey[$frontID]; $frontPage = $pages[$frontKey]; unset($pages[$frontKey]); $frontPage->post_parent = '0'; $frontPage->menu_order = '0'; array_unshift($pages, $frontPage); $IdToKey = array(); foreach ($pages as $key => $page) { $IdToKey[$page->ID] = $key; } } if (is_home()) { $blogID = get_option('page_for_posts'); if ($blogID && isset($IdToKey[$blogID])) { $currentID = $blogID; } } } $activeIDs = array(); $activeID = $currentID; while($activeID && isset($IdToKey[$activeID])) { $activeIDs[] = $activeID; $activePage = $pages[$IdToKey[$activeID]]; if ($activePage && $activePage->post_status == 'private') { break; } $activeID = $activePage->post_parent; } $result = ''; if (art_option('menu.showHome') && ('page' != get_option('show_on_front') || (!get_option('page_on_front') && !get_option('page_for_posts')))) { $result = '<li><a' . (is_home() ? ' class="active"' : '') . ' href="' . get_option('home') . '">' .art_option('menu.topItemBegin') . art_option('menu.homeCaption') .art_option('menu.topItemEnd') . '</a></li>'; } if (!empty($pages)) { $walker = new art_PageWalker('list', 'ul', $activeIDs, $frontID); $result .= $walker->walk($pages,$args['depth'], array(), $currentID); } return $result; } class art_PageWalker extends Walker { var $db_fields = array('parent' => 'post_parent', 'id' => 'ID'); var $activeIDs = array(); var $frontID = array(); var $is_active = false; function art_PageWalker($type='list', $tag='ul', $activeIDs=array(), $frontID=null){ $this->tag = $tag; $this->activeIDs = $activeIDs; $this->frontID = $frontID; $this->type = $type; } function start_lvl(&$output) { $output .= "\n<".$this->tag; if($this->is_active){ $output .= ' class="active" '; } $output .= ">\n"; $this->is_active = false; } function end_lvl(&$output) { $output .= "</".$this->tag.">\n"; } function start_el(&$output, $page, $depth, $args, $current_page) { $active = in_array($page->ID, $this->activeIDs); $output .= '<li'; if ($active) { $this->is_active = true; $output .= ' class="active" '; } $output .= '><a'; if ($active) { $output .= ' class="active"'; } $href = get_page_link($page->ID); if ($this->frontID && $this->frontID == $page->ID) { $href = get_option('home'); } $title = apply_filters( 'the_title', $page->post_title, $page->ID ); $output .= ' href="'.$href.'" title="'.attribute_escape($title).'">'; if ($depth == 0) $output .= art_option('menu.topItemBegin'); $output .= $title; if ($depth == 0) $output .= art_option('menu.topItemEnd'); $output .= '</a>'; } function end_el(&$output, $page) { $output .= "</li>\n"; $this->is_active = false; } } /* categories */ function art_get_list_categories($args = array()) { global $wp_query; $categories = &get_categories($args); $IdToKey = array(); foreach ($categories as $key => $category){ $IdToKey[$category->term_id] = $key; } $currentID = null; if ($wp_query->is_category) { $currentID = $wp_query->get_queried_object_id(); } $activeID = $currentID; $activeIDs = array(); while ($activeID && isset($IdToKey[$activeID])) { $activeIDs[] = $activeID; $activeCategory = $categories[$IdToKey[$activeID]]; $activeID = $activeCategory->parent; } $result = ''; if (!empty($categories)) { $walker = new art_CategoryWalker('list','ul', $activeIDs); $result .= $walker->walk($categories, $args['depth'], array('count' => false, 'current_category' =>$currentID)); } return $result; } class art_CategoryWalker extends Walker { var $db_fields = array ('parent' => 'parent', 'id' => 'term_id'); var $activeIDs = array(); var $is_active = false; function art_CategoryWalker($type='list', $tag='ul', $activeIDs=array()){ $this->tag = $tag; $this->activeIDs = $activeIDs; $this->type = $type; } function start_lvl(&$output){ $output .= "\n<".$this->tag; if ($this->is_active) { $output .= ' class="active" '; } $output .= ">\n"; $this->is_active = false; } function end_lvl(&$output) { $output .= "</".$this->tag.">\n"; } function start_el(&$output, $category, $depth, $args) { $count = intval($category->count); $count_text = sprintf(__('%s posts', THEME_NS), $count); $active = in_array($category->term_id, $this->activeIDs); $output .= '<li'; if ($active) { $this->is_active = true; $output .= ' class="active" '; } $output .= '>'; if ($category->description) { $title = $category->description; } else { $title = $count_text; } $output .= '<a'; if ($active) { $output .= ' class="active"'; } $output .= ' href="'.get_category_link($category->term_id).'" title="'.$title.'">'; if ($depth == 0) $output .= art_option('menu.topItemBegin'); $output .= attribute_escape($category->name); if ($depth == 0) $output .= art_option('menu.topItemEnd'); $output .= '</a>'; } function end_el(&$output, $page) { $output .= "</li>\n"; $this->is_active = false; } } This the line... Code: [Select] $output .= ' class="1" '; // This line..... How could I set the class to the page number - So for example if page 1 then background is blue, if its 5 then its green etc... I want to set up the css but I need to assign the class to the page number.... (Or parent page number if the page number is not top level..) Any ideas? I have a method that is returning a funny variable, it should be returning what is below and when I echo the return from inside the method it is right. Code: [Select] Software/Section but when I goto echo the from outside the class I get the following. It adds a back slash Code: [Select] Software//Section this is the method code and it works fine when I echo the returnValue the value is right Code: [Select] // Creates a dymamic case statement for making a the choice // inside and array foreach (scandir($dir) as $folderItem) { if ($folderItem != "." AND $folderItem != "..") { if (is_dir($dir.$folderItem.DIRECTORY_SEPARATOR)) { $folderItem = $folderItem ; // this allows the the dir to be placed if statements below $folderContents = $this->showPage( $dir.$folderItem ,$getPageGlobal , $subdir); $subdir = ""; // this resets so that ithe value does not get added to main links; } else { // put into if into array if($getPageGlobal== $folderItem) { $pageReturn = $dir . $folderItem; } } } } echo $pageReturn.'<br>'; return $pageReturn; This is the way I am echoing the class. This is when it decides to add the back slash Code: [Select] echo $dynamicMenu->getShowPage(); Hello I want to be able to change the class depending on if a variable is 1 or 0. <html> <p class="note-general"> This is the general </p> <p class="note-warning"> And this is the warning </p> </html> I want the variable $adult (that can be 1 or 0) to set if the class should be a note-general or note-warning. Thank you for support If you look at this form: kmkwebdevelopment.com/formtest/upload.php you will see that when you click on the "add another upload box" button, instead of it adding another upload box, it is submitting the form for some reason. Can anyone see where the error lies? Relevant snippet of code below: <?php //deafult number of upload boxes $upload_quant = 4; //if the user increased the number of boxes if(isset($_POST['increase_upload'])) { //increasing the number of upload boxes $upload_quant = $_POST['previous_upload'] + 1; } $upload_quantity = $_POST['previous_upload']; //getting all the names into an array $uplaoded_array = array(); for($i=0;$i<$upload_quantity;++$i) { $ii = $i+1; $upload_name = 'upload'.$ii; $get_upload_name = $_POST['$upload_name']; array_push($uplaoded_array,$get_upload_name); } ?> <form class="uploadform" action="<?php echo $_SERVER["PHP_SELF"] ?>" method="post" enctype="multipart/form-data" onSubmit="return CheckForm(this);"> <?php IsThereErrors("0", $_iserrors); ?> <input type="hidden" name="_referer" value="<?php echo $_referer ?>"> <input type="hidden" name="_next_page" value="1"> <p class="form_expert_style"><input name="URL" type="text" value=""/></p> <table> <tr> <td>First Name *</td> <td><input type='text' size='30' name='firstname' onBlur="FieldBlur(this.name+'_tooltip')" <?php mark_if_error("firstname", "") ?> value="<?php echo isset($_values["firstname"]) ? htmlspecialchars($_values["firstname"]) : "" ?>"></td> </tr> <tr> <td>Last Name *</td> <td><input type='text' size='30' name='lastname' onBlur="FieldBlur(this.name+'_tooltip')" <?php mark_if_error("lastname", "") ?> value="<?php echo isset($_values["lastname"]) ? htmlspecialchars($_values["lastname"]) : "" ?>"></td> </tr> <tr> <td>E-mail *</td> <td><input type='text' size='30' name='email' onblur="FieldBlur(this.name+'_tooltip')" <?php mark_if_error("email", "") ?> value="<?php echo isset($_values["email"]) ? htmlspecialchars($_values["email"]) : "" ?>"></td> </tr> <tr> <td>Company Number *</td> <td><input type='text' size='30' name='companynumber' onBlur="FieldBlur(this.name+'_tooltip')" <?php mark_if_error("companynumber", "") ?> value="<?php echo isset($_values["companynumber"]) ? htmlspecialchars($_values["companynumber"]) : "" ?>"></td> </tr> <?php for($i=0;$i<$upload_quant;++$i) { $ii = $i+1; $upload_name = 'upload'.$ii; echo <<<_END <tr> <td>Upload $ii</td> <td><input class="image" type='file' size='30' name='$upload_name'></td> </tr> _END; } echo <<<_END <tr> <td> <input type="hidden" value="$upload_quant" name = "previous_upload"/> <input type="submit" name="increase_upload" value="Add another upload box" /> </td> <tr> <td><input type="submit" name="SubmitBtn" onClick="CheckForm1();" value="SUBMIT" /></td> </tr> </table> </form> _END; } ?> </html> <?php Thanks This topic has been moved to JavaScript Help. http://www.phpfreaks.com/forums/index.php?topic=347187.0 function theme_user_badge($badge) { $image = theme('image', $badge->image, $badge->name, $badge->name); if ($badge->href != "") { return l($image, $badge->href, array('html' => TRUE)); } else { return $image; } }
How to add class to the link so it appears like <a href="/link" class="popups">? Hi all
I have a small issue with a site I am building. For the main menu I use an SSI for ease of updating every page at once. When the user clicks an item and goes to a page I want to have that option in the menu highlighted / different colour, to show what page they are on.
This works perfectly for single menu items like this:
<li <?php if( $page=='index') echo 'class="active"'; ?> ><a href="index.php">Home</a></li>I use $page in the respective page HTML and it links up to the menu. However, some of the options have drop down menu items. I would like to highlight the top level item on the menu even when a sub section item is selected. In its current state the drop down menu item is highlighted, but not the top. <li <?php if ($page=='ci') echo 'class="active"'; ?>> <a href="ci.php" class="dropdown-toggle" data-toggle="dropdown" data-hover="dropdown">CI <i class="fa fa-angle-down"></i></a> <ul class="dropdown-menu"> <li <?php if ($page=='ci1') echo 'class="active"'; ?>> <a href="ci.php">xxxx</a></li> <li <?php if ($page=='reasons') echo 'class="active"'; ?>> <a href="reasons.php">xxxx</a></li> <li <?php if ($page=='small_faq') echo 'class="active"'; ?>> <a href="small-faq.php">faq</a></li> </ul> </li>Even when I change the sub levels to be the same as the top level, the top level item will not change colour. I have no idea why. Can anyone see what I am doing wrong? Edited by Zola, 17 October 2014 - 10:42 AM. I have a button that increases a counter (which also a link to a file) beside it. Code: [Select] echo "<tr>"; echo "<td name='".$cell1['value']."'>".$cell1['value']."</td><td name='".$cell2['value']."'><a href='file.php'>".$counter."</a><input type='button' name='buttonName' onclick='submit('.$cell1['value'].');'></td> <td name='".$cell2['value']."'><a href='file.php'>".$counter."</a><input type='button' name='buttonName' onclick='submit('.$cell1['value'].');'></td>"; echo "</tr>";When one of the buttons is clicked I want to pass cell1value to the processing script. Is this the correct way to do it? And how do I access $cell1['value'] after submission? Hello, Im new to website building. I have created a login system. The login system echoes some text when the username and password is correct. However, if correct i would like it to open another page on my site. Code: [Select] <form name="form1" method="post" action=""> <p>Username <label> <input type="text" name="username" id="username"> </label> Password <label> <input type="password" name="password" id="password"> </label> <input name="login" type="submit" id="login" value="Login"> <?php $username = $_POST ["username"]; $password = $_POST ["password"]; if ($username == "admin" && $password == "password"){ echo"Logged In";} ?> </p> </form> I am a novice and learnt this via youtube. However, can't find a tutorial for what i want. Thanks sorry solved this one, I didnt put the submit button in the <form> </form> tag lmfao... Whenever I hit the submit button, it's not even reading if they hit it and doing all that if and else statements I have. Why is not noticing the submit button? I had this working last night, but my dumb self saved over it with another file I was editing. Code: [Select] <?php session_start(); include("config.php"); include("logincheck.php"); $time = date_default_timezone_set("US/Eastern"); $timeformat = date("Y-m-d H:i:s"); $author = $_SESSION['username']; $title = $_POST['title']; $body = $_POST['body']; if (isset($_POST['submit'])) { if (!empty($title)) { if (!empty($body)) { $sql = "INSERT INTO news (author, title, body, time) VALUES ('$author', '$title', '$body', NOW())"; mysqli_query($cxn, $sql); $error = "Your news posting has been submitted successfully."; } else { $error = "You must fill out the body of the posting!"; } } else { $error = "You must fil out the title of the posting!"; } } $sql = "SELECT userlevel FROM members WHERE userid='".$_SESSION['userid']."'"; $result = mysqli_query($cxn, $sql); $row = mysqli_fetch_array($result); if ($row['userlevel'] != 2) { $error = "You do not have the power to view this page!"; header("Location: news.php"); } else { ?> <?php include("header.php"); ?> <h1>Post News</h1> <?php echo $error; ?> <form method="<?php echo $_SERVER['SCRIPT_NAME']; ?>" method="post"> <b>Author:</b> <?php echo $author; ?><br> <b>Title:</b><br> <input type="text" maxlength="25" name="title" value="<?php echo $title; ?>" /><br> <b>Body:</b><br> <textarea name="body" maxlength="999" rows="10" cols="40"><?php echo $body; ?></textarea><br> <input type="submit" name="submit" value="Post News" /> </form> <?php } ?> <?php include("footer.php"); ?> |