Jump to content

Search the Community

Showing results for tags 'javascript'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


  • 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


Last Updated

  • Start


Filter by number of...


  • Start





Website URL








Donation Link

  1. Dear all, My new web project is fully based on javascript. Each and every fields and form's have javascrip and ajax call's. So, if any user who comes without any knowledge of javascrip whether it is enabled or disabled in browser, my site will not work properly for them. So, i want to prevent them from unknowingly feel that the site has problem. Instead i just want to throw an error like google or any site does. If an access to my page comes from a browser i should first check whether the javascript functionality has been enables or not. If not i will throw an error saying that "please enable javascript in your browser for the better user interface something like that. How can i acheive this. I am having this in mind but do not know how to acheive the output. Any help will be greatful. Thanks!
  2. Hello guys, I've added a search bar in my website using php and javascript. It selects data from database according to your search input and then it displays the results. That works just fine but when the user select one of the resulted options I want to put the value of the specific option in the textbox or below so I can have access to it. So if for example someone will search the word "Car", when they click the word I just want to get the value like we normally do in PHP ( $car = $_POST['car']; ). Is there any way I can do it? main.php <html xmlns="http://www.w3.org/1999/xhtml"> <head> <script type="text/javascript" src="scripts/jquery-1.3.2.min.js"></script> <script type="text/javascript"> $(document).ready(function() { $("#SearchInput").focus(function() { if($("#SearchInput").val() == "Car Search") { $("#SearchInput").val(""); } }); $("#SearchInput").blur(function() { if($("#SearchInput").val() == "") { $("#SearchInput").val("Car Search"); } $("#SearchResults").slideUp(); }); $("#SearchInput").keydown(function(e) { if(e.which == { SearchText = $("#SearchInput").val().substring(0, $("#SearchInput").val().length-1); } else { SearchText = $("#SearchInput").val() + String.fromCharCode(e.which); } $("#SearchResults").load("retrieveCar.php", { SearchInput: SearchText }); $("#SearchResults").slideDown(); }); }); </script> </head> <body> <table> <tr> <td><div id="SearchBox"><input id="SearchInput" name="SearchInput" value="Car Search"/></div></td> <td><div id="SearchButton"><input type="image" src="images/left.png" /></div></td></tr> <tr><div id="SearchResults"></div> </tr> </table> retrieveCar.php <?php $dbc = @mysql_connect ('localhost','root@localhost',''); // Select the database. mysql_select_db ('model'); if(isset($_POST['SearchInput'])) { $SearchInput = strtolower($_POST['SearchInput']); $Cars = mysql_query('select * from Cars where car_name like "%'.$SearchInput.'%"'); while($Car = mysql_fetch_assoc($Cars)) { $Name = utf8_encode($Car['car_name']); $Name = str_replace($SearchInput, '<span class="highlight">'.$SearchInput.'</span>', $Name); $Name = str_replace(ucfirst($SearchInput), '<span class="highlight">'.ucfirst($SearchInput).'</span>', $Name); echo '<a href="">'.$Name.'</a>'; } } ?>
  3. Can anyone give me an idea on how I will count the table column and table row and get the id, attribute and the content of a each cell (the cell is contenteditable). What tools i have to use. e.g. <table id='sheet'> <tbody> <tr> <td id='1A' rowspan=2>Rowspan 2</td> <td id='1B'>22222</td> <td id='1C'>33333</td> </tr> <tr> <td id='2B' colspan='2'> Colspan2</td> </tr> <tr> <td id='3A' style='color:red'>Whaterver</td> <td id='3B' style='font-weight:bold'>Askyourmother</td> <td id='3C'>sigh</td> </tr> </tbody> </table> I'm using PHP and Jquery(Javascript). Thanks. .
  4. i want to manipulate a joomla component for my site. component has no ability to do what i want. i create a db row for component, for every new users. but i coudn't resolve parent id column to insert the correct value. i have to login to panel and open that category id, and just click "save and close" button for every new users. it is a manuel solution. but can i do it by running "file_get_contents". like this: $url = "/index.php?option=com_joomgallery&controller=categories&task=edit&cid=59"; $postdata=http_build_query(array("usr" => "xxxx", "pass" => "xxx", "cid" => "59", "javascript" => ""Joomla.submitbutton('save')"")); $opts = array('http' => array('method' => 'POST', 'header' => 'Content-type: application/x-www-form-urlencoded', 'content' => $postdata)); $context = stream_context_create($opts); $result = file_get_contents($url, false, $context); source code part: <li class="button" id="toolbar-save"> <a href="#" onclick="Joomla.submitbutton('save')" class="toolbar"> <span class="icon-32-save"> </span> Save & Close </a> </li> could i explain the problem clearly??? categories.php
  5. mainpage.php, loginModal.php, signInvalidate.php I have a page has a button that when click a modal dialog box pop up, the content of the modal is from other page(loginModal.php) using jquery .load, so the content now of the modal is a login form which validates using jquery ajax that send information to signInvalidate.php. I have no problem on validation it still return error if it is error, but if it is correct information I want to reload the main page. How will I do that? or does Jquery .load accepting return TRUE value. e.g. signInvalidate.php $result = $userFunction->checkLogin($useremail, @$password, @$remember, $gotUrl); if($result == TRUE){ return TRUE; } loginModal.php success: function(msg){ if(msg == TRUE){ return true; }else{ $("#signInOutput").html(msg); } } mainpage.php $('#previewOutput').load('modalLogin.php', function(){ });
  6. im designing a online coupon site,,, there are several products displaying in my home page, when you click on each product, there is a coupon image displaying, but All that i want is, i want the users select the products they like. and there is a seperate print button. so i wanted the users to print the coupon of multiple selected products at once when click on the print button... for exaample, simillar as this website: visit http://www.coupons.com/
  7. HI , I am begineer in the field of webdesigning. I am facing problem with a java script which is working at one places but doesnot at another. Test.php -- working fine <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <title>Untitled Document</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <meta http-equiv="Content-Style-Type" content="text/css"> <meta http-equiv="Content-Script-Type" content="text/javascript"> <script type="text/javascript"> var clone; function cloneRow(){ var rows=document.getElementById('mytab').getElementsByTagName('tr'); var index=rows.length; clone=rows[index-1].cloneNode(true); var inputs=clone.getElementsByTagName('input'), inp, i=0,n ; while(inp=inputs[i++]){ inp.name=inp.name.replace(/\d/g,'')+(index+1); } } function addRow(){ var tbo=document.getElementById('mytab').getElementsByTagName('tbody')[0]; tbo.appendChild(clone); cloneRow(); } function addValue(obj){ obj.value=obj.value.replace(/[^\d]/,''); var fields=document.getElementsByTagName('input'), i=0, tot=0, f; while(f=fields[i++]){ f.name&&f.name.match(/cost/)?tot+=Number(f.value):null; } document.getElementsByName('sum')[0].value=tot; } onload=cloneRow; </script> </head> <body> <?php $host="localhost"; // Host name $username="root"; // Mysql username $password="root"; // Mysql password $db_name="teanest"; // Database name // Connect to server and select databse. $con=mysql_connect("$host", "$username", "$password"); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("$db_name")or die("cannot select DB"); $sql="select id,name from items order by name"; $result = mysql_query ($sql); $sql1="select id,name from suppliers order by name"; $result1=mysql_query($sql1); ?> <form action=""> <table> <tr> <td align="right">Item Name:</td> <td align="left"> </td> </tr> <tr> <td align="right">Supplier:</td> <td align="left"> <?php echo "<select name=\"suppliers\" value=''>Supplier</option>"; // printing the list box select command while($nt=mysql_fetch_array($result1)){//Array or records stored in $nt echo "<option value=$nt[id]>$nt[name]</option>"; /* Option values are added by looping through the array */ } echo "</select>";// Closing of list box ?> </td> <tr> <td align="right">Date:</td> <td align="left"><input id='start_dt' class='datepicker' name="date"/></td> </tr> <tr> <td align="right">Bill No:</td> <td align="left"><input type="text" size="10" name="billNo" /></td> </tr> </table> <table id="mytab" border="1"> <tr> <th>Sl No.</th> <th>Item Name</th> <th>Quantity</th> <th>Unit</th> <th>Cost Price</th> </tr> <tr> <td><input type="text" size="3" name="slno"></td> <td> <?php echo "<select name=\"items\" value=''>Item</option>"; // printing the list box select command while($nt=mysql_fetch_array($result)){//Array or records stored in $nt echo "<option value=$nt[id]>$nt[name]</option>"; /* Option values are added by looping through the array */ } echo "</select>";// Closing of list box ?> </td> <td><input type="text" size="4" name="quantity"></td> <td><input type="text" size="4" name="unit"></td> <td><input type="text" size="4" name="costprice" onkeyup="addValue(this)"></td> </tr> </table> <br> <input type="button" value="Add a new row" onclick="addRow()"> <p> Total: <input type="text" name="sum" readonly="readonly" value="Sum of Cost Price inputs"> </form> </body> </html> receivings.php-- doesnot work ... same javascript included in header part <?php include 'includes/header.inc.php'; ?> <div class="sidebar1"> <br><br> <ul class="nav"> <li><a href="#receive">Receive</a></li> <li><a href="#">Link two</a></li> <li><a href="#">Link three</a></li> <li><a href="#">Link four</a></li> </ul> <!-- end .sidebar1 --></div> <?php $host="localhost"; // Host name $username="root"; // Mysql username $password="root"; // Mysql password $db_name="teanest"; // Database name // Connect to server and select databse. $con=mysql_connect("$host", "$username", "$password"); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("$db_name")or die("cannot select DB"); $sql="select id,name from items order by name"; $result = mysql_query ($sql); $sql1="select id,name from suppliers order by name"; $result1=mysql_query($sql1); ?> <div id="receive" class="modalDialog"> <div> <a href="#close" title="Close" class="close">X</a> <form name="receive" method="post" action="receive.php"> <fieldset> <legend>Receive:</legend> <table> <tr> <td align="right">Supplier:</td> <td align="left"> <?php echo "<select name=\"suppliers\" value=''>Supplier</option>"; // printing the list box select command while($nt=mysql_fetch_array($result1)){//Array or records stored in $nt echo "<option value=$nt[id]>$nt[name]</option>"; /* Option values are added by looping through the array */ } echo "</select>";// Closing of list box ?> </td> <tr> <td align="right">Date:</td> <td align="left"><input id='start_dt' class='datepicker' name="date"/></td> </tr> <tr> <td align="right">Bill No:</td> <td align="left"><input type="text" size="10" name="billNo" /></td> </tr> </table> <br><br> <!--// receivings transaction table --> <table id="mytab" border="1"> <tr> <th>Sl No.</th> <th>Item Name</th> <th>Quantity</th> <th>Unit</th> <th>Cost Price</th> </tr> <tr> <td><input type="text" size="3" name="slno"></td> <td> <?php echo "<select name=\"items\" value=''>Item</option>"; // printing the list box select command while($nt=mysql_fetch_array($result)){//Array or records stored in $nt echo "<option value=$nt[id]>$nt[name]</option>"; /* Option values are added by looping through the array */ } echo "</select>";// Closing of list box ?> </td> <td><input type="text" size="4" name="quantity"></td> <td><input type="text" size="4" name="unit"></td> <td><input type="text" size="4" name="costprice" onkeyup="addValue(this)"></td> </tr> </table> <br> <input type="button" value="Add a new row" onclick="addRow()"> <p> Total: <input type="text" name="sum" readonly="readonly" value="Sum of Cost Price inputs"> </fieldset> <input type="submit" value="Receive"> </form> </div> </div> <div class="content"> <h1>List Of Receivings:</h1> </div> <!-- end .content --></div> <?php include 'includes/footer.inc.php'; ?> Please help !!!
  8. I am trying to do a mouseover/mouseout on an image in a table. Right now I have it working with Javascript. You click on the camera and the image comes up in a new window. However; I want to do it with a mouseover like this. http://www.menuhead.net/PopUP/mouseover-popup/over.php I know mouseover is client side so how would I do this with php. function newPopup(url) { popupWindow = window.open( url,'popUpWindow','height=300,width=300,left=10,top=10,resizable=no,scrollbars=no,toolbar=no,menubar=no,location=no,directories=no,status=no' ) } <td><a href=Javascript:newPopup('$row[LocationPix]');><img src='http://www.menuhead.net/Images/Buttons/PShotClear.png'</td> Thank you.
  9. I'm new here and looking for help with a problem (already tried googling it, though I'm not sure I'm even explaining it correctly). The only file visible to the user is this <?php include "../../the-actual-site/index.php"; ?> The rest of the site is behind the "www" folder, and uses includes, get, and session, variables to navigate the pages. Now I want to add some javascript to the display pages, but some nasty things are happening when i do, i trimmed everything down to a bare example (just to make sure something else was not interfering), but these problems still persist. So for the example page I have setup the index.php in the www folder the same way, and used the page from this tutorial as a working example. The tutorial pages work fine if laid out as instructed, or renamed/moved around (but not included). So the first problem is that that the javascript requires me to expose the "index.php" part of the url to send a get variable. (I trued outputting just the "?var=" part, and it did not work) The production site never exposes this, and while I don't believe it would cause an issue, I would rather keeps things "as-is" than having people freak out over it. The second issues is that the javascript is making the page display twice once it starts working. Another instance of the page is created below the first one (the second is non-functional). So first, how can I use js in an include without the page duplicating? And second how do I get javascript to output clean GET variables without showing the "index.php" part?
  10. Dear all, I have having a text area field which has a limit of 100 characters only. Now, i also want to validate it such that it should only contain letter's (alphabet A-Z .a-z). It should not contain any number or @ symbol. If such things entered it should throw me an error saying invalid arguments like that. I know it can be done with regular expressions. But i m not aware of how to do. Can some one help with that. Here is my script. <script language="javascript" type="text/javascript"> function limitText(limitField, limitCount, limitNum) { if (limitField.value.length > limitNum) { limitField.value = limitField.value.substring(0, limitNum); } else { limitCount.value = limitNum - limitField.value.length; } } </script> <tr> <td valign="top" align="left">Description</td> <td valign="top">:</td> <td align="left"><textarea name="limitedtextarea" onkeydown="limitText(this.form.limitedtextarea,this.form.countdown,100);" onkeyup="limitText(this.form.limitedtextarea,this.form.countdown,100);"> </textarea><br> <font size="1">(Maximum characters: 100)<br> You have <input readonly type="text" name="countdown" size="3" value="100"> characters left.</font></td> </tr>
  11. Hey guys why do i keep getting a problem with a redirect loop... i dont know why and i just get: http://www.powerwashers.co.uk/temp/main/main/main/main/main/main/main/main/main/main/main/main/main/main/main/main/main/main/main/main/main/main/main/main/main/main/main/main/main/main/main/main/main/main/main/main/main/main/main/main/main/main/main/index.php Its mainly when i click that google link although its just been happening on most things i do... also it doesnt display in firefox :/... Can anyone help me please?. http://www.powerwashers.co.uk/temp/main/expo.php <!DOCTYPE html> <head> <title>Brendon Powerwashers - News & Exhibitions</title> <meta http-equiv="content-type" content="text/html; charset=utf-8"/> <meta name="language" content="en"/> <meta name="robots" content="index, follow"/> <meta name="description" content=""/> <meta name="keywords" content=""/> <link rel="stylesheet" href="stylesheet/style1.css" type="text/css"/> <link rel="stylesheet" href="stylesheet/style6.css" type="text/css"/> <script type="text/javascript" src="js/jquery.js"></script> <script type="text/javascript" src="js/navigation_hide_show.js"></script> <script type="text/javascript" src="js/hover_script.js"></script> <script type="text/javascript" src="js/fader.js"></script> <script type="text/javascript" src="js/bg_fade.js"></script> <script type="text/javascript" src="js/jquery_script01.js"></script> <script type="text/javascript" src="js/app_fader.js"></script> <script type="text/javascript" src="js/navigation_dropdown.js"></script> </head> <body style='display:none;' class='body'> <div id="header"> <?php include('content/navigation2.php'); ?> </div> <div id="page_wrapper"> <div id="page"> <?php include('content/acc_navigation.php'); ?> <div id="fp_top2" style='margin-bottom:-3px;'> <div id="fp_nav"> <ul> <a href="#" id="fade1_link"><li>Exhibitions</li></a> <a href="#" id="fade2_link"><li>Latest News</li></a> <a><li> </li></a><!--id="fade3_link"--> <a><li> </li></a><!--id="fade4_link"--> <a><li> </li></a><!--id="fade5_link"--> <a><li> </li></a><!--id="fade6_link"--> <a><li> </li></a><!--id="fade7_link"--> </ul> </div> <div id="fader_img2"> <img id='fade1' class="fader_images" src="images/exhibition_banner.jpg" alt="Fader"/> <img id='fade2' class="fader_images" src="images/about_fader.jpg" alt="Fader"/> <img id='fade3' class="fader_images" src="images/fader/1_3.jpg" alt="Fader"/> <img id='fade4' class="fader_images" src="images/fader/1_4.jpg" alt="Fader"/> <img id='fade5' class="fader_images" src="images/fader/1_5.jpg" alt="Fader"/> <img id='fade6' class="fader_images" src="images/fader/1_6.jpg" alt="Fader"/> <img id='fade7' class="fader_images" src="images/fader/1_7.jpg" alt="Fader"/> </div> </div> <div> <div id="sheet2_1" class="fader_sheets"> <div class="white_bg"> <h1 style=" text-align:center; font-size:26px">Exhibitions</h1><br/> <?php $expire = date('Ymd'); $select_query8 = mysql_query("SELECT * FROM expos ORDER BY expire"); while($select_query_row8 = mysql_fetch_array($select_query8)){ if($select_query_row8['expire'] > $expire) { echo ' <div style="width:200px; height:300px; border:1px solid #000; float:left; margin-top:10px; margin-left:5px; margin-right:5px; margin-bottom:10px; padding:5px;"> <div style="width:300px; margin:0px auto;"><img src="images/logos/'.$select_query_row8['image_url'].'" alt="Show Logo"/></div> <h1 style="text-align:center;">'.$select_query_row8['header'].'</h1><h1 style="text-align:center; font-size:14px; margin-top:4px">('.$select_query_row8['start_day'].'/'. $select_query_row8['start_month'].'/'.$select_query_row8['start_year']. ' - '.$select_query_row8['end_day'].'/'. $select_query_row8['end_month'].'/'.$select_query_row8['end_year'].')</h1><br/>'; echo '<p style="text-align:center">'.$select_query_row8['content'].'<br/><a href="www.google.com" class="expo1" >www.google.com</a></p> </div> '; } } ?> </div> </div> <div id="sheet2_2" class="fader_sheets"> <div class="white_bg"> <h1 style=" text-align:center; font-size:26px">Latest News</h1> <p>Coming Soon...</p> </div> </div> <div id="sheet2_3" class="fader_sheets"> <div class="white_bg"> </div> </div> <div id="sheet2_4" class="fader_sheets"> <div class="white_bg"> </div> </div> <div id="sheet2_5" class="fader_sheets"> <div class="white_bg"> </div> </div> <div id="sheet2_6" class="fader_sheets"> <div class="white_bg"> </div> </div> <div id="sheet2_7" class="fader_sheets"> <div class="white_bg"> </div> </div> </div> </div> </div> <div id="background"></div> </body> </html>
  12. I've been working on a project here oplinfo.hj.cx/insert_test.php When a user is adding a game and it's compatibly information to the database, I'm able to make check boxes and radio button selections mandatory, as well as specify the min/max characters for a text field. <script Language="Javascript"> <!-- function CheckGameCode() { // Check the length of the value of the element named text_name // from the form named form_name if it's < 10 and > 10 characters // display a message asking for different input if ((form1.gamecode.value.length < 10) || (form1.gamecode.value.length > 10)) { // Build alert box message showing how many characters entered mesg = "You have entered " + form1.gamecode.value.length + " character(s) for Game Code\n" mesg = mesg + "Valid Game Code entries are 10 characters.\n" mesg = mesg + "Please verify your input and submit again.\n" mesg = mesg + "Example: SLUS-12345" alert(mesg); // Place the cursor on the field for revision form1.gamecode.focus(); // return false to stop further processing return (false); } // If text_name is not null continue processing return (true); } --> </script> <script language="Javascript"> function formCheck(formobj){ // Enter name of mandatory fields var fieldRequired = Array("gamename", "gamecode", "region", "comp", "vmc"); // Enter field description to appear in the dialog box var fieldDescription = Array("Game Name", "Game Code", "Region", "Result", "VMC Support"); // dialog message var alertMsg = "Complete the following fields:\n"; var l_Msg = alertMsg.length; for (var i = 0; i < fieldRequired.length; i++){ var obj = formobj.elements[fieldRequired[i]]; if (obj){ switch(obj.type){ case "select-one": if (obj.selectedIndex == -1 || obj.options[obj.selectedIndex].text == ""){ alertMsg += " - " + fieldDescription[i] + "\n"; } break; case "select-multiple": if (obj.selectedIndex == -1){ alertMsg += " - " + fieldDescription[i] + "\n"; } break; case "text": case "textarea": if (obj.value == "" || obj.value == null){ alertMsg += " - " + fieldDescription[i] + "\n"; } break; default: } if (obj.type == undefined){ var blnchecked = false; for (var j = 0; j < obj.length; j++){ if (obj[j].checked){ blnchecked = true; } } if (!blnchecked){ alertMsg += " - " + fieldDescription[i] + "\n"; } } } } if (alertMsg.length == l_Msg){ return true; }else{ alert(alertMsg); return false; } } </script> and the form <table width="830" border="0" bgcolor="#003131" align="center"><form action="insert_action.php" method="post" name="form1" id="form1" onsubmit="return !!(CheckGameCode() & formCheck(this));"> <tr> <td width="174" height="38" bgcolor="#003a39"><strong> Game Name / Game Code</strong></td> <td width="438" bgcolor="#003a39"> <input name="gamename" type="text" id="" size="40" maxlength="35" /> <input name="gamecode" type="text" id="gamecode" size="10" maxlength="10" /></td> <td width="204" bgcolor="#003a39"> For gamecode: <a href="http://www.sonyindex.com/index.htm">Sony Index</a><br /> Enter using 10 chars: ABCD-12345</td> </tr> Now what I'd like to do is make the "gamecode" text field require a certain character such as "-", rather then only requiring 10 characters.. more specifically, I'd like the first 4 characters required to be a letter (A-Z), the 5th character to be a "-" and the last 5 to be integers.. else the form does not submit. I'd like to eventually use these gamecodes to guarantee no duplicate entries into the database, and also proper format (example: ABCD-12345) if I ever decide to loop and display the row on the web page. The required format would be help against people just typing 10 random characters or using different gamecode format (ABCD_123.45), since duplicate entry validation will depend on the accuracy of these gamecodes. Is this possible with Javascript? If yes, how might I go about implementing these requirements.
  13. I'm using pretty photo. I want to refresh the parent page when I close the modal window which is an iframe. This script closes the modal, but does not refresh the parent frame. <a href="#" onclick="window.parent.jQuery.prettyPhoto.close();">Close</a>
  14. Hello all, I was trying to use PHP to echo a Javascript function but it wasn't going well at all. I am wondering, is it possible to do the following: <script type="text/javascript"><span id="formResponse"></script> Thank you, Josh.
  15. i have a form. if user enter the data, the db table display. but i want the table to get displayed when the user logins for the first time. simple one but i can't get it how... aa.html <html> <body> <script language="javascript" type="text/javascript"> <!-- //Browser Support Code function ajaxFunction(){ 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){ var ajaxDisplay = document.getElementById('ajaxDiv'); ajaxDisplay.innerHTML = ajaxRequest.responseText; } } var age = document.getElementById('age').value; var wpm = document.getElementById('wpm').value; var sex = document.getElementById('sex').value; var name = document.getElementById('name').value; var queryString = "?age=" + age + "&wpm=" + wpm + "&sex=" + sex + "&name=" + name; $a=ajaxRequest.open("GET", "ss1.php" + queryString, true); ajaxRequest.send(null); } //--> </script> <form name='myForm'> Name:<input type='text' id='name' /> <br /> Age: <input type='text' id='age' /> <br /> WPM: <input type='text' id='wpm' /> <br /> Sex: <select id='sex'> <option value='m'>m</option> <option value='f'>f</option> </select> <input type='button' onclick='ajaxFunction()' value='Insert New row' /> </form> <div id='ajaxDiv'>Your result will display here</div> </body> </html> ss1.php $age = $_GET['age']; $sex = $_GET['sex']; $wpm = $_GET['wpm']; $name= $_GET['name']; // Escape User Input to help prevent SQL Injection $a=isset($_GET['age']) && $_GET['age']; $b=isset($_GET['sex']) && $_GET['sex']; $c=isset($_GET['wpm']) && $_GET['wpm']; $d=isset($_GET['name']) && $_GET['name']; $age = mysql_real_escape_string($age); $sex = mysql_real_escape_string($sex); $wpm = mysql_real_escape_string($wpm); $name = mysql_real_escape_string($name); //build query $query = "INSERT INTO `ajax_example`(`ae_name`, `ae_age`, `ae_sex`, `ae_wpm`) VALUES ('$name','$age','$sex','$wpm')"; $qry = mysql_query($query) or die(mysql_error()); $a="SELECT `ae_name`, `ae_age`, `ae_sex`, `ae_wpm` FROM `ajax_example`"; $qry_result=mysql_query($a) or die(mysql_error()); //Build Result String $display_string = "<table>"; $display_string .= "<tr>"; $display_string .= "<th>Name</th>"; $display_string .= "<th>Age</th>"; $display_string .= "<th>Sex</th>"; $display_string .= "<th>WPM</th>"; $display_string .= "</tr>"; // Insert a new row in the table for each person returned while($row = mysql_fetch_array($qry_result)){ $display_string .= "<tr>"; $display_string .= "<td>$row[ae_name]</td>"; $display_string .= "<td>$row[ae_age]</td>"; $display_string .= "<td>$row[ae_sex]</td>"; $display_string .= "<td>$row[ae_wpm]</td>"; $display_string .= "</tr>"; } $display_string .= "</table>"; echo $display_string; ?> if u could tell me show good websites to practice javascript. woulg b gr8.. thank u in advances.
  16. I have a html form in which the dropdown box is an array element now I have created a javascript function that get form as parameter . 1)I need to maniulate the values of the array present in the form in the below code sendmail is the form sname is the field array function addit(sendmail) { var x=document.sendmail.sname.length; //alert(x); while( x>0 ) { var skill=document.getElementById("sname[x]").value; //alert(skill); var anOption = document.createElement("OPTION"); anOption.innerText = skill; anOption.Value = skill; document.form.snames.options.add(anOption); x--; } }
  17. Hi everyone, I have problem with my accordion menu. Instead of sliding down, content from menu overlap each other...Cut me a little slack because i am new to javascript. This is code for menu. <?php include("script/dblib.php"); connectToDB(); header("Content-Type: text/html; charset=UTF-8"); ?> <HTML> <HEAD> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <script type="text/javascript" src="http://code.jquery.com/jquery-latest.js"></script> <script type="text/javascript" src="script/script.js"></script> <STYLE> #accordion { list-style: none; padding: 0 0 0 0; width: 230px; } #accordion li{ height:45px; line-height:45px; display: block; background-image:url('images/for_css/menu_bg.jpg'); background-repeat:repeat-x repeat-y; font-weight: bold; padding-left: 5px; cursor: pointer; list-style: circle; -moz-border-radius: 5px; -webkit-border-radius: 5px; border-radius: 5px; } #accordion ul { list-style: none; padding: 0 0 0 0; display: none; } #accordion li:hover{ background-image:url('images/for_css/bgMenu.png'); } #accordion ul li{ height:30px; text-align: center; font-size: 12px; font-weight: normal; cursor: auto; background-image:url('images/for_css/bc_bg.gif'); line-height:30px; padding: 0 0 0 7px; } #accordion ul li:hover { background-image:url('images/for_css/bgMenu.png'); } #accordion a { text-decoration: none; } </STYLE> </HEAD> <BODY> <?php // Select all entries from the menu table $result=mysql_query("SELECT * FROM parents ORDER BY id_roditelja"); // Create a multidimensional array to conatin a list of items and parents $menu = array( 'items' => array(), 'parents' => array() ); // Builds the array lists with data from the menu table while ($items = mysql_fetch_assoc($result)) { // Creates entry into items array with current menu item id ie. $menu['items'][1] $menu['items'][$items['id_roditelja']] = $items; // Creates entry into parents array. Parents array contains a list of all items with children $menu['parents'][$items['parent_id']][] = $items['id_roditelja']; } // Menu builder function, parentId 0 is the root function buildMenu($parent, $menu) { $html = ""; if (isset($menu['parents'][$parent])) { $html .= " <ul id='accordion'>\n"; foreach ($menu['parents'][$parent] as $itemId) { if(!isset($menu['parents'][$itemId])) { $html .= "<li>\n <a >".$menu['items'][$itemId]['naziv']."</a>\n</li> \n"; } if(isset($menu['parents'][$itemId])) { $html .= " <li>\n <a >".$menu['items'][$itemId]['naziv']."</a> \n"; $html .= buildMenu($itemId, $menu); $html .= "</li> \n"; } } $html .= "</ul> \n"; } return $html; } echo buildMenu(0, $menu); ?> </BODY> </HTML> javascript part: $(document).ready(function(){ $('#accordion > li ul') .click(function(event){ event.stopPropagation(); }) .filter(':not(:first)') .hide(); $('#accordion > li, #accordion > li > ul > li').click(function(){ var selfClick = $(this).find('ul:first').is(':visible'); if(!selfClick) { $(this) .parent() .find('> li ul:visible') .slideToggle(); } $(this) .find('ul:first') .stop(true, true) .slideToggle(); }); }); This is image of what is happening
  18. I'm writing code to validate a form and I'd like to be able to set the position of the cursor to the field of my choice when I detect an error. I'm getting the strong impression that I have to use Javascript to set the position of the cursor via the focus() function. But how do I pass information from my PHP code to Javascript to tell it which field I want the focus on? For example, let's say I've got a simple form contain Name, Email address, Subject and Message. I check for bad data in all of those fields and I want to put the cursor (or focus) on the first field that has an error. How does my PHP code tell Javascript that the first field in error is the Email Address or the Message or whatever? An example showing what happens in PHP and what happens in Javascript would be very handy if someone can point me to one or throw one together....
  19. so is there any way to fetch what array to fetch the data from in the Function input? this is what i got so far function onHoverCounter( ChampID ) { var show1 = ChampID[1]; $("#"+show1).addClass('counter'); } ChampID is fetched from <a href="?champion=ahri"><div class="champion apcarry mid" id="ahri" onmouseover="onHoverCounter(this.id);" onmouseout="onmouseoutCounter(this.id);"><img src="img/champions/ahri.jpg"> Ahri </div></a>
  20. I'm trying to load a listbox named Doggie with this script. It's in the header of my webpage. Can anyone see what I am doing wrong? Thank you. switch(n){ case "Place": $(".Doggie").load(function() $.ajax({ type: "POST", url: "place_place.php", cache: false, success: function (html) { $(".Doggie").html(html); } }); }); break;
  21. I have code that is working. $('.Kitty').live("change",function(){ var LocationString = 'Lid='+ $(this).val(); $.ajax({ type: "POST", url: "ajax_area.php", data: LocationString, cache: false, success: function (html) { $(".Pig").html(html); However; I need two values. Lid (LocationString) and Cid (CityString) How would I do this? I tried this and it doesn't work. $('.Kitty').live("change",function(){ var LocationString = 'Lid='+ $(this).val(); var CityString = 'Cid='+ $(this).val(); $.ajax({ type: "POST", url: "ajax_area.php", data: {Lid: LocationString, Cid:CityString}, cache: false, success: function (html) { $(".Pig").html(html); And this is the ajax_area.php file. Its grabbing Lid successfully, how is Cid added to this mix? <?php require('config.php'); if($_POST['Lid']) { $Lid=$_POST['Lid']; $sql=mysql_query("SELECT tblLocations.RestID as Lid, tblAreas.AreaName as name FROM tblLocations INNER JOIN tblAreas ON tblLocations.AreaID = tblAreas.AreaID WHERE tblLocations.RestID = $Lid GROUP BY tblLocations.RestID, tblAreas.AreaName ORDER BY tblAreas.AreaName ASC"); echo '<option selected="selected">--Select Area--</option>'; while($row=mysql_fetch_array($sql)) { echo '<option value="'.$row['Lid'].'">'.$row['name'].'</option>'; } } ?> Help is appreciated! Thank you!
  22. I made this simple shopping cart where you select quantity from a dropwdown list and these numbers get added and you get a total number for all the products and a total number for the product itself. But i want it write the quantity with price and the name and write it in a div placed on the site so that it is easy for the user to see that he added a product. I made the calculating part by adding the products one by one, as i did not array them. But for this next part i just didn't find a way that suited my needs. This is just from my test page , so i only have a few values , but in the other page i have over 70 listed just like these: <div id="radioAlert"> <script type="text/javascript"> //calculator function updatesum() { document.form.sum.value = (document.form.sum0.value -0) *99 + (document.form.sum1.value -0) *99 + (document.form.sum2.value -0) *99; document.form.smu.value = (document.form.prod0.value -0)*99 + (document.form.prod1.value -0) *99 + (document.form.prod2.value -0) *99 + (document.form.prod3.value -0) *99 + (document.form.prod4.value -0) *99; document.form.totalsum.value = (document.form.sum.value -0) + (document.form.smu.value -0); //not a typo i was just lazy with the name //arrays //This one i did not get to work. var myArray = newArray(); myArray[0]=document.form.sum2.value; myArray[1]=document.form.prod0.value; myArray[2]=document.form.prod1.value; myArray[3]=document.form.prod2.value; myArray[4]=document.form.prod3.value; myArray[5]=document.form.prod4.value; for (var i = 0; i < myArray.length; i++) { alert(myArray[i]); } //this part works but i want it to add its value only once and then replace its value if its updated again, if its 0 i want it to be completely removed. var prod1 = document.form.sum2.value; var prod2 = document.form.sum1.value; var radioAlert = document.getElementById("radioAlert"); var radioAlert2 = document.getElementById("radioAlert"); if (document.form.sum2.value>0) { //document.write("pilotjakke pelsforet small " + prod1 + " stk"); radioAlert.innerHTML += ("pilotjakke pelsforet small " + prod1 + " stk"); alert("pilotjakke pelsforet medium " + prod1 + " stk"); } if (document.form.sum1.value>0) { //document.write("pilotjakke pelsforet small " + prod1 + " stk"); radioAlert2.innerHTML += ("pilotjakke pelsforet medium " + prod2 + " stk"); } } </script> </div>
  23. *I wasnt quite sure what forum to put this at, so since im coding in PHP i posted it here* I am currently creating a League of Legends Champion site where i want it to when i hover over a Champion (Character) i want its counters to get a red/green border (depending on if the champion is good against it or the champion itself is good vs it) So i started using the CSS:hover way, but looking at this i cant help but to notice that it will require a whole lot of code, so im kinda wondering if theres another way of doing it with like Jquery or plain javascript (Maybe even a PHP Function?) I got all the counters stored in a Database Built up as following: CREATE TABLE `counters` ( `Name` TEXT NULL, `Counter 1` TEXT NULL, `Counter 2` TEXT NULL, `Counter 3` TEXT NULL, `Counter 4` TEXT NULL, `Counter 5` TEXT NULL, `Counters 1` TEXT NULL, `Counters 2` TEXT NULL, `Counters 3` TEXT NULL, `Counters 4` TEXT NULL, `Counters 5` TEXT NULL, `Good With 1` TEXT NULL, `Good With 2` TEXT NULL, `Good With 3` TEXT NULL, `Good With 4` TEXT NULL, `Good With 5` TEXT NULL ) i already know how to fetch the data and such, so thats not the problem (just included this if it would be usefull in anyway) But ye, to summarize it im asking if theres another way to do it with Javascript/PHP or anything like that, and also if you would be kind enough to give me a hint about how to do that (i dont need you to write the whole code since i enjoy that myself) but simply a hint on how to do it. And also once again i apologize if this is the wrong part of the forum to put it (move it if needed)
  24. Hello guys, I'm building a website for tablets and i want o add the ability for the user to swipe down to another div. I've found some jquery plugins for this but only for left/right, and from some blogs that jquery doesn't support this ? Is that true and how can i overcome this ? I don't know javascript/jquery and i'd like some help.
  25. Hi, In my project I am calling ul and li data in Iframe and when I click on link then it move fucus on top instead of selected item. Following is the example of the problem. testFrame.htm <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>Tree Frame</title> </head> <body> <table width="50%" border="0"> <tr id="frameRow"> <td> <iframe id="treeFrame" src="treeFrame2.htm" width="50%" height="100%" scrolling="yes" frameborder="0"> </iframe> <td> </tr> </table> </body> </html> testFrame2.htm <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>Test Frame2</title> <script language="javascript" type="text/javascript"> function focusMe(id) { documentBygetelementsbyid(id).focus(); } </script> </head> <body> <ul> <li><a href="#" id="1" onclick="javascript:focusMe('1');">menu1</a></li> <li><a href="#" id="2" onclick="javascript:focusMe('2');">menu2</a></li> <li><a href="#" id="3" onclick="javascript:focusMe('3');">memnu3</a></li> <li><a href="#" id="4" onclick="javascript:focusMe('4');">menu4</a></li> <li><a href="#" id="5" onclick="javascript:focusMe('5');">menu5</a></li> <li><a href="#" id="6" onclick="javascript:focusMe('6');">menu6</a></li> <li><a href="#" id="7" onclick="javascript:focusMe('7');">menu7</a></li> <li><a href="#" id="8" onclick="javascript:focusMe('8');">menu8</a></li> <li><a href="#" id="9" onclick="javascript:focusMe('9');">menu9</a></li> <li><a href="#" id="10" onclick="javascript:focusMe('10');">menu10</a></li> <li><a href="#" id="11" onclick="javascript:focusMe('11');">menu11</a></li> <li><a href="#" id="12" onclick="javascript:focusMe('12');">menu12</a></li> <li><a href="#" id="13" onclick="javascript:focusMe('13');">menu13</a></li> <li><a href="#" id="14" onclick="javascript:focusMe('14');">menu14</a></li> <li><a href="#" id="15" onclick="javascript:focusMe('15');">menu15</a></li> </ul> </body> </html> Any solution? - Thanks Zohaib.
  • 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.