Skip to main content

Posts

Showing posts from February 17, 2012

How do I get to #1 of html page using jQuery Address

I'm using asual jquery address plugin for page navigation. But I have a little problem. When I'm inserting mypage.html#first_paragraph address plugin recognize this as new page, not as "goto operation". And I just want this link to go to that place of my page. How can I do this? For example: http://developer.android.com/reference/android/widget/ListView.html#addFooterView(android.view.View ) see, when you click on this link its automatically goes to that place of page (with the addFooterView method) When I'm trying to release this using jquery address plugin, this (<a href="ListView.html#addFooterView(android.view.View)">ListView</a>) link (it opens new page) is recognizing as link (not "go to this part of page" operation)

div not scrolling properly with slimScroll plugin

I am using the slimScroll plugin for jQuery by Piotr Rochala Which is a great plugin for nice scrollbars on most browsers but I am stuck because I am using it for a chat box and whenever the user appends new text to the boxit does scroll using the .scrollTop() method however the plugin's scrollbar doesnt scroll with it and when the user wants to look though the chat history it will start scrolling from near the top. I have made a quick demo of my situation http://jsfiddle.net/DY9CT/2/ Does anyone know how to solve this problem?

Why Json is null in this situation?

I'm trying to return a JSON encoded array from a PHP page via ajax. here's my code from the calling page $('#test_load').click(function(){ $.ajax({ type:"POST", url:'/actions/admin_load.php', dataType: 'json', asynch:false, data:"action=4", success: function(json) { alert("we're back"); alert(json.a); } }); }); here's my php code //return json array case "4" : $str2 = "HELLO"; $arr = array ('a'=>1,'b'=>2,'c'=>3,'d'=>4,'e'=>5); $str = json_encode($arr); echo $str; break; I keep getting "json is null". Any suggestions would be much appreciated

jquery mouseenter mouseout in menu

I met some jquery menu mouseenter problem. How to fix when mouse enter p , the p still display block ? <script> $(document).ready(function() { $('a').mouseenter(function(){ $('p').css('display','none'); $(this).next('p').slideDown('slow'); }).mouseleave(function(){ $('p').slideUp('slow'); }); $('p').mouseenter(function(){ $(this).css('display','block'); });​ }); </script> <div> <a>menu1</a> <p>about us</p> <a>menu2</a> <p>contact</p> </div> <style> div{ position:relative; z-index:0; width:600px; height:20px; } p{ display:none; position:absolute; top:20px; left:0; width:300px; height:100px; background:#ccc; }​ </style> ​ Live demo: http://jsfiddle.net/KTvf7/

JQuery code not working

I am trying to find a cell in a table that has a class of 'empty', i am then using a bit of code to find the id(cell number) so i can the find out what cells are next too it. just too see if it works, i am trying: console.log($('.empty').attr('id')); but Firebug just returns 'undefined' each cell has the class of 'box' and only one has empty as well so 'box empty'. Any asssitance would be much appreciated.

How do I properly use position: absolute?

Sorry for the newbie question, but I can't seem to work around this issue just yet. I have a website with dynamic content all over. When you go to the page of an article, it pulls the content from the database etc. If the user is logged in and is an admin on of the website, I am displaying an "Edit article" link in the top right corner. The only problem is the position of that "Edit article" div . On different screen resolutions, it moves around, as the it's set with a position:absolute , top:x px , left:y px . I am open to any suggestion (Javascript, jQuery most welcome, easy peasy CSS would be best if possible).

.animate() queue option explanation

from http://api.jquery.com/animate/ : queue: A Boolean indicating whether to place the animation in the effects queue. If false, the animation will begin immediately. As of jQuery 1.7, the queue option can also accept a string, in which case the animation is added to the queue represented by that string. I want that the animations added to an object should be start when the last animation ends. From the jquery doc it seems to me that, in order to achieve this, the animation must added to a queue. if I pass {queue: true} the animation is added to the general queue, while in jQuery 1.7 I can pass {queue: "queue_foo"} to add the animation to a certain queue. I wrote this in my code, but the animation is not executed. showedSlide.animate({ left: -showedSlide.outerWidth() }, {queue: "left"});

jquery validation engine : ajax field validation with java (not with php)

I try to validate a field with ajax and a function which verify that the value is not already in base. All examples I found are with php ; how to do with java ? JSP code : <form id="FLoginNew" action="Loginnew" method="post"> ..... <script> $(document).ready(function(e) { $("#FLoginNew").validationEngine('attach', {promptPosition : "centerRight", scroll: false, validationEventTrigger: "blur", autoHidePrompt:true, autoHideDelay:3000 }); }); </script> jquery.ValidationEngine-fr.js altered : "ajaxLoginCall": { "url": "myapp.selvlets.DoublonLoginServlet", "extraDataDynamic": ['#login'], "alertText": "* Ce login est déjà pris", "alertTextOk": "* Ce login est disponible", "alertTextLoad": "* Chargement, veuillez att

PHP/JSON-jquery pagination

I Need away to show two per page, and have a pagination at the bottom of the page. Here is how I am currently doing it. As you can see we dont do any pagination at the moment. PHP code which returns the JSON data public function realcashoffers($state,$count) { $this->state = $state; $this->number = $count; $result = $this->JSONselect("approved_business, business_stores, Real_Cash_Offers"," *, group_concat(offer ORDER BY offer ASC SEPARATOR ',') as offers"," approved_business.id = business_stores.business_id AND Real_Cash_Offers.business_id = approved_business.id AND Real_Cash_Offers.storeid = business_stores.storeid AND business_stores.state = '{$this->state}'","GROUP BY id ORDER BY RAND(), approved_business.id DESC LIMIT {$this->number} "); $remaining = $count - count($result); if ($remaining) { $this->type = 'G'; $result = array_merge($result, $this->JSONselect("iN

jquery tabbed trade click for mouse over

I'm using some one else's plugin and I see that it has configurations available, ie. 'tabs:true'(see below). When I look at the plugin file it's just one long line that includes some of these settings separated by pipes '|' like, |scrollspeed|scrolleasing|panelfxfirst|panelbtnshover|verticalslide| <- What are these called so I can google how to use them? I've tried adding panelbtnshover=true, and there was no hover effect. My guess is need to read the two jquery books I bought some more. <script type="text/javascript"> $(window).load(function(){ //$(window).load() must be used instead of $(document).ready() because of Webkit compatibility // Tabs > Standard $(".tabs-standard").sliderkit({ auto:false, tabs:true, //mousewheel:true, circular:true, panelbtnshover:true, panelf

How to get json data from a file (jQuery)

Just cant figure it out. I have a large object stored as a JSON file and I want to access it once and use it multiple times: var myjson = new Object(); $.getJSON("myJSON.js", function(json) { myjson = JSON.stringify(json); }); $('#console').append(myjson); This does nothing. It's a scope issue, I know. I just don't know how to do what I'm wanting. Must I do all my functions inside the $.getJSON call or is there a way to pass the object that I can use throughout runtime?

Multiple jqGrids fires ajax call for every jqGrid on page

I have three grids each has a unique: pager, ID, and wrapper. These grids are hidden by default and show upon selection of a dropdown box. At page load, before anything is selected, jqgrid makes three ajax calls for its data, but after debugging it appears that each grid makes three calls, one for each of the grids on the page. I would like each grid to only request its data for its own grid. Typically the first grid times out and the other two work flawlessly. I believe that the first one may bog down the number of connections to the server causing it to timeout and then the others are then free to proceed because they are below the max number of connections. Any thoughts, ideas, or suggestion are greatly appreciated.

Set first selected image in Galleriffic jQuery plugin?

I am using the Galleriffic jQuery plugin for my photo gallery. The gallery images are loaded from a database in PHP. I want to be able to link to one photo in the gallery from another web page, with an URL query that passes the ID of that image. This image should then be selected and shown in the big preview (or slideshow container), instead of the first image which is the default. What I want to do is: mywebsite.com/pictures/?pid=12345 where 12345 is the ID of the image to be selected.

JS Object, how to access objects from within myself

So, i see no reason why this isn't working but i am at a wall and frustrated. Why can't i call this.myself from within the wyr.message.close function? Maybe my understanding of this is scewed but i was sure this is referring to the object itself, not the function. this.myself is undefined Code: wyr.message = { myself: $('.message'), init: function() { if(this.myself.is(':visible')){ setTimeout(this.close, 5000); } }, close: function(){ this.myself.fadeOut(1200,function(){ this.myself.remove(); }); } }

Populating a select list based on an index from another select list using jQuery and xml

I've been trying to fix a problem i've been having all afternoon and was hoping someone might be kind enough to help me spot my error.I've only started learning jQuery this morning and was trying to get this function working but its proving a bit of a pain in the proverbial... I'm trying to populate a model select list based on a value from a make select list My jQuery function looks like this: $(document).ready(function() { $('#make').change(function(){ alert('Changing'); $('#model option').remove(); $('#model').attr('disabled',true); $.ajax( { type: "GET", url: "../xmlsource/models/model-"+$('#make option:selected').val()+".xml", dataType: "xml", success: function(xml) { alert('XML'); $(xml).find('model').each(function() {

HTMLInstance.attachEvent onload

The following code works with IE9 but not with IE8 HTMLInstance.attachEvent("onclick" , function() { } ); // work with IE8 HTMLInstance.attachEvent("onload" , function() { } ); // does not work with IE8 but works with IE9 How can I fix the problem with onlaod event ?

jQuery JSON response into table column

The excerpt below is part of a .ajax() function I'm using to pull data from a database. The database is queried using PHP and the output sent back in JSON format. Only 1 row of data is returned by the function. success: function(data) { for(var key in data) { $("#formTable tr").find("td:eq(1)").text(data[key]); } } I have an HTML table on the page which is split into two columns. The left column has field labels, the right column is empty. I would like to cycle through my JSON reply for each key/value pair. I would like to insert the value into the right hand column table cell. The code should cycle through until all key/value pairs have been output onto the next table row, into the next right hand table cell. The code above selects the second column table cell but inserts the last JSON value into all cells instead of each value going into its' own table cell in the column. I think if I can get the selecto

Adding new row to table and textbox appear from specific dropdown box

I have provided my code here - http://jsfiddle.net/PEYFc/11/ I have shown on the link what I need, for some reason the adding is not working but on my page is it, but thats not the problem. The problem is once I have added a new row, the new row drop down box does not work when selecting volvo, the textbox does not appear.

Using jquery.calculation.js with dynamically added form fields

I'm creating a form with dynamically added fields and would like to sum all added fields. So far I have the following code, but it only sums the first row: <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"> <title>Totals</title> <script type="text/javascript" src="../js/jquery/jquery-1.6.2.js"></script> <script type="text/javascript" src="../js/jquery/jquery.calculation.js"></script> <script type="text/javascript"> //Sum $(document).ready( function (){ $('input[name^=reds]').sum("keyup", "#totalSumReds"); $("input[name^=blues]").sum("keyup", "#totalSumBlues"); } ); </script> <script type="text/javascript"> //Add/remove form fields jQuery(func

How to make a delete confirmation that need a minimum of 1 record to be deleted?

I need help on making a delete confirmation that need a minimum of 1 record to be deleted. I'm still confused on making it. I think there's something wrong in my javascript code. Any help would much be appreciated. Thanks here's the php code: enter code here <script src="javascript.js" type="text/javascript"></script> <?php echo"<form method=POST action='action.php?act=delete'> <input type=checkbox name='checkbox[]' value='1'>1 <input type=checkbox name='checkbox[]' value='2'>2 <input type=checkbox name='checkbox[]' value='3'>3 <input type=submit value=Delete onClick='return del_confirm();'></form>"; ?> here's the javascript code: enter code here function del_confirm() { var msg=confirm('Are you sure?'); var c=document.getElementsByName('checkbox[]'); if(msg) { for(i=0;i<c.len

JavaScript: asynchronous function that resumes to synchronous

I have a large script that is very synchronous. 1) it runs a function like this: var result = doSomethingSynchronous(myVar); if (result === 'something') { doSomethingElse(); } the doSomethingSynchronous function has a for loop that returns a value on a if statement: var i = 0; le = someVariable.length; for (; i < len; i++) { if (someVariable[i] === 'aString') { return true; } else { doSomethingElse(); } } Because the for loop and the processing can be intense, I've replaced the for loop with an iterative queue processing function that runs itself asynchronously using setTimeout after shifting one element from the array. Once it runs asynchronously of course it doesn't return the value and assigns it to the 'result' variable in the first snippet synchronously, and the if statement there always fails. My question is, is there a way to keep this part synchronous? Have the value be assigned to result before the script goes on to th

$("#form&rdquo;).attr("method&rdquo;, "post&rdquo;) is In java Script ASP.NET

I have a Grid view where I have a hyper link button which displays ID, by clicking on it I make a Ajax call to the server and get the specific URL to navigate against of the ID. After the Ajax call complete I call the following Codes to open the respective page in New Tab/Window. function RedirectPageUrl(rqstID) { $("#formMain").attr("action", rqstID); $("#formMain").attr("method", "post"); $("#formMain").attr('target', '_blank'); $("#formMain").submit(); return false; } Here my problem is after clicking on the First hyperlink button things are working perfectly but then onwards whenever I click on any control (say Button)the previous opened form opens up. How to get rid of it any idea??

Can I set an instance property in Javascript on a Scriptable Member property in Silverlight?

I have the following (2) 'ScriptableMember' types in my Silverlight control: <ScriptableMember()> Public Property MType As MyCustomType <ScriptableMember()> Public Property Message As String The purpose here is obviously to allow exposure via the HTML bridge in Javascript. Calling the 'Message' property is trivial and works perfectly like below: var SLControl = document.getElementById("SilverlightControl"); SLControl.Content.MyRegisteredControl.Message = 'Hello'; However I am having trouble setting the values of an instance property by drilling down to its properties in JS. The code I would think should be as below: SLControl.Content.MyRegisteredControl.MType.Name = 'John'; Notice how I added in the 'MType' and then accessed one of its Public Properties named 'Name'. The MyCustomType class has all the appropriate 'ScriptableMember' atributes as required. However when that line above is ran I get the

Recursion in jQuery event

This event is attached to a set of elements: var elems = $(this).filter(function(){ ... }); How can I trigger a change event on these elements within a change event handler, but ignore the current element? elems.bind('change input', function(){ // do some stuff... // then trigger change, but not on "this", to avoid the recursion issue elems.change(); }); Basically I want ot ignore this from elems , but only in my "manual" change()-call above...

Closing the jsp page based on user choice

I have a jsp page where if the user closes the page the popup box should appear asking whether he really wants to close the page. If he chooses to close the page then i need to redirect to another jsp page using ajax. How do i achieve the same. I have a sample code which asks the user when he clicks the close button but this message is getting popped up when refresh,submit or clear buttons or any other buttons are pressed. Can anyone sggest to modify the given code or any new functionality which achieves the same. sample.jsp <html> <head> <title>Refresh a page in jQuery</title> <script type="text/javascript" src="jquery-1.4.2.min.js"></script> </head> <body> <h1>Stop a page from exit with jQuery</h1> <button id="reload">Refresh a Page in jQuery</button> <script type="text/javascript"> $('#reload').click(function() { location.reload(); }

Splitting a CSV into an object with javascript/jquery

I have an ordered array which looks like this:- [-0.0020057306590257895, 50, 0.09598853868194843, 50, 0.19398280802292264, 49.99999999999999, 0.2919770773638969, 50] What I would like to do is the following: Take each 'odd' entry and make it the 'key index in an object, which can be achieved by rounding the value and multiplying by 10 e.g. (Math.round(-0.0020057306590257895 * 10) should be index 0 and Math.round(0.09598853868194843 * 10) should be index 1 etc) Take the 'even' values and make them the corresponding values in the object. So... The above CSV file should return the following object:- { 0: 50, 1: 50, 2: 49.99999999999999, 3: 50 } Does anyone one know how I can parse this CSV to produce the required array using either jQuery or plain javascript?

this.function is not a function error, but function exists

I have some code to get calendar events and display them. The display is only updated if the events have changed, since the last call. var calendar = { events = null, display_calendar_events : function (data) { // Some display stuff... }, get_events: function() { // Get messages for calendar $.getJSON("/ajax/get-events/", function(json){ var new_events = json.data; // If events haven't changed, do nothing if (this.events === new_events) { return true; } // Events have changed. // Save new events this.events = new_events; // Display new events this.display_calendar_events(json); }); }, } I call this with: calendar.get_queued_events(); The problem is, I'm getting the error "this.display_calendar_events is not a function" (last line of code). But if I change this line to: calendar.d

Google Chome "Application Shortcut&rdquo; Custom Javascript

Introduction Google chrome has a feature that allows you to create shortcuts to web pages and make them appear like traditional desktop applications. For example, a shortcut to twitter mobile might be C:\Users\<username>\AppData\Local\Google\Chrome\Application\chrome.exe --app=https://mobile.twitter.com/ The file icon for this app is stored in C:\Users\<username>\AppData\Local\Google\Chrome\User Data\Default\Web Applications\mobile.twitter.com\https_80 My Question It's been a while since I've used this feature and I seem to remember that you could add your own javascript files to the app folder which were included when the application was loaded. However, I cannot find any documentation that discusses this feature but I'm 99% certain it exists. Does anyone have any details if this feature is available and what files I need to create?

Javascript regex replace weird behavior

I'm developing a js to dig up Bible references on Portuguese web pages, and link them to a youversion.com url. This is one of those pages: http://www.adventistas.org.pt/Evangelismo/Web/Img/Downloads/Trimensario/2012/1t/online/licao7.htm This is the script: http://www.adventistas.org.pt/Evangelismo/Web/Img/Downloads/Trimensario/2012/1t/online/bibleref.js It pretty much works, but it acts kinda funny, and can't find out why. Sometimes it outputs empty links with correct bible references, and then outputs the real link, with a wrong reference. Eg: <a target="_blank" href="http://www.youversion.com/bible/verse/arc/gen/2/1-3" class="passagem"></a> <a target="_blank" href="http://www.youversion.com/bible/verse/arc/gen/2/1-3" class="passagem"></a> <a target="_blank" href="http://www.youversion.com/bible/verse/arc/gen/2/1-3" class="passagem"></a> <

jqPlot custom tick labels

I've got data with X values from 0 to 55. I would like to see these values as a custom text in tick labels. Ideally, I want to specify some callback, like function tickLabel(tickValue) { return "This is " + tickValue; } Is it possible?

An easy way to post to a URL and not use ajax?

Using jQuery, I know $.ajax() can be used to POST to a url but I can't use $.ajax() for my problem. I want the client to POST to a url and have the server redirect to a user to some url (PRG pattern) so therefore, it cannot use XHR requests. How can I get the client to POST to a url without creating a <form> ? Surely, there's got to be an easier solution than this. jQuery post request (not Ajax)

Is there a way to tell which javascript file holds an event handler?

This problem has bothered me for a while and Im sure theres some sort of technicality which stops this from being possible, but is there a way to find which Javascript file is linked to a button? So when I press a submit button and it triggers a Javascript event, I need to find the code which is being triggered rather than trawling through every link in the head of the html trying to find "jQuery('submitBtn').click(..." Im using Firebug and sometimes Chrome's console.

Class Pointers in CoffeeScript?

trying to figure out how to write the following in CoffeeScript: var foo = new function() { var $this = this; $("#foo").click( this.clicked ); this.clicked = function() { $this.alert( $(this).text() ); }; this.alert = function(message) { alert(message); }; }; Unfortunately I can't figure out for the life of me how in CoffeeScript I access the class pointer, "this" is obviously not context aware and will often just point to the variable passed by the callee. So there's no way for me to write the above script in CoffeeScript. Any advice? I can't find anything useful in the documentation, you have the @ pointers but they also just use the "this" pointer from the current context, making it useless..

JavaScript "this" confusion

This is probably pretty easy, yet I am confused, so maybe I might still learn something more today. I am trying to do the following: var myObj = {}; myObj.src = {} myObj.src.A = ['1.png','2.png','3.png']; myObj.A = new Image(); myObj.A.src = this.src.A[0]; This will result in an Uncaught TypeError: Cannot read property 'A' of undefined error. When I use myObj.src.A[0] instead of this it is working fine. What would be the correct way to use this in this context?

asp.net unable to locate a resource file

Im attempting to utilize some custom script and css files within an asp page. In Visual Studio 2010 I am not getting any warnings or errors as to the status of these files, but when I attempt to run the page, and I open the javascript console I get the error: Failed to load resource: the server responded with a status of 404 (Not Found) Here's how I am attempting to load the files in my ascx file: <script type="text/javascript" src="scripts/jquery.js"></script> <script type="text/javascript" src="scripts/jquery.scripts.js"></script> <script type="text/javascript" src="scripts/jquery.alerts.js"></script> <link href="styles/jquery.alerts.css" rel="stylesheet"/> Anyone know whats going on here, why the browser can't locate the files but visual studio can?

javascript function not returning correct value

I have this function that checks a UK postcode. The problem is that it never returns true or false - only undefined . function PostcodeAnywhere_Interactive_FindByPostcode_v1_00(Key, Postcode, UserName) { var retval; $.getJSON("https://services.postcodeanywhere.co.uk/PostcodeAnywhere/Interactive/FindByPostcode/v1.00/json3.ws?", { Key: Key, Postcode: Postcode, UserName: UserName }, function (response) { // Test for an error if (response.Items.length == 1 && typeof(response.Items[0].Error) != "undefined") { // Show the error message retval = false; } else { // Check if there were any items found if (response.Items.length == 0){ retval = false; } else { retval = true; } } }); return retval; } To me it looks like it should always return true or false , so I can't unders

Javascript function not getting called in Drupal 7 which used to run proper in Drupal 6

I am in the process of migrating my Drupal 6 site to Drupal 7. As a result i am facing some issues with the code. The calling of javascript laced with jquery etc is different in Drupal 7 is what i have read. This is the image of the page i had in Drupal 6. On change of the dropdown box, the table above it gets populated with projects belonging to that status. This works fine in Drupal 6. But in Drupal 7 i see this javascript error. This is the form element for the Dropdown in my php file. <? php $form['status_list'] = array( '#type' => 'select', '#title' => t('Freeway Project Statuses'), '#options' => array( 0 => t('-Select Status-'), 1 => t('Draft'), 2 => t('NotSpecified'), 3 => t('Quote'), 4 => t('Forecasted'), 5 => t('InEvaluation'), 6 => t('Cancelled'), 7 => t('Booked'), 8 => t('InProduction'), 9 =&g

JS Lint Array Literal Notation with String Split

I know that JSLint is only a guide and you should take what it says with a grain of salt, however, I'm curious how I can even resolve this warning without rewriting the entire function. Here is the function of interest: function randomString(length) { var chars = 'ABCDEFGHIJKLMNOPQRSTUVWXTZabcdefghiklmnopqrstuvwxyz'.split(''), str = '', i; if (!length) { length = randomNumber(chars.length); } for (i = 0; i < length; i++) { str += chars[randomNumber(chars.length)]; } return str; } JS Lint tells me "JS Lint: Use the array literal notation []." and it is pointing to the line with string.split() . How can I satisfy JSLint without having to re-write the entire function? Is it even possible? I am aware that there are other methods to generate random strings; I'm interested in how to resolve the JSLint warning using this method.

IronJs and C# how compile and translate

I'd like to convert my library in Javascript to C#. While doing research, it seems that it'll be easier to compiling the Javascript directly to a .NET executable instead of converting the code to C#. I've found IronJS but I found way to compile to .NET exe or dll to unassemble later.

How do I convert domain.com/foo/bar/baz/ into a string like "foo bar baz"?

Basically I want to be able to grab the ending of an url, and convert it into a string to be used somewhere. Currently I'm doing this (which is less than optimal): // grab the path, replace all the forward slashes with spaces local_path = location.pathname.toString().replace(/\//g,' '); // strip empty spaces from beginning / end of string local_path.replace(/^\s+|\s+$/g,"")); But I think there is probably a better way. Help? Edit: Could I confidently get rid of the .toString method there?

How to loop through and extract property values from a complex object (Array)?

The following snippet is from an opensource poker client written in JQuery. It displays a poker table that has been previously spawned by the poker server. The table is displayed within a div on the page after the page is loaded. // // featured table // jpoker.plugins.featuredTable = function(url, options) { var opts = $.extend({}, jpoker.plugins.featuredTable.defaults, options); var server = jpoker.url2server({ url: url }); server.registerUpdate(function(server, what, packet) { if (packet && packet.type == 'PacketPokerTableList') { if (packet.packets.length === 0) { var updated = function(server, what, packet) { if(packet && packet.type == 'PacketPokerTableList') { var found = null; for(var i = packet.packets.length - 1; i >= 0 ; i--) { var subpacket = packet.packets[i]; if(opts.compare(found, subpacket) >= 0) { found = subpacket;

How to assign value to $_SESSION with AJAX?

Yes, I'm aware that this question has already been post, but ... I'm looking for a way to check if the Client has Javascript Enabled. Here is my idea : At every loading page, PHP initialize $_SESSION['is_js'] to 0 . Then, I wish AJAX to ( via launching a script php ? ) try to set $_SESSION['is_js'] to 1 . If JS is enabled, AJAX will succeed, if not, the value remains 0. I can't use jQuery or others libraries... I have to write this in pure AJAX ( I mean not using framework or librairies ), and I have no idea how to do this. Edit : I can't use cookie. I don't want to use <noscript> .

how to insert value in input, with javascript

So I tried to do something like this - $('#price').val(price); price is 300, and it shows good on browser, in input field, but when I want to take it out and mail it with PHP, in $_POST['price'] it doesn't show up, How can I insert something in inputs value with JavaScript, so I can mail it? It seems this is not an insertion in value, but just a feature to display something, correct?