JavaScript - Trying To Pass A Value In Php Script Via Js? Please Help
Hi All,
have a script which already passes one varible from a php script to my js script but i am having trouble trying to pass another one. here is my php code PHP Code: <?php include("config.php"); $keyword = $_POST['data']; $sql = "select prodName from ".$db_table." where ".$db_column." like '".$keyword."%' limit 0,10"; $result = mysql_query($sql) or die(mysql_error()); if(mysql_num_rows($result)) { echo '<ul class="list">'; while($row = mysql_fetch_array($result)) { $prodCat = $row['category']; $str = $row['prodName']; $start = strpos($str,$keyword); $end = similar_text($str,$keyword); $last = substr($str,$end,strlen($str)); $first = substr($str,$start,$end); $link = ""; $final = '<span class="bold">'.$first.'</span>'.$last; echo '<li><a href="'.$link.'">'.$final.'</a></li>'; } echo "</ul>"; } else echo 0; ?> and here is my original js code Code: $(document).ready(function(){$(document).click(function(){$("#ajax_response").fadeOut('slow');});$("#keyword").focus();var offset=$("#keyword").offset();var width=$("#keyword").width()-2;$("#ajax_response").css("left",offset.left);$("#ajax_response").css("width",width);$("#keyword").keyup(function(event){var keyword=$("#keyword").val();if(keyword.length) {if(event.keyCode!=40&&event.keyCode!=38&&event.keyCode!=13) {$("#loading").css("visibility","visible");$.ajax({type:"POST",url:"ajax_server.php",data:"data="+keyword,success:function(msg){if(msg!=0) $("#ajax_response").fadeIn("slow").html(msg);else {$("#ajax_response").fadeIn("slow");$("#ajax_response").html('<div style="text-align:left;">No Matches Found</div>');} $("#loading").css("visibility","hidden");}});} else {switch(event.keyCode) {case 40:{found=0;$("li").each(function(){if($(this).attr("class")=="selected") found=1;});if(found==1) {var sel=$("li[class='selected']");sel.next().addClass("selected");sel.removeClass("selected");} else $("li:first").addClass("selected");} break;case 38:{found=0;$("li").each(function(){if($(this).attr("class")=="selected") found=1;});if(found==1) {var sel=$("li[class='selected']");sel.prev().addClass("selected");sel.removeClass("selected");} else $("li:last").addClass("selected");} break;case 13:$("#ajax_response").fadeOut("slow");$("#keyword").val($("li[class='selected'] a").text());searchValue=document.getElementById('keyword').value;window.location="/dvd/"+searchValue+".php";break;}}} else $("#ajax_response").fadeOut("slow");});$("#ajax_response").mouseover(function(){$(this).find("li a:first-child").mouseover(function(){$(this).addClass("selected");});$(this).find("li a:first-child").mouseout(function(){$(this).removeClass("selected");});$(this).find("li a:first-child").click(function(){$("#keyword").val($(this).text());$("#ajax_response").fadeOut("slow");});});}); and i tryed to pass the $prodCat value by changing the above code and adding the code in red Code: $(document).ready(function(){$(document).click(function(){$("#ajax_response").fadeOut('slow');});$("#keyword").focus();var offset=$("#keyword").offset();var width=$("#keyword").width()-2;$("#ajax_response").css("left",offset.left);$("#ajax_response").css("width",width);$("#keyword").keyup(function(event){var keyword=$("#keyword").val(); var category=$("#prodCat").val(); if(keyword.length) {if(event.keyCode!=40&&event.keyCode!=38&&event.keyCode!=13) {$("#loading").css("visibility","visible");$.ajax({type:"POST",url:"ajax_server.php",data:"data="+keyword,success:function(msg){if(msg!=0) $("#ajax_response").fadeIn("slow").html(msg);else {$("#ajax_response").fadeIn("slow");$("#ajax_response").html('<div style="text-align:left;">No Matches Found</div>');} $("#loading").css("visibility","hidden");}});} else {switch(event.keyCode) {case 40:{found=0;$("li").each(function(){if($(this).attr("class")=="selected") found=1;});if(found==1) {var sel=$("li[class='selected']");sel.next().addClass("selected");sel.removeClass("selected");} else $("li:first").addClass("selected");} break;case 38:{found=0;$("li").each(function(){if($(this).attr("class")=="selected") found=1;});if(found==1) {var sel=$("li[class='selected']");sel.prev().addClass("selected");sel.removeClass("selected");} else $("li:last").addClass("selected");} break;case 13:$("#ajax_response").fadeOut("slow");$("#keyword").val($("li[class='selected'] a").text());searchValue=document.getElementById('keyword').value; searchCategory=document.getElementById('category').value; window.location=" /"+searchCategory+"/"+searchValue+".php ";break;}}} else $("#ajax_response").fadeOut("slow");});$("#ajax_response").mouseover(function(){$(this).find("li a:first-child").mouseover(function(){$(this).addClass("selected");});$(this).find("li a:first-child").mouseout(function(){$(this).removeClass("selected");});$(this).find("li a:first-child").click(function(){$("#keyword").val($(this).text());$("#ajax_response").fadeOut("slow");});});}); but this breaks the js code and it prevents it from running any ideas what ive done wrong? thanks Luke Similar TutorialsPLEASE IGNORE - I'D DONE A BOO BOO! </facepalm> Hi guys, not sure i have a decent explanation in the title. so, let me explain. i have a script that collapses rows in tables but i create the array in php. the button needs to be above the content else i could just create it using php if i try this function in a .js file it all works: Code: function toggleAll() { //collapse all layers in var togglelist = "['380','379','378','377','376','374','373','369','367']"; for (var i=0; i<togglelist.length; i++) { collapseTableRows(togglelist[i]); } } the problem is that i need to create togglelist when im doing the php. if i just do a simple: Code: <script> var togglelist = "['380','379','378','377','376','374','373','369','367']"; </script> at the bottom of the page i cant seem to pass togglelist to the function in the .js file im a bit rusty at JS so i think im doing something wrong. or is it just that i cant pass a variable array to a function if the variable is below the function on the page... i hope that makes sense. Here is my code <script language="javascript" type="text/javascript"> function revealModal(divID) { window.onscroll = function () { document.getElementById(divID).style.top = document.body.scrollTop; }; document.getElementById(divID).style.display = "block"; document.getElementById(divID).style.top = document.body.scrollTop; } function hideModal(divID) { document.getElementById(divID).style.display = "none"; } </script> <div id="modalPage3"> <div class="modalBackground"></div> <div class="modalContainer"> <div class="modal53"> <div class="modalTop"><a href="javascript:hideModal('modalPage3')">[X]</a></div> <div class="modalBody"> <?php echo 'value='.$_SERVER['value']; ?> <h3><center>Choose from the options below</center></h3> <center><div id="stylized" class="myform"> <a href="javascript:hideModal('modalPage3');javascript:revealModal('modalPage1')" tabindex="2" title="Remove UPCAT Passer"><img src="images/photo_remove.png" /></a> <a href="javascript:hideModal('modalPage3');javascript:revealModal('modalPage2')" tabindex="4" title="Edit UPCAT Passer"><img src="images/photo_edit.png" /></a> <a href="javascript:hideModal('modalPage3');javascript:revealModal('modalPage4')" tabindex="4" title="Change Status of UPCAT Passer"><img src="images/photo_up.png" /></a> </div></center> </div> </div> </div> </div> <a href=javascript:revealModal('modalPage3');> <img src=images/option.jpg /></a> my problem is this one..how can I pass a value example value=3 to be like href= index.php?value=3..PLEASE HELP!!! Is it possible to pass the id onChange like in this example instead of the value This is part of a large complex script, and I need the id as seperate function Code: <select name='color' onChange='this.form.F1.value=this.form.color.id' > <option value='Green' id='c1'>Green <option value='Red' id='c2'>Red <option value='Blue' id='c3'>Blue </select> <input type="text" name="F1" size="15" value="" onChange="this.value=this.form.color.id"> hi in javascript section there is a variable namesd first is available. i want to pass the value of this variable in a php variable. how can i do this.. Hi!! I am trying to find out solution for this since long. I tried js but as I am not good with it, I just want to do this through PHP. I am adding dynamic rows when user clicks the Add Row button.I want to show the calculated amount like: line_total=qty*unit_price; PHP Code: if (isset($_POST['qty']) && sizeof($_POST['qty']) > 0) { for($i = 0, $maxi = count($_POST['qty']); $i < $maxi; $i++) { $quantity = (isset($_POST['qty'][$i]) && !empty($_POST['qty'][$i])) ? mysql_real_escape_string($_POST['qty'][$i]) : 0; $description = (isset($_POST['description'][$i]) && !empty($_POST['description'][$i])) ? mysql_real_escape_string($_POST['description'][$i]) : 0; $unit_price = (isset($_POST['unit_price'][$i]) && !empty($_POST['unit_price'][$i])) ? mysql_real_escape_string($_POST['unit_price'][$i]) : 0; $line_total = (isset($_POST['line_total'][$i]) && !empty($_POST['line_total'][$i])) ? mysql_real_escape_string($_POST['line_total'][$i]) : 0; ?> <?php $myvar=$quantity*$unit_price; ?> <script type="text/javascript"> jsvar = <?php echo $myvar; ?>; document.write(jsvar); // Test to see if its prints array: </script> } } This code works very well and displays the values.But if I use it in the function like; PHP Code: function line(elem) { jsvar = <?php echo $myvar; ?>; document.getElementById("line_total").value = jsvar; } And call it: PHP Code: <input type="text" name="line_total[]" id="line_total" onBlur="return line(this)"> It is not showing the result. Kindly guide me where I am going wrong? This is my function to add rows: PHP Code: <script type="text/javascript"> function addRow(tableID) { var table = document.getElementById(tableID); var rowCount = table.rows.length; if(rowCount<3) { var row = table.insertRow(rowCount); var colCount = table.rows[0].cells.length; for(var i=0; i<colCount; i++) { var newcell = row.insertCell(i); newcell.innerHTML = table.rows[0].cells[i].innerHTML; //alert(newcell.childNodes); switch(newcell.childNodes[0].type) { case "text": newcell.childNodes[0].value = ""; break; case "checkbox": newcell.childNodes[0].checked = false; break; case "select-one": newcell.childNodes[0].selectedIndex = 0; break; } } } else { alert("Maximum Limit Of 3 Rows Reached"); } } </script> Please help me I'm using a geolocator service to find the zipcode of a web page visitor using the code below. This will be used to serve up ads to the visitor based on their zip code. The question is, how do I pass the zip code value from the script into an ASP variable, such as a cookie or session object? <script language="JavaScript" src="http://www.iplocationtools.com/iplocationtools.js?key=my_site_key"></script> <script language="JavaScript"> <!-- document.write(ip2location_zip_code()); //--> </script> I've avoided cookies for 12 years. I made my first cookie today: Code: <p><a href="projects.html" onclick="document.cookie='whichPic=8'">Set Cookie</a></p> I have an external javascript sheet with an array of images w/text and the following code: Code: var current = 0; function update() { var pic = slides[current]; document.getElementById('proj_title').innerHTML = pic.title; document.getElementById('proj_image').src = "images/slides/" + pic.image; document.getElementById('proj_location').innerHTML = "<span>Location:</span> " + pic.location; document.getElementById('proj_operation').innerHTML = "<span>Commercial Operation:</span> " + pic.commercial_operation; document.getElementById('counter').innerHTML = (current + 1) + " of " + slides.length; if(pic.link) { document.getElementById('proj_link').style.display = "block"; document.getElementById('proj_href').href = pic.link; } else { document.getElementById('proj_link').style.display = "none"; } } When the user clicks the link, it should open the page to the slideshow and it should start on slide[8]. I think what I need to do is pass the value of the cookie to the variable "current", but I don't know how to do that. Also, I only need the cookie to last long enough for the new page to load (about 20 seconds), but all of the cookie scripts I've found set expiration in days. Any guidance would be appreciated. Hi All, I am a newbie to Javascript, I have a text box which when searched with 3 characters of vendor name will do ajax request and populate the results below the textbox, beside the box are two arrows pointing to a selectbox, when i clcik on the right arrow after the search the vendor name should to added to the select box.... similarly after i add required vendor names, I should be able to delete the name from the select box. I have completed the ajax search part of the textbox, and I am stuck with the passing value to the selectbox portion. Anyhelp will be appreciated. thanks in advance! Hey there, I'm using the service from Maxmind to get user's postal code, what I wanna do is pass the value to the next page using GET function.. I am quite new to PHP, however I think I should name the variable first and call it on the next page right? But it doesn't seem to work. Any help is much appreciated! Thanks! Hi all I'm adding buttons to my google map through a loop. I pass some parameters, and the addButtons() function creates the buttons. How can I pass the "task" for the button to the function? In the addDomListener line below, I'm now writing the function name literally, I'd like find a way with a parameter. Thank you.. Code: // The loop... for (i=0;i<=4;i++) { oCC = addButtons(aCtrls[i],'btnContainerChild'); ... } // The function... function addButtons(cButtonID,cClassName) { var oButton = document.createElement('DIV'); oButton.className=cClassName; oButton.id=cButtonID; //... other settings here... // ===> Here, I'd like to set the click function through a parameter google.maps.event.addDomListener(oButton, 'click', function() {gmapSetCenter(defaultCenter)}); I just stucked somewhere in js, i know its simple task but i don't know what's wrong but i believe i just need little guidance to get my result. Here is my problem Code: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <title>sample</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <script language="JavaScript" type="text/javascript"> function OfferTwo(){ var Name = document.getElementById("txtName").value; var Email = document.getElementById("txtEmail").value; var sUrl = document.getElementById('offer2').src; document.getElementById('offer2').src = 'http://www.getmyname.com?info.php?dp=0&l=0&p=0&Name='+Name+'&email='+Email; alert(document.getElementById('offer2').src); } </script> </head> <body> <form name="myFrom" method="get" action=""> <p>Name <input name="txtName" type="text" id="txtName"> </p> <p>Email <input name="txtEmail" type="text" id="txtEmail"> </p> <p>Yes <input type="radio" name="rb" value="radiobutton" onClick="OfferTwo();"> No <input type="radio" name="rb" value="radiobutton"> </p> </form> <iframe name="offer2" id="offer2" src="" height="500px" width="100%" frameborder="0" scrolling="no">Your Browser not supporting</iframe> </body> </html> what i am trying to do on radio click 'YES' option i pass the value into querystring. Till now i got sucess to pass values but now problem is that how i pass this value into iframe src element. I tried alot did lot of googling but didn't get anything yet. Please help me, i know its very basic thing but i didn't trace my mistake. Thanks i n advance i am trying to pass the a variable "oneone" from a select box to a php page via java script. this is my html Code: <div id="wrapper"> <div id="content"> <form> Select a Customer: <select id="oneone" name="oneone" value=""> <option value="s_last">last</option> <option value="s_first ">first</option> <option value="c_city">cirty</option> </select> </form> <div> <form method="get" action="" class="asholder"> <small style="float:right">Hidden ID Field: <input type="text" id="testid" value="" style="font-size: 10px; width: 20px;" disabled="disabled" /></small> <label for="testinput">Person</label> <input style="width: 200px" type="text" id="testinput" value="" /> <input type="submit" value="submit" /> </form> </div> </div> this is my javascript Code: <script type="text/javascript"> var options = { script:"test.php?json=true&limit=6&", varname:"input", json:true, shownoresults:false, maxresults:6, callback: function (obj) { document.getElementById('testid').value = obj.id; } }; var as_json = new bsn.AutoSuggest('testinput', options); var optionsa = { script:"test.php?", varname:"one", json:false }; var as_jsona = new bsn.AutoSuggest('oneone', optionsa); </script> and the little part of my php Code: $input =$_GET['input']; $q =$_GET["one"]; can someone PLEASE tell my why i cant get this to work!!! I'm trying to echo a php variable to my javascript function but nothing is happening Basically this php page displays bunch of records with a radio button next to each record. So when the radio button is clicked it would open that record in a new window that is clicked. Code: <input type='radio' name='option' value='$ctr' id='$ctr' onClick="edit_record('<?php echo $ctr ?>')"> <script type="text/javascript"> function edit_record(){ var value = arguements[0]; alert("record id: " + value); window.open("Edit.php", "Edit Record", "status=1, height=400, width=900, resizable=0"); } ok i have auto complete that i want to be able to select a column of the database before searching on it i just want to pass the oneone variable over to the php page. so i have this javascript Code: <script type="text/javascript"> $().ready(function() { function log(event, data, formatted) { $("<li>").html( !data ? "No match!" : "Selected: " + formatted).appendTo("#result"); } $("#search").autocomplete("test.php", { width: 260, selectFirst: false }); $("#search").result(function(event, data, formatted) { if (data) $(this).parent().next().find("input").val(data[1]); }); $(":text, textarea").result(log).next().click(function() { $(this).prev().search(); // shows resluts }); }); </script> the html Code: <p class="field" > <select id="oneone" name="oneone" style="width:100px;margin:5px 0 5px 0;" value=""> <option value="s_last">Last Name</option> <option value="s_first">First Name</option> <label>Search</label> <input type="text" id="search" /> </p> <p> <label>Hidden input</label> <input type="text" id="inputit" /> Hello. I am very new at using javascript and jquery. Right now Im working on a website, and it has a hierarchical menu in the right and im also doing some content loading in a div, all that with javascript. My problem is that when they click on a link, I need to pass a variable "id" through the link. I dont want to pass it in the url, but I want to pass it in another way, for every link the id is going to be different. How can I pass a variable to another page and how can I retrieve it in that page so I can use it for the content loading? Thanks! Here's my code Code: (function() { var GOOGLE_PLUS_SCRIPT_URL = 'https://apis.google.com/js/client:plusone.js'; var CHANNELS_SERVICE_URL = 'https://www.googleapis.com/youtube/v3/channels'; var VIDEOS_UPLOAD_SERVICE_URL = 'https://www.googleapis.com/upload/youtube/v3/videos?uploadType=resumable&part=snippet'; var VIDEOS_SERVICE_URL = 'https://www.googleapis.com/youtube/v3/videos'; var INITIAL_STATUS_POLLING_INTERVAL_MS = 15 * 1000; var accessToken; $.getJSON( "the_key.txt", function( data ) { accessToken = data.access_token; function initiateUpload(e) { e.preventDefault(); var file = $('#file').get(0).files[0]; if (file) { $('#submit').attr('disabled', true); var gettags = $('#tags').val() var metadata = { snippet: { title: $('#title').val(), description: $('#description').val(), categoryId: 20, tags: ['"' + gettags.replace(/,/g , '", "') + '"'] }, }; $.ajax({ url: VIDEOS_UPLOAD_SERVICE_URL, method: 'POST', contentType: 'application/json', headers: { Authorization: 'Bearer ' + accessToken, 'x-upload-content-length': file.size, 'x-upload-content-type': file.type }, data: JSON.stringify(metadata) }).done(function(data, textStatus, jqXHR) { resumableUpload({ url: jqXHR.getResponseHeader('Location'), file: file, start: 0 }); }); } } function resumableUpload(options) { var ajax = $.ajax({ url: options.url, method: 'PUT', contentType: options.file.type, headers: { 'Content-Range': 'bytes ' + options.start + '-' + (options.file.size - 1) + '/' + options.file.size }, xhr: function() { // Thanks to http://stackoverflow.com/a/8758614/385997 var xhr = $.ajaxSettings.xhr(); if (xhr.upload) { xhr.upload.addEventListener( 'progress', function(e) { if(e.lengthComputable) { var bytesTransferred = e.loaded; var totalBytes = e.total; var percentage = Math.round(100 * bytesTransferred / totalBytes); $('#upload-progress').attr({ value: bytesTransferred, max: totalBytes }); $('#percent-transferred').text(percentage); $('#bytes-transferred').text(bytesTransferred); $('#total-bytes').text(totalBytes); $('.during-upload').show(); } }, false ); } return xhr; }, processData: false, data: options.file }); ajax.done(function(response) { var videoId = response.id; document.location="http://ez-gaming.net/index.php?app=videos&module=post§ion=submit&do=add_video&cat=&vidid=" + videoId; }); ajax.fail(function() { $('#submit').click(function() { alert('Not yet implemented!'); }); $('#submit').val('Resume Upload'); $('#submit').attr('disabled', false); }); } $(function() { $.getScript(GOOGLE_PLUS_SCRIPT_URL); $('#upload-form').submit(initiateUpload); }); }); })(); As you see I get JSON from the_key.txt and assign in to a variable. I call this variable later in the script but it doesn't seem to work. I did Code: alert(accessToken); after I put Code: $.getJSON( "the_key.txt", function( data ) { accessToken = data.access_token; and it worked and gave the correct string. But when I call accessToken in the initiateUpload function it does not work. AS shown he Code: function initiateUpload(e) { e.preventDefault(); var file = $('#file').get(0).files[0]; if (file) { $('#submit').attr('disabled', true); var gettags = $('#tags').val() var metadata = { snippet: { title: $('#title').val(), description: $('#description').val(), categoryId: 20, tags: ['"' + gettags.replace(/,/g , '", "') + '"'] }, }; $.ajax({ url: VIDEOS_UPLOAD_SERVICE_URL, method: 'POST', contentType: 'application/json', headers: { Authorization: 'Bearer ' + accessToken, 'x-upload-content-length': file.size, 'x-upload-content-type': file.type }, data: JSON.stringify(metadata) }).done(function(data, textStatus, jqXHR) { resumableUpload({ url: jqXHR.getResponseHeader('Location'), file: file, start: 0 }); }); } } Any ideas how to solve this? I want to pass the value to my object id = "Parameters" How can I do that? I had tried the code as posted below but it couldn't work. I'm using document.all.Parameters.data = tempParams[0]; to pass in the data to <OBJECT id="Parameters" style="Z-INDEX: 200; LEFT: 0px; TOP: 0px; POSITION: ABSOLUTE;" type=application/pdf height=800 width=1060 VIEWASTEXT scroll=yes></OBJECT> I also have tried document.getElementById("Parameters").data = tempParams[0]; but still doesn't work. The code attached as below. PHP Code: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <title>Management System Manual</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <script language="JavaScript" type="text/JavaScript"> <!-- function MM_reloadPage(init) { //reloads the window if Nav4 resized if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) { document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }} else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload(); } MM_reloadPage(true); function right(e) { if (navigator.appName == 'Netscape' && (e.which == 3 || e.which == 2)) return false; else if (navigator.appName == 'Microsoft Internet Explorer' && (event.button == 2 || event.button == 3)) { alert("Sorry, you do not have permission to right click."); return false; } return true; } document.onmousedown=right; document.onmouseup=right; if (document.layers) window.captureEvents(Event.MOUSEDOWN); if (document.layers) window.captureEvents(Event.MOUSEUP); window.onmousedown=right; window.onmouseup=right; // End --> </script> <script type="text/javascript" language="JavaScript1.2"> <!-- // Begin //Disable right click script //no alert var message=""; /////////////////////////////////// function onKeyDown() { if ( (event.altKey) || ((event.keyCode == 8) && (event.srcElement.type != "text" && event.srcElement.type != "textarea" && event.srcElement.type != "password")) || ((event.ctrlKey) && ((event.keyCode == 82)) ) || (event.keyCode == 68) || (event.keyCode == 80) || (event.keyCode == 78) || (event.keyCode == 66) || (event.keyCode == 72) || (event.keyCode == 73) || (event.keyCode == 74) || (event.keyCode == 70) || (event.keyCode == 122) ) { event.keyCode = 0; event.returnValue = false; } } function clickIE() {if (document.all) {(message);return false;}} function clickNS(e) {if (document.layers||(document.getElementById&&!document.all)) { if (e.which==2||e.which==3) {(message);return false;}}} if (document.layers) {document.captureEvents(Event.MOUSEDOWN);document.onmousedown=clickNS;} else{document.onmouseup=clickNS;document.oncontextmenu=clickIE;} document.oncontextmenu=new Function("return false") // End --> </script> <script type="text/javascript" language="JavaScript1.2"> function getParams() { var idx = document.URL.indexOf('?'); var idx1 = document.URL.indexOf('#'); var tempParams = new Object(); if (idx != -1) { var pairs = document.URL.substring(idx+1, idx1).split('?'); //pairs = 1; for (var i=0; i<pairs.length; i++) { nameVal = pairs[i].split('='); tempParams[0] = nameVal[1]; } } //document.getElementById("Parameters").data = tempParams[0]; //document.all.Parameters.data = tempParams[0]; document.all.Parameters.data = tempParams[0]; //alert (window.document.parameters.data); return false; } </script > </head> <style media="print"> body { display : none; } </style> </HEAD> </head> <!-- <body ondragstart="return false" onselectstart="return false" onkeydown=onKeyDown() onload=setInterval("window.clipboardData.clearData();getParams();",2) oncontextmenu="return false" scroll=yes > --> <body ondragstart="return false" onselectstart="return false" onkeydown=onKeyDown() onload=getParams() oncontextmenu="return false" scroll=yes > <!--<input id="abc" type="text"/>--> <form id="frmRestricted" method="post"> <div id="Layer2" style="position:absolute; left:0px; top:-35px; width:1060; height:800; z-index:201"> <OBJECT id="Parameters" style="Z-INDEX: 200; LEFT: 0px; TOP: 0px; POSITION: ABSOLUTE;" type=application/pdf height=800 width=1060 VIEWASTEXT scroll=yes></OBJECT> </div> </form> </body> </html> Thank you very much Basically I am trying to retrieve my image path data from mysql to my variable created in my javascript. This is the code I m using. <?php $result = mysql_query("SELECT * FROM Shop"); while($row = mysql_fetch_array($result)) { $shopName[] = $row['ShopName']; $shopLogo[] = $row['ShopLogo']; $shopDescription[] = $row['ShopDescription']; $totalShops = count($shopName); } for($i=0; $i<totalShops; $i++){ echo "<script type='text/javascript'>"; echo "var logos = new Array();" echo "</SCRIPT>"; } ?> However, I cant solve the for loop part. I wanted to pass each and every data retrieved from mysql query into the array created in javascript part inside the for loop. Can anyone teach me how to do that? Thanks. hi, I would like to pass a link through the same page using XMLHttpRequest or what ever is best without reloading the page eg; I have : Code: <a id="prev"><? echo $prev;?></a> <a id="page"><? echo $page;?></a> <a id="next"><? echo $next;?></a> if someone click on the link id='next' then they go to the next page where at the moment in the URL it says: default.php?page=3 Hello Guys, I need some help here.. I have a page that has a grid on it and I have a hidden div(below the grid). When the link is clicked inside the grid it opens the hidden div using the following code for the link in the grid. Here is my code with the PHP id that I need to pass PHP Code: foreach($ct->data as $key => $value){ $ct->data[$key][3]='<a href=#" onclick="part2('.$ct->data[$key][0].');" href="javascript:void();">'.$ct->data[$key][3].'</a>'; Here is the code in my head Code: <script type="text/javascript"> function part2(id) { var part2 = document.getElementById('part2'); if ( part2.className == 'hidden' ) { part2.className = 'visible'; document.getElementById('message').InnerHTML = 'This is the ID: '+id } else { part2.className = 'hidden'; } } </script> Added this to my hidden div to show the id Code: <span id=message></span> Any help would be appreciated.. Thanks, Dan |