Welcome to the MacNN Forums.

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

You are here: MacNN Forums > Software - Troubleshooting and Discussion > Developer Center > Dynamic Javascript Listbox

Dynamic Javascript Listbox
Thread Tools
Mac Elite
Join Date: Jan 2001
Status: Offline
Reply With Quote
Oct 7, 2003, 12:10 AM
 
Hi all!

I'm looking for some clean, well writen javascript and html code that produces something like this:

http://www.metabuilders.com/tools/DynamicListBox.aspx

However, I would like the remove button to remove the current selected items in real time, not after pushing another button to reload the page. Also, I would like a textfield before the Add button to add entries in real time to the list box.

What I am trying to do it make a preferences for IPs to block from my PHP pages, so the listbox will have the currently blocked IPs, and then you can remove them, add to them. Then the admin submits all changes to the admin panel (writtin in php) and the changes are saved.

Thanks for any help!

Karl
     
Registered User
Join Date: Jul 2003
Location: San Jose
Status: Offline
Reply With Quote
Oct 7, 2003, 06:22 PM
 
check your private messages....
     
timmerk  (op)
Mac Elite
Join Date: Jan 2001
Status: Offline
Reply With Quote
Oct 7, 2003, 09:11 PM
 
i made up a mockup of what i want it to be like:

http://overridedesign.com/mockup.jpg
     
Registered User
Join Date: Jul 2003
Location: San Jose
Status: Offline
Reply With Quote
Oct 7, 2003, 10:25 PM
 
let's hear it for insomnia...

[php]
<html>

<head>

<script language="JavaScript" type="text/javascript">
function removeIP(v)
{
// remove IP address from list
document.ipForm.ipList[v] = null;

// if no IP addresses are in the list, a message is displayed
if (document.ipForm.ipList[0] == null)
{
// increase the number of options by 1
++document.ipForm.ipList.length;

// add message to the option
document.ipForm.ipList[0].text = "no IP's blocked";
}
}

function addIP(v, l)
{
// if no IP addresses are in the list, adds new as first entry
if (document.ipForm.ipList[0].text == "no IP's blocked")
{
// replaces message with new option
document.ipForm.ipList[0].text = v;
}
// if there are IP addresses in the list, adds new to bottom
else
{
// increase the number of options by 1
++document.ipForm.ipList.length;

// add text to the new option
document.ipForm.ipList[l].text = v;
}
}
</script>

</head>

<body>

<form name="ipForm" method="post">
<select name="ipList" size="10">
<option>192.168.254.2</option>
<option>192.168.254.3</option>
<option>192.168.254.4</option>
</select>
<a href="javascript:removeIP(document.ipForm.ipList.s electedIndex)">Remove</a>
<br>&nbsp;<br>
<input type="text" name="add_ip">
<a href="javascript:addIP(document.ipForm.add_ip.valu e, document.ipForm.ipList.length)">Add</a>
</form>

</body>

</html>
[/php]

see it in action

sosa just hit a hr!!!!!! go cubbies.
     
timmerk  (op)
Mac Elite
Join Date: Jan 2001
Status: Offline
Reply With Quote
Oct 7, 2003, 10:30 PM
 
thanks!
     
Registered User
Join Date: Jul 2003
Location: San Jose
Status: Offline
Reply With Quote
Oct 7, 2003, 10:40 PM
 
no problem... that metabuilder stuff was waaaaayyy too complicated.

simple = good.
     
timmerk  (op)
Mac Elite
Join Date: Jan 2001
Status: Offline
Reply With Quote
Oct 8, 2003, 12:33 AM
 
one other things - i dont understand where the "no ips blocked" messages appear?
     
Registered User
Join Date: Jul 2003
Location: San Jose
Status: Offline
Reply With Quote
Oct 8, 2003, 03:06 AM
 
Originally posted by timmerk:
one other things - i dont understand where the "no ips blocked" messages appear?
when all the ip addresses are removed from the list...
     
   
Thread Tools
Forum Links
Forum Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Top
Privacy Policy
All times are GMT -5. The time now is 07:13 PM.
All contents of these forums © 1995-2011 MacNN. All rights reserved.
Branding + Design: www.gesamtbild.com
vBulletin v.3.8.7 © 2000-2011, Jelsoft Enterprises Ltd., Content Relevant URLs by vBSEO 3.3.2