Jump to content


  • Posts

  • Joined

  • Last visited


Profile Information

  • Gender
    Not Telling

sunfighter's Achievements


Newbie (1/5)



  1. A couple of things 1.) Do not use <input type="text" name="admission_no" id="textfield" onkeyup ...... This will execute as soon as the first number is entered. Use onblur. This occurs when you leave the text field and that should be when the complete number has been entered. 2.) Your code to establish XMLHttpRequest is wrong. I just re=wrote it. 3.) Don't send the Admission Number verification number to the same php file that you want executed upon submission. This is your code for the Admission Number HTML: <input type="text" name="admission_no" id="textfield" onblur="showReg('number')"/></td> I am sending a code word called 'number' to the function. When you write your HTML make sure the SUBMIT button sends a different code word!!! This is the javascript that sets up the XMLHttpRequest and the ajax. <script type="text/javascript"> function showReg(str) { var ajaxRequest; // The variable that makes Ajax possible! try{ // Opera 8.0+, Firefox, Safari ajaxRequest = new XMLHttpRequest(); } catch (e){ // Internet Explorer Browsers try{ ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) { try{ ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP"); } catch (e){ // Something went wrong alert("Your browser broke!"); return false; } } } // Create a function that will receive data sent from the server ajaxRequest.onreadystatechange = function(){ if(ajaxRequest.readyState == 4){ if (str == 'number') document.getElementById('regresult').innerHTML = ajaxRequest.responseText; } } Please notice that the js is not complete and that I choose where the responseText goes depending upon the code word 'number'. We end the script with a section that also depends on the code word. Add this after the above code: if (str == 'number'){ var words = document.getElementById('textfield').value; ajaxRequest.open("GET", "ajax.php?Admit="+words, true); ajaxRequest.send(''); } } // this ends the function </script> Write another section based on the last section to execute when the submit button is pressed. Don't forget to do the conditional statement for the responseText in the beginning js section. The php file I wrote is called ajax.php - use your own name. It looks like this: <?php // Connect to your database here $admission_no = $_GET["Admit"]; // sent with this ajaxRequest.open("GET", "ajax.php?Admit="+words, true); $query="SELECT admission_no FROM student_info Where student_info.admission_no='$admission_no'"; $result = mysql_query($query) ; if(mysql_num_rows($result) > '0') echo 'This Number has been taken'; ?> That should do it.
  2. Please use the above '#' to wrap your code in. You do not define $cart in your code. And a question for you is $_POST['item'] an array? And what is it's value?
  3. This is not done in the php that reads the submitted form, but rather with AJAX when the Admission Number is entered and you leave the field 'onblur';
  4. Try this: give image an ID: <img src="images/happy-couple-420.png" alt="420 Friendly Dating Couple" id="mainPic"/> And add just before the </head> tag: <style type="text/css"> #mainPic{ position:relative; top: 50px; } </style> </head>
  5. Went to validate the site with http://validator.w3.org/ and it could not do it. First time I ran into that! So got the code and did it that way = it showed 82 Errors, 20 warning(s) . They need to be fixed before you can get any cross browser compatibility. The main thing with IE is to have a doc type at the top of the code. Without that IE is brainless. So first fix this up with the validator and if your still having problems repost.
  6. Change this line var formatted_date = ele.value; to var formatted_date = new Date(ele.value);
  7. Use this line xmlhttp.open("GET","test.php?q="+document.getElementById('PHPVal').innerHTML, true); And I hope the HTML markup on your php file is a mistake.
  8. If this don't solve your problem at lest it should point you in the right direction. Tell me how it works out for you OK? <?php $pictures = ''; $id = '7'; // <==== This is your product id $pnum = 14; // <==== This is the query returned number of pictures per the product for($i = 1; $i < $pnum+1; $i++) { $picnum = $id.'_'.substr('000' . $i, -3).'.jpg'; $pictures .= '<img src="pictures/'.$picnum.'" width="200" alt="" />'; } echo $pictures; // <=== This shoud be your pictures ?>
  9. The table has nothing to do with it. The box model says the total width of a box object is the width + right padding + left padding + right border + left border + right margin + left margin. To see it in your example kill the table and add a second div. Just duplicate the css for the second one, but make back ground color different and remove the padding. <style type="text/css"> div.header { width:900px; background-color:#363E44; padding:12px; font-family:Arial, Helvetica, sans-serif; font-size:13px; color:#FFFFFF; font-weight:bold; } div.foot { width:900px; background-color:pink; //padding:12px; font-family:Arial, Helvetica, sans-serif; font-size:13px; color:#FFFFFF; font-weight:bold; } </style> </head> <body> <div class="header"> some thing here </div> <div class="foot"> some thing there </div> </body> </html>
  10. You are writing to the page so, yes, it over writes what there. Try using alert('error code what you want to see'). Or make a div on your page and write to the div.
  11. Where are the attachments saved? I'd put then into a first temp folder and then when the user submits his post the code that adds to the DB can also move the attachment to a permanent location. All stuff left in the first temp folder are the attachments that were not followed up with a post. Easy to handle and delete or what ever.
  • 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.