add value to dropdown list

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
madu
Forum Commoner
Posts: 32
Joined: Sat Dec 25, 2010 3:19 am
Location: india

add value to dropdown list

Post 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>
Last edited by Benjamin on Sat Jan 08, 2011 1:12 am, edited 1 time in total.
Reason: Added [syntax=php] tags.
d3ad1ysp0rk
Forum Donator
Posts: 1661
Joined: Mon Oct 20, 2003 8:31 pm
Location: Maine, USA

Re: add value to dropdown list

Post 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!
sutki72
Forum Newbie
Posts: 1
Joined: Sat Jan 15, 2011 6:03 am

Re: add value to dropdown list

Post 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

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