Jump to content

Search the Community

Showing results for tags 'ajax'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • Welcome to PHP Freaks
    • Announcements
    • Introductions
  • PHP Coding
    • PHP Coding Help
    • Regex Help
    • Third Party Scripts
    • FAQ/Code Snippet Repository
  • SQL / Database
    • MySQL Help
    • PostgreSQL
    • Microsoft SQL - MSSQL
    • Other RDBMS and SQL dialects
  • Client Side
    • HTML Help
    • CSS Help
    • Javascript Help
    • Other
  • Applications and Frameworks
    • Applications
    • Frameworks
    • Other Libraries
  • Web Server Administration
    • PHP Installation and Configuration
    • Linux
    • Apache HTTP Server
    • Microsoft IIS
    • Other Web Server Software
  • Other
    • Application Design
    • Other Programming Languages
    • Editor Help (PhpStorm, VS Code, etc)
    • Website Critique
    • Beta Test Your Stuff!
  • Freelance, Contracts, Employment, etc.
    • Services Offered
    • Job Offerings
  • General Discussion
    • PHPFreaks.com Website Feedback
    • Miscellaneous

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


AIM


MSN


Website URL


ICQ


Yahoo


Jabber


Skype


Location


Interests


Age


Donation Link

  1. Hello, I have piece of code I have written that, when the form is submitted it sends the string from the textbox through ajax, through a database and returns a name corresponding to that string. It works fine in chrome but not in firefox and I was wondering if you could help. If I set the function to a simple alert(code) it will fire it and work fine however when I revert it to the ajax script it simply reloads the page with the "?code=string" and ignores anything and everything in the js function. This is the ajax code: function signin(code) { // event.preventDefault(); var xmlhttp; var photo; if (code=="") { document.getElementById("resultcontents").innerHTML="lol"; return; } if (window.XMLHttpRequest) {// code for IE7+, Firefox, Chrome, Opera, Safari xmlhttp=new XMLHttpRequest(); } else {// code for IE6, IE5 xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); } xmlhttp.onreadystatechange=function() { if (xmlhttp.readyState==4 && xmlhttp.status==200) { var str = xmlhttp.responseText; var split = str.split(", "); document.getElementById("resultcontents").innerHTML=split['0']; document.getElementById("counter").innerHTML=split['1']; if(!(split['2'] == undefined)){ document.getElementById("webcamcanvas").innerHTML="<img src='" +split['2']+"' width='400' height='300'>"; } document.getElementById("codetextbox").value=""; document.getElementById("codetextbox").focus(); } } xmlhttp.open("GET","files/******.php?code="+code,true); xmlhttp.send(); } This is the HTML form: form onsubmit="signin(codeform.codetextbox.value)" name="codeform"> <input type="textbox" name="codetextbox" id="codetextbox" /> </form> The reason it has no submit button is because firstly, it clutters up the page and secondly I'm using a barcode scanner which automatically inserts a carriage return, submitting the form. Any help would be greatly appreciated! Also, I'm sorry if this is in the wrong section, it's to do with both JS and Ajax and I didn't know which to choose. Jacbey.
  2. I have 2 sites on my machine, one is my development site and one is third party site. The third party site has a aspx file that returns information. I have been trying access this through Jquery and Ajax but ran into a cross domain problem. Am I right in thinking I can do this is PHP? and are their any simple tutorials that someone could point me to. thanks Jasemilly
  3. hi guys, im new with google map, i need some help. i have ajax call, here: $('#checkbtn').click(function(e) { e.preventDefault(); var lo=$("#long").val(); var la=$('#lat').val(); $.ajax({ url:BASEURL+'register/checklocation', type:'POST', data:{log:lo,lat:la}, success:function(data) { $('#view_checkmap').html(data); } }); }); here is my view to view the map: <script> function initialize() { var myLatlng = new google.maps.LatLng(<?php echo $lat; ?>,<?php echo $long; ?>); var mapOptions = { zoom: 15, center: myLatlng, mapTypeId: google.maps.MapTypeId.ROADMAP } var map = new google.maps.Map(document.getElementById('mymap'), mapOptions); var marker = new google.maps.Marker({ position: myLatlng, map: map, title: 'my location' }); } google.maps.event.addDomListener(window, 'load', initialize); </script> <div id="mymap" style="width:500px; height:300px;"></div> when i access to the URL, it displays, but when i access over ajax, nothing display. is my code worng or something else? thanks in advance.
  4. I have the code that dynamically generates textboxes and select boxes upon a button click. I want to fetch the data from DB and display in the dynamically generated select box. Fiddle http://jsfiddle.net/hEByw/10/ shows how the text and selectboxes are generated dynamically. Jquery code var counter = 1; $(document).ready(function () { $("#addButton").click(function () { if(counter>7){ alert("Only 7 textboxes allow"); return false; } //To Display the tax types from DB $(function(){ var items=""; $.getJSON("get_tax_type.php",function(data){ $.each(data,function(index,item) { items+="<option value='"+item.id+"'>"+item.name+"</option>"; }); $("#tax_type' + counter + '").html(items); }); }); var newTextBoxDiv = $(document.createElement('div')) .attr("id", 'TextBoxDiv' + counter); newTextBoxDiv.after().html('<label>Product #'+ counter + ' : </label>' + '<input type="text" size="60" name="product[]"\n\ id="product' + counter + '" value="" > \n\ <label>Quantity #'+ counter + ' : </label>' + '<input type="text" size="2" name="qty[]" \n\ id="qty' + counter + '" value="" > \n\ <label>Rate #'+ counter + ' : </label>' + '<input type="text" size="2" name="rates[]"\n\ id="rates' + counter + '" value="" > \n\ <label>Tax #'+ counter + ' : </label>' + '<select id="tax_type' + counter + '" ></select> \n\ <label>Tax% #'+ counter + ' : </label>' + '<select id="tax_type' + counter + '" ></select> \n\ <label>Total #'+ counter + ' : </label>' + '<input type="text" size="3" name="total[]" id="total' + counter + '" value="" onchange="calculate();"> '); newTextBoxDiv.appendTo("#TextBoxesGroup"); counter++; }); $("#removeButton").click(function () { if(counter==0){ alert("No more textbox to remove"); return false; } counter--; $("#TextBoxDiv" + counter).remove(); }); }); HTML Code <table> <tr> <td><strong>Select the products</strong> <input type='button' value='Add Products' id='addButton'> <input type='button' value='Remove Products' id='removeButton'> </td> </tr> </table> <table> <tr> <td> <div id='TextBoxesGroup'> </div> </td> </tr> <tr> <td> <input type="hidden" id="countervalue" name="countervalue" style="display:none;"> </td> </tr> </table> PHP Code <?php include('includes/db.php'); $q = "select TaxID, TaxName from tax"; $sql = mysql_query($q); $data = array(); while($row = mysql_fetch_array($sql, true)){ $data[] = $row; }; echo json_encode($data); ?> I have tried the following part of code to fetch the data from DB and Put into dynamically generated select box but its not working for me. //To Display the tax types from DB $(function(){ var items=""; $.getJSON("get_tax_type.php",function(data){ $.each(data,function(index,item) { items+="<option value='"+item.id+"'>"+item.name+"</option>"; }); $("#tax_type' + counter + '").html(items); }); }); Can any one suggest where am I going wrong or the correct way of doing it. I am new to jquery. Any help is appreciated.Thanks in advance.
  5. Dear all, Here is my scenario, I have a php page called index.php which is linked to dashboard. At the index page i will have 40-50 href's each with a id like dashboard.php/subcat=1 When a user click's particular href they will be forwarded to a page called dashboard and there i get this id. $subcat=$_REQUEST['subcat']; This dashboard is dynamic. In this page i have three different div's. Each with different query and result display. For example: My first div has a query and some 50 results. I want a display first four rows and remaining as a ajax pagination. similarly for the other two div's. There is no problem in using ajax pagination because it will be executed in different page and result will be display here. But the real problem is in each of my query i should pass the original subcat id which is what make the dashboard dynamic. Now, i need someway to pass this dynamic id for my external pagination for each query.
  6. Hello everyone my name is Sania and m here to learn PHP. I just got a website designed and code by a bunch of good programmers, now i m tring to learn few php lines so i can change few lines in the code and add a bit of my own variety in it. Do visit my website and leave your feed back. www.submaza.com
  7. I want to be able to update more than one element with an ajax request. This is for a shopping cart. So when someone removes an item, it will update the quantity in the cart element, #cart_quantity, and I want it to also update the remaining items in the cart, by changing the value of their array. So for example: cart_quantity = 4 item1 (array = 0) item2 (array = 1) item3 (array = 2) item4 (array = 3) When I remove item2 from the cart I then want all the array values to be updated (they are contained within a hidden input form), so it should be become; cart_quantity = 3 item1 (array = 0) item3 (array = 1) item4 (array = 2) So in the ajax request I have updated the cart_quantity, and the number of the items in the array. I know I can do this with 2 ajax requests, but is there someway it can be done with just one? For example I have the success part of the ajax query as: success : function(data) { $('#cart_quantity').html(data); } is there someway we can set up something like: success : function(data1) { $('#cart_quantity').html(data1); }, function(data2) { $('#cart_items').html(data2); } Or do you simply have to do two ajax requests? Or are there any other alternatives?
  8. Topic: custom jquery/ajax form in a sidebar template page The website Hi everyone, I made a custom form in a sidebar template page – a plugin is not an option. I got the validation working but the processing runs foul. Next I will explain in more detail what I did. Let me start off by saying: I am noob (and that’s probably stretching it). My problem – in short – is that a contact form validated with the jquery validation plugin, and submitted through ajax does not end up in my mailbox. And yes, I have a form processor php scrip attached but something goes wrong. But I don’t know what. Now I have been searching the internets for an answer. Of course I don’t thoroughly understand the javascript and php stuff. None the less I did put the necessary scripts together in accordance with the many explanations that I have read. My own guess Before I will show you the custom scripts I want to address what I think is going foul. I made a valid html form. I used the jquery validation plugin to use the validate function on the various fields. And I added some custom jquery to tell the validation plugin exactly what fields are required. On top of that I added ajax, via the jquery form plugin, so that the form doesn’t reload upon submittal. Now the validation works – see for yourself here. And as soon as all fields are filled out correctly, and I press submit ajax kicks in because I see the button value change as intended. After a short load – sending sequence – the button changes to ‘message send’. But I receive no email. And I have checked my spam folder: it’s empty. In previous tests – with a different script – I did receive emails with the contact form values (but there were other issues). I am using this contact form in a WordPress template. Perhaps it is the php processor? But I can’t see what’s wrong with that file. Also in Firebug, under ‘console’ I see a GET string with the form values after submittal. My question is. Can someone take a look at the form (because I think the post action might be wrong, the form processor is located in the template file), the custom jquery script and the php script? Plus after the form is successfully submitted, via ajax, I would like the form to reset, to clear all fields; how would I do that? Btw I read somewhere I can use a WordPress function to add the admin e-mailaddress in the php form processor – where you would normally put down the receivers emailaddress. Is this true? And how would I do this? Any help is seriously appreciated. Thank you for your time. You can check the script and code over at Pastebin: Sidebar template page containing the htlm form http://pastebin.com/0Ucn306n Custom jquery form validation script http://pastebin.com/xxPdV7eL Php form processor http://pastebin.com/1LKVPx2v
  9. Hi I am not familiar with ajax. pls help me how i can do in script Below my script and using pdo and mssql 2005. Below script working fine. But everytime change the details, page refresh and display is delayed Pls help me --------------------------------------------------------------------------- index.php ---------------------------------------------------------------------------------------------- <?php include_once '../inc/connection.inc.php'; ?> <?php try { $stmt = $dbh->prepare('SELECT * FROM MVendorMaster order by MVName'); $stmt->execute(); } catch (PDOException $e) { $output = 'Error fetching main vendor from database!'; include '../errormsg.php'; exit(); } foreach ($stmt as $row) { $mvcode[] = array('MVCode' => $row['MVCode'], 'MVName' => $row['MVName']); } include 'searchform.html.php'; ?> <?php if (isset($_POST['mvendor']) && $_POST['mvendor'] != "" ) { $mvcode = $_POST["mvendor"]; $datefrom=$_POST["datefrom"]; $dateto=$_POST["dateto"]; $stmt = $dbh->query("SELECT * FROM InvoiceHead WHERE MVCode='$mvcode' and SODate>='$datefrom' and SODate<='$dateto' order by SODate"); $stmt->setFetchMode(PDO::FETCH_ASSOC); } include 'view.html.php'; exit(); ?> --------------------------------------------------------- searchform.html.php------------------------------------------- <?php include '../templete/header.php'; ?> <form action="" method="post"> <table> <tr> <td>Main Vendor Name </td> <td> <select name="mvendor" id="mvcode"><option value="">Mian Vendor</option> <?php foreach ($mvcode as $mvcodes): ?> <option value="<?php htmlout($mvcodes['MVCode']); ?>"> <?php htmlout($mvcodes['MVName']); ?></option> <?php endforeach; ?> </select> </td> </tr> <tr> <td>Date[From]:</td> <td><input type="text" id="datepicker1" name="datefrom" /></td> </tr> <tr> <td>Date[To]:</td> <td><input type="text" id="datepicker2" name="dateto" /></td> </tr> </table> <div> <input type="submit" value="Search"> </div> </form> ------------------------------------------------------------------------ view.html.php ----------------------------------------------------------------------- <?php //include '../templete/header.php'; ?> <script language="javascript" type="text/javascript"> //window.print(); </script> <script type="text/javascript"> function PrintGridData() { var prtGrid = document.getElementById('<%=txtDocNo%>'); prtGrid.border = 0; var prtwin = window.open('', 'PrintGridViewData', 'left=100,top=100,width=1000,height=1000,tollbar=0,scrollbars=1,status=0,resizable=1'); prtwin.document.write(prtGrid.outerHTML); prtwin.document.close(); prtwin.focus(); prtwin.print(); prtwin.close(); </script> <table width="100%" align="center" cellpadding="4" cellspacing="1" class=tbl_table"> <tr> <td class="tbl_header">MV CODE</td> <td class="tbl_header">MV NAME</td> <td class="tbl_header">SONO</td> <td class="tbl_header">SO Date</td> <td class="tbl_header">RATE</td> <td class="tbl_header">SUPP.QTY</td> <td class="tbl_header">RTN.QTY</td> <td class="tbl_header">BAL.Qty</td> <td class="tbl_header">SOLD AMT</td> <td class="tbl_header">Actions</td> </tr> <?php if(isset($stmt)) { while($row = $stmt->fetch()) {?> <tr> <td class="tbl_content"><?php echo $row['MVCode'];?></td> <td class="tbl_content"><?php echo $row['MVName'];?></td> <td class="tbl_content"><?php echo $row['SONo'];?></td> <td class="tbl_content"><?php echo date("d-m-Y", strtotime($row['SODate']));?></td> <td class="tbl_content_right"><?php echo number_format($row['Rate'],2) ;?></td> <td class="tbl_content_right"><?php echo number_format($row['Qty']) ;?></td> <td class="tbl_content_right"><?php echo number_format($row['RTNQty']) ;?></td> <td class="tbl_content_right"><?php echo number_format($row['BalQty']) ;?></td> <td class="tbl_content_right"><?php echo number_format($row['BalAmt'],2) ;?></td> <!--number_format <td> <a href="view?=<?php echo $row['SVCode'];?>">View</a> | <a href="edit?=<?php echo $row['SVCode'];?>">Edit</a> | <a href="delete?=<?php echo $row['SVCode'];?>">Delete</a> </td> --> </tr> <?php }}?> </table> <?php unset($dbh); unset($stmt); ?> <?php include '../templete/footer.php'; ?> --------------------------------------------- Data connection --------------------------------------------- <?php try { $hostname = "server"; //host $dbname = "db1"; //db name $username = "sa"; // username like 'sa' $pw = "7hjer34s$%"; // password for the user $dbh = new PDO ("mssql:host=$hostname;dbname=$dbname","$username","$pw"); } catch (PDOException $e) { echo "cannot connect " . $e->getMessage() . "\n"; file_put_contents('PDOErrors.txt', $e->getMessage(), FILE_APPEND); exit; } ?> Pls help how can i add ajax in this page thanking you maideen
  10. I have an index.php that loads a page.php into a #result div. Page.php in turn has its own links and I have it so that when you click on one of these links it loads the respective page into the SAME #result div. Similarly that loaded page might have its own links and I want to continue loading content into the same div. The code for this is as follows: function loadPage(url){ $("#wrapper").load(url, function(){ $("#wrapper").find($('a')).each(function(){ $(this).on('click', function(e){ loadPage($(this).attr('href')); e.preventDefault(); }); }); }); } Say page.php has a link to page2.php. At the moment when I open the link to page2.php in a new window, it opens as page2.php. Same if I type the url to page2.php directly into my browser. I want it so that it opens as index.php but with page2.php loaded into its #result div(a duplicate of clicking the link normally in the original window). How do you do this?? I have tried lots of things including setting a session variable and passing to loadPage, but nothing seems to work.
  11. Hey guys! First time post here and I am only a begginer in programming. Anyway I have a few questions as I am stuck and have been for quite a while. I know this is a long post but it will cover the whole entire process of what I am doing at the moment. I really appreciate the time anyone can give me and will be happy to paypal someone over some $ for any help they can give me. Firstly, I am working with a bit of javascript and PHP. I am using a javascript method to update content from my table data in mysql without reloading the page. It works very well but I want to simplify the way i do things with the javascript so I am not left with repetative lines of code. Here is my javascript: $(document).ready(function() { //Edit link action (1) $('.edit_link').click(function(){$('.text_wrapper').hide(); var data=$('.text_wrapper').html(); $('.edit').show();$('.editbox').html(data);$('.editbox').focus();}); //Edit link action (2) $('.edit_link2').click(function(){$('.text_wrapper2').hide(); var data=$('.text_wrapper2').html();$('.edit2').show(); $('.editbox2').html(data);$('.editbox2').focus();}); //Mouseup textarea false (1) $(".editbox").mouseup(function(){return false}); //Mouseup textarea false (2) $(".editbox2").mouseup(function(){return false}); //Textarea content editing (1) $(".editbox").change(function(){$('.edit').hide();var boxval = $(".editbox").val(); var dataString = 'data='+ boxval;$.ajax({type: "POST",url: "update.php",data: dataString,cache: false,success: function(html){$('.text_wrapper').html(boxval);$('.text_wrapper').show();}});}); //Textarea content editing (2) $(".editbox2").change(function(){$('.edit2').hide(); var boxval = $(".editbox2").val();var dataString = 'data2='+ boxval;$.ajax({type: "POST",url: "update.php",data: dataString,cache: false,success: function(html){$('.text_wrapper2').html(boxval);$('.text_wrapper2').show();}});}); //Textarea without editing (1) $(document).mouseup(function(){$('.edit').hide();$('.text_wrapper').show();}); //Textarea without editing (2) $(document).mouseup(function(){$('.edit2').hide();$('.text_wrapper2').show();}); }); As you can see I am having to repeat the functions and all I do is change the name. Instead of repeating the script like I am over and over again to recognise different textareas is there a way I can array it or something like this so I don't have endless lines of the same code over and over again? I have allot more then just 2 textareas but of course shortened it for this post. Here is how I UPDATE the data in MySQL. I am looking into moving this over to PDO as I have be learning that PDO is the more safe and finctional option. My question here would be is there a simple way to UPDATE the rows instead of the way I doing this by repeating this process over and over again? I know I can use the: if (isset()); but I am troubled to work out how I would define the "id" of the data I am changing? <?php include("connection.php"); if($_POST['data']) { $data=$_POST['data']; $data = mysql_escape_String($data); $sql = "update slider set content='$data' where id='1'"; mysql_query( $sql); } if($_POST['data2']) { $data2=$_POST['data2']; $data2 = mysql_escape_String($data2); $sql = "update slider set content='$data2' where id='2'"; mysql_query( $sql); } ?> The HTML is quite simple. The form is wrapped in a div and the "edit" link is defined by class which again I repeat by just copy and past, the select is done via "id" which I need to define in the UPDATE section: <a href="#" class="edit_link" title="Edit">Edit</a> <? $sql=mysql_query("select content from slider where id='1'"); $row=mysql_fetch_array($sql); $profile=$row['content']; ?> <div class="text_wrapper" style=""><?php echo $profile; ?></div> <div class="edit" style="display:none"> <textarea class="editbox" cols="23" rows="3" name="profile_box"></textarea> </div> <a href="#" class="edit_link2" title="Edit">Edit</a> <? $sql=mysql_query("select content from slider where id='2'"); $row=mysql_fetch_array($sql); $profile=$row['content']; ?> <div class="text_wrapper2" style=""><?php echo $profile; ?></div> <div class="edit2" style="display:none"> <textarea class="editbox2" cols="23" rows="3" name="profile_box"></textarea> </div> I hate asking for help but I really need some guidence here as myself and Javascript are not good friends and myself and PHP are just starting a relationship, if you know what I mean. Any examples of how to achieve this? I do beleive if anyone could put me in the right direction it would be a great script to share around as it is very functional. I apologize for such a large post, however I really am stuck and have gone this far. I have researched google but find i just keep getting stuck. Idealy I just want to simplify the whole script, make it more functional and save myself the repetative task of going over the same thing again and again.
  12. Hi everyone! This is another n00b question but here goes... Say I have an index.php that loads a page.php into one of its divs. So: $('#result').load('page.php'); page.php in turn has its own links and I want it so that when you click on one of these links it loads the respective page into the SAME #result div. Similarly that loaded page might have its own links and I want to continue loading content into the same div. How might I achieve this chain effect of pages? Thank you for your time!
  13. I am trying to connect to a server socket which will send me a bunch of data after connecting, take a response from me, and then send a bunch more data, repeating this process until it determines its had enough. So basically, after first~ connecting, we will (and currently are) receiving data from the server. We want to take this data, compute it in another script/program passing with AJAX, and then return to this and respond to the server. We're afraid that once we take data from the server, go to compute the data, the socket is going to close and we're not going to be able to continue where we left off. How can we make sure that php persists in its connection to this socket? I've looked into fsockopen and I'm not quite understanding of it and whether it will help here or not. Any assistance? // create socket //$socket = socket_create(AF_INET, SOCK_STREAM, 0) or die("Could not create socket\n"); $socket = fsockopen($host, $port, $errno, $errstr, 30); if (!$socket) { echo "$errstr ($errno)<br />\n"; } $_SESSION['socket'] = $socket; // receive DATA from server //$result = socket_connect($socket, $host, $port) or die("Could not connect to server\n"); echo "Connected to server"; //$_SESSION['connection'] = $result;\ //STOP, PASS DATA, COMPUTE, SEND RESPONSE // send response to server fwrite($socket, $message1) or die("Could not send data to server\n"); // get data server response $result = fread ($socket, 1024) or die("Could not read server response\n"); echo "<br>Reply From Server :".$result; // close socket fclose($socket);
  14. I have a form that has 2 dropdown lists (Diplomas, Fields), a submit button and an "Add" button that copies the selected values of the dropdownlists to some dynamically generated textboxes as long as the number of the textboxes is lower than 5 This is the code of the dipSecSelection.php file included inside the form: <!----------- The dipSecSelection File -------------> <div id="dipSecSelection"> <table> <tr> <td><label for="diplomes">Diplome:</label></td> <td> <select name="Diplomes" id="Diplomes"> <option value="na">--Diplome--</option> <option value="Technician">Technician</option> <option value="Master">Master</option> <option value="PhD">PhD</option> </select> </td> <td id="separator">|</td><!-- Separator --> <td><label for="secteurs">Secteur:</label></td> <td> <select name="Secteurs" id="Secteurs"> <option value="na">--Secteur--</option> <option value="Software Dev">Software Dev</option> <option value="Engineering">Engineering</option> <option value="Physics">Physics</option> </select> </td> <td> <a href="#" Onclick="addDipSec()" value="Add" class="button">Add</a> </td> </tr> </table> <table> <tr> <td><div id='DipTextBoxesGroup'></div></td> <td><div id='SecTextBoxesGroup'></div></td> </tr> </table> </div> <script type="text/javascript"> //Diplomas textBoxes!!! var counterdip = 1; var countersec = 1; function addDipSec(){ if(counter>5){ alert("Only 5 Diplomas allow"); return false; } var newTextBoxDiv = $(document.createElement('div')).attr("id", 'TextBoxDiv' + counterdip); newTextBoxDiv.after().html('<label>Diplome #'+ counterdip + ' : </label>' + '<input type="text" name="dipBox[]" id="textboxdip' + counterdip + '" value="" >'); newTextBoxDiv.appendTo("#DipTextBoxesGroup"); $('#textboxdip'+counterdip).val($('#Diplomes option:selected').html()); counter++; //Secteurs textBoxes if(countersec>5){ alert("Only 5 Setors are allowed"); return false; } var newTextBoxDiv = $(document.createElement('div')).attr("id", 'TextBoxDiv' + countersec); newTextBoxDiv.after().html('<label>Secteur #'+ countersec + ' : </label>' + '<input type="text" name="secBox[]" id="textboxsec' + countersec + '" value="" size="35">'); newTextBoxDiv.appendTo("#SecTextBoxesGroup"); $('#textboxsec'+countersec).val($('#Secteurs option:selected').html()); countersec++; alert(secBox[0].val); } </script> This is the php code: <form action="<?php echo $_SERVER['REQUEST_URI']; ?>" method="POST" enctype="multipart/form-data"> <?php include'includes/dipSecSelection.php'?> <?php if(isset($_POST['dipBox']) && isset($_POST['secBox'])){ if(!empty($_POST['dipBox'])&&!empty($_POST['secBox'])){ $dip= $_POST['dipBox']; $sec= $_POST['secBox']; $N = count($dip); for($i=0; $i < $N; $i++){ $add_AnnDipSec = "INSERT INTO annDipSec VALUES('$dip[$i]','$sec[$i]')"; if(mysqli_query($connection, $add_AnnDipSec)){ echo'Successfully Added to AnnDipSec'; }else{echo'Error while trying to insert into AnnDipSec';} } }else{echo"Dip and Sec were Empty";} } ?> <input type="submit" name="submit" value="Submit" class='button'> </form> Problem is that dipBox[] and secBox[] never get set and always return nothing so they never get inserted to the database table.
  15. Dear members, I m running with the following problem for more than a week but i m not able to sort out. The scenario is that, in one of my php form i m having two dropdown and a text box related to each other. i.e when i select a product from dropdown1, the values of dropdown2 will be sorted based on the value of dropdown1 and similarly based on the value of dropdown2 , the value of textbox will be shown. This i accomplished with the help of ajax and jquery. And also this one working for me very well(shown in the image 1&2 of attachements). But the issue now is, in my product selection, my product list went very long so i had to bring an auto-suggestion. i brought the jquery selection with auto-complete model which has been shown in the same attachment(image3&4). the issue now is, when i select the product from my first dropdown, the second dropdown value is not loading, with firebug i checked, the values are properly retrieved for second dropdwn based on first drpdown but its not shwn up in the value list of second dropdwn. I don know what exactly the problem is. I m thinking it might be the clash of jquery versions that i m using. So, can some sort me out the problem with my form. I have included the form code here. <link rel="stylesheet" href="<?php echo HOME_URL; ?>chosen/chosen.css" /> <style type="text/css"> td { width:800px; } </style> <script src="http://code.jquery.com/ui/1.9.2/jquery-ui.js"></script> <script type="text/javascript" charset="utf-8"> $(function(){ $("select#product_id").change(function(){ var get_package_url = '<?php echo HOME_URL; ?>select.php'; $.getJSON(get_package_url,{product_id: $(this).val(), ajax: 'true'}, function(j){ var options = ''; options += '<option value="0"> -- Select -- </option>'; for (var i = 0; i < j.length; i++) { options += '<option value="' + j[i].optionValue + '">' + j[i].optionDisplay + '</option>'; } $("select#package_id").html(options); }) }) $("select#package_id").change(function(){ var get_package_url = '<?php echo HOME_URL; ?>select.php'; $.getJSON(get_package_url,{package_id: $(this).val(), ajax: 'true'}, function(j){ for (var i = 0; i < j.length; i++) { var value = j[i].optionDisplay; } $("#package_qty").val(value); }) }) }) </script> <script> $(function() { $( "#datepicker" ).datepicker({ altFormat: "dd-mm-yyyy" }); }); </script> <form action="<?php echo base_url(); ?>purchase_order/add" method="post"> <table border="1"> <tr> <td> <b>Product </b> <select name="product_id" style="width:250px;" data-placeholder="Choose a Supplier..." id="product_id" class="chzn-select"> <option value="0"> -- Select Product -- </option> <?php foreach($get_all_product as $value) { ?> <option value="<?php echo $value['product_id']; ?>"><?php echo $value['product_name']; ?></option> <?php }?> </select> </td> <td> <b>Order Qty </b> <input type="text" name="quantity" value="" style="width:75px;" /></td> <td> <b>Package</b> <select name="package_id" id="package_id"> </select> </td> <td> <b> Qty / Packing</b> <input type="text" name="package_qty" id="package_qty" value="" readonly="readonly" style="width:75px;" /></td> <td colspan="2"> <input type="submit" name="submit" value="Add to Cart" /> </td> </tr> </table> <script src="<?php echo HOME_URL; ?>chosen/chosen.jquery.js" type="text/javascript"></script> <script type="text/javascript"> $(".chzn-select").chosen(); $(".chzn-select-deselect").chosen({allow_single_deselect:true}); </script> </form><br/><br/> <?php if($this->cart->contents()) { ?> <h2>Ordered Cart</h2> <br/> <table border="1"> <tr> <td> <b> Product </b> </td> <td> <b> Order Qty</b> </td> <td> <b>Qty/ Packing</b></td> <td> <b> MRP</b> </td> <td align="right"> <b>Amount </b></td> <td align="right"> <b>Action </b></td> </tr> <?php $grand_total = 0; foreach ($this->cart->contents() as $items) { ?> <tr> <td> <?php echo $items['name']; ?></td> <td> <?php echo $items['qty']; ?></td> <td> <?php echo $items['package_qty']; ?></td> <td> <?php echo $items['price'];//money_format('%!i',$items['price']); ?></td> <td align="right"> <?php echo $items['amount'];//money_format('%!i', $items['amount']); $grand_total = $items['amount']+$grand_total; $discount= $grand_total * 40/100; $gross_amount = $grand_total-$discount; ?></td> <td align="right"> Remove </td> </tr> <?php } ?> <tr> <td colspan="5" align="right"><b>Grand Total</b></td> <td align="right"><b><?php echo $grand_total;//money_format('%!i', $grand_total); ?></b></td> </table> <form method="post" action="<?php echo base_url()."purchase_order/create"; ?>"> <BR/> <BR/> Addtional Details : <textarea rows="5" cols="80" name="info"></textarea> <BR/> Date : <input type="text" name="date" value="<?php echo date('d-m-Y'); ?>" /><br/><br/><br/> <h2> Approximate value of Order</h2><br/> <b>Gross Amount:<b><?php echo $grand_total;?><br/> <b>Less Discount @ 40%:<b><?php echo $discount;?><br/> <b>Net Amount:<b><?php echo $gross_amount;?><br/> <input type="submit" name="submit" value="Create PO" /> </form> <?php } ?>
  16. could any one get me the code for retrieving a table from database using stored procedures and editing that table as well and again displaying that table using ajax in the same page.
  17. Hi folks! Im trying to implement an Ajax chat client to my website, and im having issues with the implementation of the files., This is a third party code, the link is here... http://ajaxim.com/ Now, i have my database set up etc... but when i implement this code into my pages, the chat box doesnt show, and if i ftp the ajaxim.php file in standalone as it were, i get this error, even though the files are there. Fatal error: require_once() [function.require]: Failed opening required '../ajaxim/libraries/dbMySQL.php' (include_path='.:/usr/lib/php:/usr/local/lib/php') in /home/guyrich/public_html/ajaxim/ajaxim.php on line 30 The snippet of code im using to implement the chat system in my <head> is <script type="text/javascript" src="ajaxim/js/im.load.js"></script> This is bugging me big time, and by the sounds of it, others are having this issue also. Im not excellent with coding, im a learner. Your help is most appreciated
  18. $_FILE uploading is empty. I've been doing this upload 2 days but my image file won't move to the site directory, and I dump the $_FILES I see that everytime I post It returned empty, but on my localhost (pc that I'm using) it is working. On the site using IIS7 server, I see the file return everytime I upload on the windows/temp, but the file not moving to the directory of the site. I already use 3 plugin's for uploading but still it won't do. I am using codeigniter framework. Anyone can give an idea about the problem?
  19. what I am trying to do is something similar to a shopping cart. I am using ajax to display the search results. when i click on one item from the results it gets added to another paragraph. The problem is that when i select the second item it is appended as string to the last item. For example if I select books and pens. It shows bookspens I want each item to be shown separately so that i can send the seperate values to a php script for inserting it as requested items. how can i achieve this without jquery This is the code search.php $keyword = mysql_real_escape_string($_POST['search_res']); $search_q = mysql_query("Select * from products where pname like '%$keyword%'"); if(mysql_num_rows($search_q)!=0) { while($result = mysql_fetch_array($search_q)) { $productid = $result['id']; $name = $result['pname']; echo "<input type='button' name='resultname' id='$productid' value='$name' onclick='throwval(this)'><br/>"; } } index.php <html> <head> <script language="javascript"> function showresult() { var product_name = document.getElementById("searchval").value; if(window.XMLHttpRequest) { XMLHttpRequestObject = new XMLHttpRequest(); } else if(window.ActiveXObject) { XMLHttpRequestObject = new ActiveXObject("Microsoft.XMLHTTP"); } XMLHttpRequestObject.open("POST", "search.php", true); XMLHttpRequestObject.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); XMLHttpRequestObject.send("search_res=" + product_name); XMLHttpRequestObject.onreadystatechange = function() { if(XMLHttpRequestObject.readyState == 4) { if(XMLHttpRequestObject.status == 200) { document.getElementById("displayresult").innerHTML = XMLHttpRequestObject.responseText; } } } } function throwval(obj) { var sent_id = obj.id; var v = document.getElementById(sent_id).value; var content = document.createTextNode(v); document.getElementById("newdiv").appendChild(content); } function sendvalues() { var data = document.getElementById("newdiv").textContent; alert(data); } </script> </head> <body> <!--Search Form--> <form method="post" name ="searchform" id="idsearchform" > <input type="text" name="search" id="searchval" /> <input type="button" name="starts" id="btn" value="startsearch" onclick="showresult()"/> </form> <div id="displayresult"> <!--Search results will be displayed here--> </div> Selected : <p id='newdiv'> <!--Selected values will be displayed here--> </p> <form name="form1" method="post" action="send_data.php"> <input type="button" id="sendtophp" name="sendingval" value="next step" onclick="sendvalues()"> </form> <p id='fetched'> </p> </body> </html>
  20. I've searched everywhere and just can't seem to find my answer, so here: I'm powerful with php and that I can deal with, but I never really had the chance to develop my javascript skills. I want to use JQuery to load part of a page in a container div. The problem is every tutorial I check out, the target (or result) div where the content will load is already defined in the function. Is there a way to include 2 arguments like this : (pseudo-code, I don't know the real syntax, still a newb at JQuery) function ajaxpage(url, containerid){ // do the magic here } // and calling the page <a href="javascriptTheJQueryWayHere:ajaxpage('page.php?id=12','load_in_this_div')">link</a> <div id="load_in_this_div"></div> I don't necessarily want a baked answer, just any link to any resource except RTFM would be of great help!
  21. <!DOCTYPE html> <html lang="en"> <head> <script type="text/javascript" src="retire_calc2.js"></script> <link rel="stylesheet" type="text/css" href="retire_calc2.css"> </head> <body> <title> Retirement Calculator </title> <center> <hr size="10" noshade> <h1> Welcome to your Retirement Calculator </h1> <hr size="10" noshade> <br><br><br> <form id="myRetCalcForm" action="retire_calc2.php" method="post"> Current Age: <input type="text" id="currentAge" name="currentAge" /><br /> <p class="errorText" id="currentAgeError"></p> Contribution Amount: <input type="text" id="contAmount" name="contAmount"> <sele ct name="frequencyOption"> <option value="yearly">Annually</option> <option valu e="monthly">Monthly</option> </select> <p class="errorText" id="contAmountError"></p> Interest Rate (Percent): <input type="text" id="intRate" name="intRate" /><br / > <p class="errorText" id="intRateError"></p> <p class="typicalReply" id="typicalReply"></p> </form> <script type="text/javascript" src="retire_calc2.js"></script> <hr/> Result: <div id="result"></div> </body> </html> function validateAge() { currentAgeField = document.getElementById("currentAge"); currentAge = currentAgeField.value; var properAge = currentAge < 65 && currentAge > 0; var ageError = document.getElementById("currentAgeError"); if(properAge) { currentAgeField.className = "okInput"; ageError.innerHTML = ""; return true; } else { currentAgeField.className = "errorInput"; ageError.innerHTML = "The age has to be between 0 and 65."; return false; } } document.getElementById("currentAge").onchange = validateAge; function validateContAmount() { contAmountField = document.getElementById("contAmount"); contAmount= contAmountField.value; var properAmount = contAmount > 0; var amountError = document.getElementById("contAmountError"); if(properAmount) { contAmountField.className="okInput"; amountError.innerHTML = ""; return true; } else { contAmountField.className = "errorInput"; amountError.innerHTML = "Please enter an amount that is greater than 0." ; return false; } } document.getElementById("contAmount").onchange = validateContAmount; function validateIntRate() { intRateField = document.getElementById("intRate"); intRate = intRateField.value; var properIntRate = intRate > 0; var intRateError = document.getElementById("intRateError"); if(properIntRate) { intRateField.className = "okInput"; intRateError. innerHTML = ""; return true; } else { intRateField.className = "errorInput"; intRateError.innerHTML = "Please enter an interest rate greater then 0."; return false; } } document.getElementById("intRate").onchange = validateIntRate; function formatMoney(num) { num = num.toFixed(2); return num.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","); } function parseResult() { if (this.readyState == 4 && this.status == 200) { var result = document.getElementById("result"); result.innterText = this.responseText; } } function makeAjaxRequest() { var ajax = new XMLHttpRequest(); ajax.onreadystatechange = parseResult; ajax.open("GET", "retire_calc2.php?" + getValues()); ajax.send(null); } function getValues() { var values = ""; for (var i=0; i<=last; ++i) { if (i>0) values += "&"; var v = document.getElementById("v" + i).value; values += "v[" + i + "]=" + v; } return encodeURI(values); } function validateAll() { for (var i=0; i<=last; ++i) { if (!validate(i)) { return false; } } makeAjaxRequest(); return true; } { background-color: white; } .errorInput { background-color: yellow; } .errorText { color: red; } <html> <head> <title>Process the HTML form</title> </head> <body> <?php $age = $_POST["currentAge"]; $contribution = $_POST["contAmount"]; $rate = $_POST["intRate"]; echo '<pre>'; printf('%3s | %10s | %10s<br>', 'Age', 'Interest', 'Total Amount'); for ($y=$age+1; $y<=65; $y++) { $capital += $contribution; $interest = $capital*$rate/100; $capital += $interest; printf('%3d | %10.2f | %10.2f<br>', $y, $interest, $capital); } $ret = "65"; $years = 100-$ret; $takeout = $capital/$years; print "<br/>"; print "Final Results:"; print "<br/>"; print "<br/>"; $formattedAmount = number_format($capital, 2); print "Total: "; print "$"; echo $formattedAmount; print "<br/>"; print "<br/>"; $formattedAmount = number_format($interest, 2); print "Interest Earned: "; print "$"; echo $formattedAmount; print "<br/>"; print "<br/>"; print "After retirement, you will be able to take out "; print "$"; print number_format($takeout, 2); print " per year."; ?> </body> </html>
  22. Hello, I am new to ajax and javascript and am trying to create a search engine This is the javascript code var XMLHttpRequestObject = false; if(window.XMLHttpRequest) { XMLHttpRequestObject = new XMLHttpRequest(); } else if(window.ActiveXObject) { XMLHttpRequestObject = new ActiveXObject("Microsoft.XMLHTTP"); } function showresult(search) { if(XMLHttpRequestObject) { var obj = document.getElementById("showresult"); XMLHttpRequestObject.open("POST","index.php",true); XMLHttpRequestObject.setRequestHeader("Content-type","application/x-www-form-urlencoded"); XMLHttpRequestObject.onreadystatechange = function() { if(XMLHttpRequestObject.readystate == 4 $$ XMLHttpRequestObject.status == 200) { obj.innerHTML = XMLHttpRequestObject.responseText; } } XMLHttpRequestObject.send("search=" + search); } //alert("You clicked me"); } PHP + HTML: <form method="post" name ="searchform" id="idsearchform" > <input type="text" name="search"/> <input type="button" name="starts" value="search" onclick="fun(search)"/> </form> <?php if(isset($_POST['starts'])) { $keyword = $_POST['search']; $search_q = mysql_query("Select * from products where pname like '%$keyword%'"); if(mysql_num_rows($search_q)!=0) { while($result = mysql_fetch_array($search_q)) { ?> <div id="showresult"> <?php $name = $result['pname']; echo "$name<br/>"; } } }?> </div> I don't get the search results when i click the search button. What is the issue here
  23. i have a many links like these <a href="www.ex.com/action.php?me=1">member1</a> i wanted to get this by ajax get method.. <script> $("a.member").click(function(e){ $.ajax({ type: "GET", url: "action.php?me=", data: "me=" + me, success: function(data){ alert(data); } }); return false; e.preventDefault(); }); </script> i know somethin wrong here..am in re.php..i am using this to navigate to action.php file.. Any help appreciated..
  24. Hello, New here so apologies if I commit any rule breaks regarding posting. I have been given basic javascript functions with in a HTML page that is supposed to fetch values from a already created database and input these values into the table on the page. Please see this link as an example: http://www.eng.nene.ac.uk/~10406206/CSY2028/Ajax/Ajax.html As you can see there is a table with headers. When the 'Load Database' button is clicked the function is supposed to load the database values into the correct cells. However this does not happen. There is an alert which displays correct information from the database but the values do not get entered into the table? I need to know why this is the case as I have no idea where to go to fix this. Edit: The alert was displaying my database values but now it is not. No errors displaying in the console. I am new to Javascript and Ajax coding so I apologise in advance. Below is the Javascript Functions. <script language="Javascript"> var xmlHttpReq = false; var xmlHttpReq2 = false; var xmlHttpReq3 = false; function appendRecord (id, carname, fueltype, transmission, enginesize, doors, total, available) { //rowcount ++; //if (firstname == "") return; mytable = document.getElementById ("DBTable"); mycurrent_row = document.createElement ("tr"); mycurrent_row.setAttribute ("id", "DB"+id); mycurrent_cell = document.createElement ("td"); currenttext = document.createTextNode (id); mycurrent_cell.appendChild (currenttext); mycurrent_row.appendChild (mycurrent_cell); mycurrent_cell = document.createElement ("td"); currenttext = document.createTextNode (carname); mycurrent_cell.appendChild (currenttext); mycurrent_row.appendChild (mycurrent_cell); mycurrent_cell = document.createElement ("td"); currenttext = document.createTextNode (fueltype); mycurrent_cell.appendChild (currenttext); mycurrent_row.appendChild (mycurrent_cell); mycurrent_cell = document.createElement ("td"); currenttext = document.createTextNode (transmission); mycurrent_cell.appendChild (currenttext); mycurrent_row.appendChild (mycurrent_cell); mycurrent_cell = document.createElement ("td"); currenttext = document.createTextNode (enginesize); mycurrent_cell.appendChild (currenttext); mycurrent_row.appendChild (mycurrent_cell); mycurrent_cell = document.createElement ("td"); currenttext = document.createTextNode (doors); mycurrent_cell.appendChild (currenttext); mycurrent_row.appendChild (mycurrent_cell); mycurrent_cell = document.createElement ("td"); currenttext = document.createTextNode (total); mycurrent_cell.appendChild (currenttext); mycurrent_row.appendChild (mycurrent_cell); mycurrent_cell = document.createElement ("td"); currenttext = document.createTextNode (available); mycurrent_cell.appendChild (currenttext); mycurrent_row.appendChild (mycurrent_cell); mycurrent_cell = document.createElement ("td"); mycurrent_input = document.createElement ("input"); mycurrent_input.setAttribute ("type", "button"); mycurrent_input.setAttribute ("value", "modify"); mycurrent_input.setAttribute ("onclick", "modifyOrUpdateRecord (" + id + ", this)"); mycurrent_cell.appendChild (mycurrent_input); mycurrent_row.appendChild (mycurrent_cell); mycurrent_cell = document.createElement ("td"); mycurrent_input = document.createElement ("input"); mycurrent_input.setAttribute ("type", "button"); mycurrent_input.setAttribute ("value", "delete"); mycurrent_input.setAttribute ("onclick", "deleteRecord (" + id + ")"); mycurrent_cell.appendChild (mycurrent_input); mycurrent_row.appendChild (mycurrent_cell); mytable.appendChild (mycurrent_row); } function loadDatabaseRecordsCallback () { if (xmlHttpReq.readyState == 4) { alert ("From Server (Load Records):\n" + xmlHttpReq.responseText); var record = xmlHttpReq.responseXML.getElementsByTagName('record'); var s = ""; for (var i = 0; i < record.length; i ++) { var rec = record[i]; var id = rec.getElementsByTagName("ID")[0].firstChild.data; var carname = rec.getElementsByTagName("CARNAME")[0].firstChild.data; var fueltype = rec.getElementsByTagName("FUELTYPE")[0].firstChild.data; var transmission = rec.getElementsByTagName("TRANSMISSION")[0].firstChild.data; var enginesize = rec.getElementsByTagName("ENGINESIZE")[0].firstChild.data; var doors = rec.getElementsByTagName("DOORS")[0].firstChild.data; var total = rec.getElementsByTagName("TOTAL")[0].firstChild.data; var available = rec.getElementsByTagName("AVAILBLE")[0].firstChild.data; appendRecord (id, carname, fueltype, transmission, enginesize, doors, total, available); } } } function loadDatabaseRecords () { // Mozilla/Safari if (window.XMLHttpRequest) { xmlHttpReq = new XMLHttpRequest(); } // IE else if (window.ActiveXObject) { xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP"); } alert ("To Server (Load Records):\n\nload.php"); xmlHttpReq.open('GET', "load.php", true); xmlHttpReq.onreadystatechange = loadDatabaseRecordsCallback; xmlHttpReq.send(null); } The loaddatabaserecords function calls the load.php file which is below <?php $link = mysql_connect ("194.81.104.22", "xxxx", "xxxxx"); mysql_select_db ("db10406206"); $query = "SELECT * from XYZ"; $result = mysql_query ($query); header ("Content-Type: application/xml"); print ("<?xml version=\"1.0\" ?>"); print "\n<database>\n"; for ($i = 0; $i < mysql_num_rows ($result); $i ++) { $row = mysql_fetch_object ($result); print " <record>\n"; print " <id>$row->ID</id>\n"; print " <carname>$row->CARNAME</carname>\n"; print " <fueltype>$row->FUELTYPE</fueltype>\n"; print " <transmission>$row->TRANSMISSION</transmission>\n"; print " <enginesize>$row->ENGINESIZE</enginesize>\n"; print " <doors>$row->DOORS</doors>\n"; print " <total>$row->TOTAL</total>\n"; print " <available>$row->AVAILABLE</available>\n"; print " </record>\n"; } print "</database>\n"; mysql_close ($link); ?> Finally this is the html table etc etc. <form name="f1"> <input value="Load Database" type="button" onclick='JavaScript:loadDatabaseRecords()'></p> </form> <table id="DBTable" border="2"> <tr> <td width="20">ID</td> <td width="100">Car Name</td> <td width="100">Fuel Type</td> <td width="100">Transmission</td> <td width="80">Engine size</td> <td width="20">Doors</td> <td width="20">Total</td> <td width="20">Available</td> </tr> <form name="myform"> <tr> <td><input type="text" name="id"></td> <td><input type="text" name="carname"></td> <td><input type="text" name="fueltype"></td> <td><input type="text" name="transmission"></td> <td><input type="text" name="enginesize"></td> <td><input type="text" name="doors"></td> <td><input type="text" name="total"></td> <td><input type="text" name="available"></td> <td colspan="2"><input type="button" value="add" onClick="JavaScript:addNewRecord()"></td> <td colspan="2"><input type="checkbox" value="update" onClick="JavaScript:updateRecord()"></td> <td colspan="2"><input type="checkbox" value="delete" onClick="JavaScript:deleteRecord()"></td> </tr> </form> </table> So, I just want to know whats going wrong. I have spent so many hours researching how to get my database values into the html table. The only responses I have had so far is to display the data in other ways etc. However, i need to display the values in the table as there is other functions that will use the information. Any help would be greatly appreciated. Thanks. Joey
  25. I have a function called after some data and the function is given below:- now the problem here is that at the #vote replace the color of the text is not assigned as it should be from where it is loaded I.e it is not red and not as the font size it should be. sorry this could be simple but not getting it. I have also tried to give .css to vote but it is still not applying that function attach() { var id="<?php echo $_REQUEST['id'];?>"; var state="<?php echo $_REQUEST['state'];?>"; $.ajax({ url: "petition_details.php", data: {id:id,state:state} }).done(function(result){ $("#spprt").replaceWith($(result).find("#spprt").html()); $("#vote").replaceWith($(result).find("#vote").html()); //The problem is here $("input[type=text]").val(""); $("textarea").val(""); if($("#ttt").text()=="You supported it before") { $('#ttt').css({'background-color':'#FFCC00','font-size':'16px','border-style':'none'}); } else if($("#ttt").text()=="Thank you for your VOTE") { $('#ttt').css({'background-color':'#00FF00','font-size':'16px','border-style':'none'}); } }); }
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.