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

Thursday, September 10, 2009

Set the value of combobox in javascript, set the value of html select value in javascript

Problem: Set the value of a combobox in javascript
Solution: For combobox give the values and names.
for ex:


Screenshot:
Javascript code to set the value of combobox:
document.forms[0].Combo.value="Test2";
i put the above code in Onload of the body. so by default the combo box value is "Test2".
The above code should work 99%. If the above javascript code is not working then use this:
for (var i=0; i (lessthan symbol here) document.forms[0].Combo.length; i++) {
if (document.forms[0].Combo[i].value == "Test2") {
document.forms[0].Combo[i].selected = true;
}
}




Wednesday, September 9, 2009

Refer a field value in iframe from parent window

Hi today i came across to read a field value of iframe from a main parent window.

Here is the javascript code:

var temp = document.getElementById('iframeid').document.getElementById('fieldID').value;

Its so simple... Right?

Search This Blog