Page 1 of 1

add value to dropdown list

Posted: Sat Jan 08, 2011 12:59 am
by madu
hi friends,,,,,
i want add text box value ahen i am click create button,,,here is my code,,,,but it not working ,,wat s the problem

Code: Select all

<html>
<head>
<title>Group mail</title>
<script language=javascript>

function add()
	{
		
				
  		var str=document.frm.lina.value;
		
		alert(str);
		
		var optn = document.createElement("OPTION");
		
		optn.text = document.frm.lina.value;
		
		alert(optn.value);

		getElementByid('sel').options.add(optn);	

	}
</script>

</head>
<body>
<div id=d style="position:absolute;left:300px;top:200px">

<form name=frm>

Enter the List Name <br>you want to Create : <input type=text name=lina  style="position:absolute;left:140px;top:16px"> <br>

<select name=sel id=sel style="position:absolute;left:300px;top:16px">

<option>None</option>

</selet>

<input type=button value=Create name=cre onClick="add();" style="position:absolute;left:170px;top:60px">

</form>

</div>
</body>

</html>

Re: add value to dropdown list

Posted: Sat Jan 08, 2011 1:32 am
by d3ad1ysp0rk
1. The method is "getElementById", the I must be capitalized.
2. You must reference it using the document object. ie. document.getElementById('objectId');
3. For best practices, you should use quotes around all attributes in your tags.

Hope this helps!

Re: add value to dropdown list

Posted: Sat Jan 15, 2011 8:40 am
by sutki72
d3ad1ysp0rk wrote:1. The method is "getElementById", the I must be capitalized.
2. You must reference it using the document object. ie. document.getElementById('objectId'); порно

3. For best practices, модули для dle you should use quotes around all attributes in your tags.

Hope this helps!
thanks for the info, helped me

_______________________________________
квартиры посуточно в Тюмени