Jump to content

Recommended Posts

Hi,

 

I need to develop a code that allows me to choose how I want to see a list of data from the database.

 

For example, I could choose to see "the most recent first" or "most recent last".

 

I have this example on how work the "onChange" event:

 

<html>
<head>
<title>Select Example</title>
<script>
function onSelectChange(){
	var dropdown = document.getElementById("developer");
	var index = dropdown.selectedIndex;
	var ddVal = dropdown.options[index].value;
	var ddText = dropdown.options[index].text;

	if(ddVal != 0) {
		output = "You Selected " + ddText;
	}

	document.getElementById("output").innerHTML = output;
}
</script>
</head>
<body>

<h3>Developers</h3>
<select id="developer" onChange="onSelectChange();">
	<option value="0">the most recent first</option>
	<option value="1">the most recent flast</option>					
</select>

<br /

<div id="output"></div>
</body>
</html>

 

Now I need to apply this to a SELECT from the database that will use this method to list data. I have tried to google it, but I can't find any example.

 

Can someone give me a clue on how to find the way of doing this? There are any examples?

 

Best Regards,

Link to comment
https://forums.phpfreaks.com/topic/216191-how-to-use-onchange-in-a-dropdown-box/
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.