Jump to content

priyankagound

Members
  • Posts

    36
  • Joined

  • Last visited

Profile Information

  • Gender
    Not Telling

priyankagound's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. try out with the below example: <script type="text/javascript"> function validate() { var regexp1=new RegExp("(word1|word2)"); if(regexp1.test(document.getElementById("txt").value)) { alert("Word found in string"); return false; } } </script> <form action="" method="post" onsubmit="return validate()"> <input type="text" id="txt" name="txt"> <input type="submit" value="submit"> </form>
  2. Try out with the below code. $(this).find("ul").toggle();
  3. try document.getElementById document.getElementById("ctl00_ContentPlaceHolder1_txtCountry").setAttribute("onchange", "javascript:get_states(this);");
  4. Some Facebook widgets do use iframes. Twitter uses javascript that most likely interacts with Ajax scripts on their server and returns HTML code to output to an HTML element that is part of their widget embed code. Either way works. Example based on Javascript and PHP (no Ajax): Embed Code <script type="text/javascript"> width = 527; height = 95; </script> <script type="text/javascript" src="http://www.mysite.com/widget.js"></script> widget.js document.write('<iframe scrolling="no" frameborder="0" width="' + width + '" height="' + height + '" src="http://www.mysite.com/showdata.php?height=' + height + '&width=' + width + '" style="border: 1px solid #6c82b5;"></iframe>'); And showdata.php could be any PHP script you want to display any data you want. You can give your users some flexibility about design and colors by passing variables through the javascript as you see me doing here.
  5. Try out with the below given example: Step 1: Insert the below into the <HEAD> section of your page: <script type="text/javascript"> /* Triple Combo Script Credit By Philip M: http://www.codingforums.com/member.php?u=186 Visit http://javascriptkit.com for this and over 400+ other scripts */ There are two variables within the script (near the top) you can customize. Step 2: Insert the below sample triple combo box the <body> section of your page: <form name="tripleplay" action=""> <select name='List1' onchange="fillSelect(this.value,this.form['List2'])"> <option selected>Make a selection</option> </select> <select name='List2' onchange="fillSelect(this.value,this.form['List3'])"> <option selected>Make a selection</option> </select> Follow the logic laid out in the code of Step 1 to customize the contents of each SELECT list.
  6. The below code has worked for me. try out with the help of this example. <!DOCTYPE html> <html> <head> <script> function selectMultiple() { document.getElementById("mySelect").multiple=true; } </script> </head> <body> <form> <select id="mySelect" size="4"> <option>Apple</option> <option>Pear</option> <option>Banana</option> <option>Orange</option> </select> <input type="button" onclick="selectMultiple()" value="Select multiple"> </form> <p>Before you click on the "Select multiple" button, try to select more than one option (by holding down the Shift or Ctrl key). Then click on the "Select multiple" button and try again.</p> </body> </html> Run it once, you will get an idea.
  7. Try out this one Hide border and background on empty cells in a table: table { border-collapse:separate; empty-cells:hide; } Formal syntax: show | hide empty-cells: show empty-cells: hide empty-cells: inherit
  8. I am stuck with this code.I want to upload image through database and want to retrieve it on the same page from database using blob datatype. Below is the code for my page. file_insert.php: <html> <head><title>File Insert</title></head> <body> <h3>Please Choose a File and click Submit</h3> <form enctype="multipart/form-data" action= "<?php echo $_SERVER['PHP_SELF']; ?>" method="post"> <input type="hidden" name="MAX_FILE_SIZE" value="10000000" /> <input name="userfile" type="file" /> <input type="submit" value="Submit" /> </form> <?php // check if a file was submitted if(!isset($_FILES['userfile'])) { echo '<p>Please select a file</p>'; } else { try { $msg= upload(); //this will upload your image echo $msg; //Message showing success or failure. } catch(Exception $e) { echo $e->getMessage(); echo 'Sorry, could not upload file'; } } // the upload function function upload() { include "file_constants.php"; $maxsize = 10000000; //set to approx 10 MB //check associated error code if($_FILES['userfile']['error']==UPLOAD_ERR_OK) { //check whether file is uploaded with HTTP POST if(is_uploaded_file($_FILES['userfile']['tmp_name'])) { //checks size of uploaded image on server side if( $_FILES['userfile']['size'] < $maxsize) { //checks whether uploaded file is of image type //if(strpos(mime_content_type($_FILES['userfile']['tmp_name']),"image")===0) { $finfo = finfo_open(FILEINFO_MIME_TYPE); if(strpos(finfo_file($finfo, $_FILES['userfile']['tmp_name']),"image")===0) { // prepare the image for insertion $imgData =addslashes (file_get_contents($_FILES['userfile']['tmp_name'])); // put the image in the db... // database connection mysql_connect($host, $user, $pass) OR DIE (mysql_error()); // select the db mysql_select_db ($db) OR DIE ("Unable to select db".mysql_error()); // our sql query $sql = "INSERT INTO image_again_test (image, name) VALUES ('{$imgData}', '{$_FILES['userfile']['name']}');"; // insert the image mysql_query($sql) or die("Error in Query: " . mysql_error()); $msg='<p>Image successfully saved in database with id ='. mysql_insert_id().' </p>'; } else $msg="<p>Uploaded file is not an image.</p>"; } else { // if the file is not less than the maximum allowed, print an error $msg='<div>File exceeds the Maximum File limit</div> <div>Maximum File limit is '.$maxsize.' bytes</div> <div>File '.$_FILES['userfile']['name'].' is '.$_FILES['userfile']['size']. ' bytes</div><hr />'; } } else $msg="File not uploaded successfully."; } else { $msg= file_upload_error_message($_FILES['userfile']['error']); } return $msg; } // Function to return error message based on error code function file_upload_error_message($error_code) { switch ($error_code) { case UPLOAD_ERR_INI_SIZE: return 'The uploaded file exceeds the upload_max_filesize directive in php.ini'; case UPLOAD_ERR_FORM_SIZE: return 'The uploaded file exceeds the MAX_FILE_SIZE directive that was specified in the HTML form'; case UPLOAD_ERR_PARTIAL: return 'The uploaded file was only partially uploaded'; case UPLOAD_ERR_NO_FILE: return 'No file was uploaded'; case UPLOAD_ERR_NO_TMP_DIR: return 'Missing a temporary folder'; case UPLOAD_ERR_CANT_WRITE: return 'Failed to write file to disk'; case UPLOAD_ERR_EXTENSION: return 'File upload stopped by extension'; default: return 'Unknown upload error'; } } ?> </body> </html> file_constants.php: <?php $host="localhost"; $user="root"; $pass=""; $db="test"; ?>
  9. For mailing you must first gather the person information and then filling out the form and what order they want to do. Below is the small example for email which may help you. <?php $action=$_REQUEST['action']; if ($action=="") /* display the contact form */ { ?> <form action="" method="POST" enctype="multipart/form-data"> <input type="hidden" name="action" value="submit"> Your name:<br> <input name="name" type="text" value="" size="30"/><br> Your email:<br> <input name="email" type="text" value="" size="30"/><br> Your message:<br> <textarea name="message" rows="7" cols="30"></textarea><br> <input type="submit" value="Send email"/> </form> <?php } else /* send the submitted data */ { $name=$_REQUEST['name']; $email=$_REQUEST['email']; $message=$_REQUEST['message']; if (($name=="")||($email=="")||($message=="")) { echo "All fields are required, please fill <a href=\"\">the form</a> again."; } else{ $from="From: $name<$email>\r\nReturn-path: $email"; $subject="Message sent using your contact form"; mail("youremail@yoursite.com", $subject, $message, $from); echo "Email sent!"; } } ?>
  10. <html> <head> <title> New Document </title> <script type="text/javascript" language="javascript"> function changeBtn(btn) { if (! btn.style) { alert("Sorry, your browser doesn't support this operation."); return; } btn.style.background = "red"; btn.style.color = "blue"; return; } </script> This works fine for me. </head> <body> <form id="f1" name="f1" action="" method=""> <br> <input type="button" value="Try me" onClick="changeBtn(this)"> </form> </body> </html>
  11. function merge_common_keys(){ $arr = func_get_args(); $num = func_num_args(); $keys = array(); $i = 0; for($i=0;$i<$num;++$i){ $keys = array_merge($keys, array_keys($arr[$i])); } $keys = array_unique($keys); $merged = array(); foreach($keys as $key){ $merged[$key] = array(); for($i=0;$i<$num;++$i){ $merged[$key][] = isset($arr[$i][$key])?$arr[$i][$key]:null; } } return $merged; } Usage: $merged = merge_common_keys($array1,$array2); PS. It can work with more than two arrays, just pass as many as you want as next arguments.
  12. Once a form is submitted, you are no longer on that page. You've navigated away. The other way you can do this is submit the first action via AJAX, then submit the form naturally to the second destination. I would suggest using jQuery to make your AJAX calls since most of the AJAX code is already there for you to use. Another option is to have raf-submitted.php perform a POST from your server to the salesforce server once it receives the form data.
  13. set up a cron job to run a php script that will fetch entries in this way e.g. /* send those 2 months before exp date*/ $sql='select * FROM users WHERE exp_date_unix>='.(time()+86400*60); or if you use the datetime/timestamp field the condition would be smth like DATE_DIFF(exp_date_unix, CURRENT_TIMESTAMP) >=60;
  14. You can use Ajax. Create the following .html page: <html> <head> <script> function showData(str) { if (str=="") { document.getElementById("ajax-content").innerHTML=""; return; } // Code for IE7+, Firefox, Chrome, Opera, Safari if (window.XMLHttpRequest) { xmlhttp=new XMLHttpRequest(); } // Code for IE6, IE5 else { xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); } xmlhttp.onreadystatechange=function() { if (xmlhttp.readyState==4 && xmlhttp.status==200) { document.getElementById("ajax-content").innerHTML=xmlhttp.responseText; } } xmlhttp.open("GET","showData.php?id="+str,true); xmlhttp.send(); } </script> </head> <body> <form> <select name="news" onchange="showData(this.value)"> <option value="">Select ID:</option> <option value="1">1</option> <option value="2">2</option> <option value="3">3</option> </select> </form> <div id="ajax-content"></div> </body> </html> And the following .php script (showData.php in my example): <?php // Receive variable from URI $id=$_GET["id"]; // Connect to your database $con = mysql_connect('localhost', 'user1591005', 'stackOverflow'); if (!$con) { die('Could not connect: ' . mysql_error()); } // Select your database mysql_select_db("myDatabase", $con); // Select all fields from your table $sql="SELECT * FROM news WHERE id = '".$id."'"; $result = mysql_query($sql); while($row = mysql_fetch_array($result)) { echo "<input type='text' value='" . $row['title'] . "'>"; echo "<textarea>" . $row['content'] . "</textarea>"; } // Close the connection mysql_close($con); ?>
  15. This might help you; the article is old, but I believe it should still be relevant. http://www.kitebird.com/articles/access-migrate.html
×
×
  • 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.