0

I have been writing a plugin but wanted to add some features to the plugin

In this program down JQuery is not working please help me

My requirements are

check this URL: codelisense.com/wp/about

1.When I click the drop down list or button yes textarea is not showing up

I mean I dunno why jquery is not showing up in this plugin

2.Please guide me in attachment

<?php

//Creating tables
function sukkyservices_installation(){
 global $wpdb;

 $table_name = $wpdb->prefix. "sukkyservices_contact";

 if($wpdb->get_var("SHOW TABLES LIKE '$table_name'" ) != $table_name){
$sql= "CREATE TABLE $table_name (
       id INT(6) UNSIGNED AUTO_INCREMENT PRIMARY KEY, 
       firstname VARCHAR(30) NOT NULL,
       lastname VARCHAR(30) NOT NULL,
       email VARCHAR(50),
       query VARCHAR(255),
       reg_date TIMESTAMP

       );";
require_once (ABSPATH. 'wp-admin/includes/upgrade.php' );
dbDelta($sql);
}
}
register_activation_hook(__FILE__, 'sukkyservices_installation');

function sukkyservices_shortcode(){
?>
<link rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css">
<style>
</style>
<div class="wrap">

 <?php

if(isset($_POST["Submit"])){

$firstname=$_POST[firstNametxt];
$lastname=$_POST["lastNametxt"];
$phoneno=$_POST["phoneno"];
$email=$_POST["email"];
$appplat=$_POST["appplat"];
$conditions=$_POST["conditions"];
$apptype=$_POST["apptype"];
$equity=$_POST["equity"];
$message= $firstname.$lastname.$phoneno.$email.$appplat.$conditions.$apptype.$equity;


$headers[] = 'From: Me Myself <wraejesh@gmail.com>';
$to= 'wraejesh@gmail.com';
$subject='hie';
$message= $firstname.$lastname.$phoneno.$email.$appplat.$conditions.$apptype.$equity;

wp_mail( $to, $subject, $message, $headers );


}

?>


<!DOCTYPE html>
<html>
 <form action="" method="post" enctype="multipart/form-data" >
 <h3><label style=" text-align: center; width: 100%;">Enquiry Form</label></h3>   
  <h4><label for="first-name-text">First name: </label></h4><input type="text" id="first-name-text" name="firstNametxt" class="form-control floating-label" placeholder="First Name" /><br/>
  <h4><label for="last-name-text">Last name: </label></h4><input type="text" id="last-name-text" name="lastNametxt" class="form-control floating-label" placeholder="Last Name" /><br/>
  <h4><label for="email">Email: </label></h4><input type="email" id="email" name="email" class="form-control floating-label" placeholder="e-mail" /><br/>
  <h4><label for="phoneno">Phone number: </label></h4><input type="text" id="phoneno" name="phoneno" class="form-control floating-label" placeholder="Phone number"> <br/>
  <h4><label for="appplat">App Platform </label></h4><select name="appplat">
<option value="Android">Android</option>
<option value="PHP">PHP</option>
<option value=".NET">.NET</option>
<option value=".NET">Java</option>
</select>
<h4><label for="NDA">Required NDA to be signed </label></h4><input name="Submit" type="button" value="Yes" class="btn btn-primary btn-raised mdi-action-grade" id="Yes" >
<input name="Submit" type="button" value="No" class="btn btn-primary btn-raised mdi-action-grade" id="No" >
 <select id="conditions" name="conditions">
<option class="yes" value="yes" selected="selected">Yes</option>
<option class="no" value="no"> No </option>
</select><br/>
<h4><label for="apptype" class="specify" style="display: block;">App type </label></h4>
<select name="apptype" class="apptype">  
 <option value="games">Games</option>
 <option value="Business">Business</option>
 <option value="Utilites">Utilities</option> 
 <option value="Others">Others</option>
</select><br/>
<textarea class="specify" name="specify" style="display: none;" >Give us the brief gist of your idea</textarea> <br/>
<h4><label for="equity" class="equity" style="display: block;">Percentage of Equity you would like to give </label></h4><br/>
<select name="equity" class="equity"> 
<?php
for($i=5; $i<=100; $i+=5){
echo "<option value=".$i."> ".$i."</option>";
}
?>
</select> <br/>
<br/>
<h4><label for="upload" class="upload" >Upload supporting documents</label></h4><br/>
<input type="file" id="upload" name="upload" class="form-control floating-label" placeholder="Upload supporting documents" /><br/>
   <input name="Submit" type="submit" value="Submit" class="btn btn-primary btn-raised mdi-action-grade" id="submit" >
    <input name="Cancel" type="submit" class="btn btn-default btn-raised mdi-action-grade" value="Cancel" id="cancel" style="margin-left: 15px" >
</form>
</div>
</html>
<?php

}

add_shortcode( 'SSS', 'sukkyservices_shortcode' ); 

function sukkyservices_js() {
wp_register_script('sukkyservices_jscall', plugins_url('/js/sukkyservices_js.js', __FILE__), array('jquery'),'1.1', true);
wp_enqueue_script('sukkyservices_jscall');
}

add_action( 'wp_enqueue_scripts', 'sukkyservices_js' );  
?>

Jquery sukkyservices_js.js file

$j=jQuery.noConflict();
$j(document).ready(function(){
  $j("#Yes").click(function(){
    $j(".apptype").show();
    $j(".specify").hide();
  });
  $j("#No").click(function(){
    $j(".specify").show();
    $j(".apptype").hide();
  });
});
  • sorry, but is totally not clear what is the question. Please edit the question and make it clear what exactly are you trying to do and what do not work. Keep in mind that if this is a jquery only question it is off-topic here. – Mark Kaplun Dec 28 '14 at 12:13
  • Check that url given there bro.. You'll know and now I edited the question – lost_in_magento Dec 28 '14 at 12:17
0

Firstly I'd suggest wrapping your JS like this:

(function ($) {

    $(document).ready(function(){
        $("#Yes").click(function(){
            $(".apptype").show();
            $(".specify").hide();
        });
        $("#No").click(function(){
            $(".specify").show();
            $(".apptype").hide();
        });
    });

})(jQuery);

You're also enqueuing jQuery twice, and the above the above script twice.... and with your shortcode you don't need to declare the DOCTYPE, or wrap your from in an HTML tag.

I would also include the bootstrap CSS file in the HEAD of document.

  • you're missing a right paren after the bracket on the last line. – Milo Dec 28 '14 at 17:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.