Le Kevin dot com

photographic-poetic-musical horizon

Browsing Posts in Javascript

<input type=”image” value=”edit”> The VALUE attribute is passed by all browsers; except IE and Opera.

The workaround solution is using a hidden field to pass the form action:

function formAction(svalue)
{
var objAction = document.getElementById(“action”);
objAction.value = svalue;
}

//Hidden Action:
<input type=”hidden” name=”action” id=”action” value=”">

//Submit Actions:

<input type=”image” name=”submit” value=”edit” onClick=”formAction(this.value);”>
<input type=”image” name=”submit” value=”delete” onClick=”formAction(this.value);”>
<input type=”image” name=”submit” value=”update” onClick=”formAction(this.value);”>

MS Internet Explorer 8 improves a lot in most aspects, but View Source option is always pain to work with for many web developers; it takes forever to load the code.
Here is a workaround, instead of using view code in the IE default debugger, we load them to a different application such as native notepad, UltraEdit, Notepad++ etc…
Step 1:

Step 2:

Step 3: Then select any application you want to load the html source

document.getElementByID() does not always work on cross browser, and sometime it returns null
In this case, we can use document.getElementsByTagName() to loop through all the “input” and assign values

Example:

var Inputs = document.getElementsByTagName("input");
for (var obj = 0; obj < Inputs.length; obj++){
var Obj = Inputs[obj];
try{
if (Obj.checked)
{
// some code, do something
switch (Obj.id.toLowerCase()){
case "ordertype":
//some code
, do something
break;
}}}
catch (e) {//alert(e); }
}

Most variables in JavaScript represent themselves internally as strings. The String class in JavaScript contains a number of handy methods, but many commonly-used functions which are available in other languages, such as the trim() function, are notably missing from JavaScript.

Since strings are represented as JavaScript classes, it is possible to extend the functionality of the basic String class in order to add those methods which are missing. This article shows how to do this with a few simple lines of JavaScript which can be placed in a <SCRIPT> block at the top of one’s HTML page. continue reading…

Blog WebMastered by All in One Webmaster.