Showing posts with label HTML. Show all posts
Showing posts with label HTML. Show all posts

Thursday, August 11, 2011

Reading disabled HTML fields on page submit


Hi folks,

This probably is not a very big solution, but might be useful for newbies. To prevent users from entering data in any textbox or dropdown, you can either use "readonly" or "disabled". Readonly works fine, apart from the fact that the interface of the fields won't look like they are uneditable. Apart from that if it works for you, then its fine.

For "disabled"  option, not only the entire fields becomes uneditable, but also the interface has the feel that it is disabled. The biggest problem with disabled fields is if the form is submitted, the disabled fields are not submitted.


If you face a scenario where you absolutely have to use disabled fields and yet post the values in form submit, then a quick fix would be

Wednesday, March 30, 2011

Cricket score update - JSON

Hi

I probably should have got this script done long back. If you have a website or a blog where you want to integrate the score update for CWC 2011, then you just need to use the code given below. In this I am using an JSON API of json-cricket.appspot.com for fetching the details. All you have to is parse the JSON returned. The output will be as follows:


This API has not been tested thoroughly, but it surely returns. Here is the code:

For simple HTML

<html>

<head>
<title>Cricket Score Update</title>
</head>
<body>
<div id="score_board"></div>
<script type="text/javascript">
o={s:function(data){document.getElementById("score_board").innerHTML=data.match + "<br />" + data.score + "<br />" + data.summary;}};

Thursday, March 10, 2011

Custom Dropdown with jQuery

Hi,

If you want to customize the conventional dropdown box in HTML, then here is what you need. In this you can put images, hyperlinks anything as the dropdown options. Here is how it looks like:

and the options as:


and finally after selecting:

Thursday, February 24, 2011

Double click on any text in page for its definition and search

Hi,

There are many plugins available for various browsers which does that, I have come up with a custom solution. What is happening here is, considering a web page which has textual content. Whenever a user selects a word by double clicking it, a small popup comes up with the definition of that word. Now in my case i have opted to show the definition of the selected word, you can put your functionality for that word, e.g. a site search with that word.

Since I do not have a word dictionary so I am getting the definition of the word from definr.com and parsing it. You can change this to meet you requirements.

For this you need two files, first being a simple HTML file, "index.html" with the following: