473,598 Members | 3,212 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

cleanup a select/options list - remove same items.

I hope that someone can help me with the following:

Short background explenation:
I have a shrfepoint page (newform.aspx) in a item list. On this page is
a lookup column that displays a lookup of all category items in
previous items. In the code this results in a select/options list like
this:

<SELECT TABINDEX=1
NAME="urn:schem as-microsoft-com:office:offi ce#CatLookup">< OPTION
Value="">(None) </OPTION><OPTION VALUE="8">name 1</OPTION><OPTION
VALUE="10">name 2</OPTION>><OPTION VALUE="11">name 1</OPTION></SELECT>

Is there a way to clean-up or rewrite this select list before it is
published and remove the double entry using javascript?

Jan 21 '07 #1
3 6421
Beholder wrote:
Short background explenation:
I have a shrfepoint page (newform.aspx) in a item list. On this page is
a lookup column that displays a lookup of all category items in
previous items. In the code this results in a select/options list like
this:

<SELECT TABINDEX=1
NAME="urn:schem as-microsoft-com:office:offi ce#CatLookup">< OPTION
Value="">(None) </OPTION><OPTION VALUE="8">name 1</OPTION><OPTION
VALUE="10">name 2</OPTION>><OPTION VALUE="11">name 1</OPTION></SELECT>

Is there a way to clean-up or rewrite this select list before it is
published and remove the double entry using javascript?
To clean up:

-----------------------------------------

<form>
<select tabindex="1"
name="urn:schem as-microsoft-com:office:offi ce#CatLookup">
<option value="">(None) </option>
<option value="8">name 1</option>
<option value="10">name 2</option>
<option value="11">name 1</option>
</select>
</form>
<script type="text/javascript">
var S =
document.forms[0].elements['urn:schemas-microsoft-com:office:offi ce#CatLookup'];
while (S.options.leng th) S.options[0] = null;
</script>

-----------------------------------------

To rewrite the options "without double entries":

-----------------------------------------

<form>
<select tabindex="1"
name="urn:schem as-microsoft-com:office:offi ce#CatLookup">
<option value="">(None) </option>
<option value="8">name 1</option>
<option value="10">name 2</option>
<option value="11">name 1</option>
</select>
<input type=submit>
</form>
<script type="text/javascript">
var N = new Object();
var S =
document.forms[0].elements['urn:schemas-microsoft-com:office:offi ce#CatLookup'];
while (S.options.leng th) {
if (!N[S.options[0].text]) N[S.options[0].text] = S.options[0].value;
S.options[0] = null;
}
for (i in N) S.options[S.length] = new Option(i,N[i]);
</script>

-----------------------------------------

I define "removing double entries" as "removing options with the same
text" which is probably what you meant. The usual naming is <option
value="[VALUE]">[TEXT]</option>. The criterium that is used to remove
is not case sensitive.

When deleting a double entry, the one that comes first is kept with its
(albeit unique) value. If you want the last one to be kept, change
if (!N[S.options[0].text]) N[S.options[0].text] = S.options[0].value;
into
N[S.options[0].text] = S.options[0].value;

Do you really need a name as
"urn:schema s-microsoft-com:office:offi ce#CatLookup" for the select ? I
would counsel to change it into something shorter and more
alphanumericalo id.

There is a syntax error in your code at the double >(at </OPTION>>).

Hope this helps,

--
Bart

Jan 22 '07 #2
Thank you Bart,

I will try your suggestions asap. Thanks for your clear comments and
suggestions.

As for the select name, this is the default naming which is used by
sharepoint. It has given me a hard time too when taking this nam up in
ie javascript code. It cannot be changed.

Bart Van der Donck schreef:
Beholder wrote:
Short background explenation:
I have a shrfepoint page (newform.aspx) in a item list. On this page is
a lookup column that displays a lookup of all category items in
previous items. In the code this results in a select/options list like
this:

<SELECT TABINDEX=1
NAME="urn:schem as-microsoft-com:office:offi ce#CatLookup">< OPTION
Value="">(None) </OPTION><OPTION VALUE="8">name 1</OPTION><OPTION
VALUE="10">name 2</OPTION>><OPTION VALUE="11">name 1</OPTION></SELECT>

Is there a way to clean-up or rewrite this select list before it is
published and remove the double entry using javascript?

To clean up:

-----------------------------------------

<form>
<select tabindex="1"
name="urn:schem as-microsoft-com:office:offi ce#CatLookup">
<option value="">(None) </option>
<option value="8">name 1</option>
<option value="10">name 2</option>
<option value="11">name 1</option>
</select>
</form>
<script type="text/javascript">
var S =
document.forms[0].elements['urn:schemas-microsoft-com:office:offi ce#CatLookup'];
while (S.options.leng th) S.options[0] = null;
</script>

-----------------------------------------

To rewrite the options "without double entries":

-----------------------------------------

<form>
<select tabindex="1"
name="urn:schem as-microsoft-com:office:offi ce#CatLookup">
<option value="">(None) </option>
<option value="8">name 1</option>
<option value="10">name 2</option>
<option value="11">name 1</option>
</select>
<input type=submit>
</form>
<script type="text/javascript">
var N = new Object();
var S =
document.forms[0].elements['urn:schemas-microsoft-com:office:offi ce#CatLookup'];
while (S.options.leng th) {
if (!N[S.options[0].text]) N[S.options[0].text] = S.options[0].value;
S.options[0] = null;
}
for (i in N) S.options[S.length] = new Option(i,N[i]);
</script>

-----------------------------------------

I define "removing double entries" as "removing options with the same
text" which is probably what you meant. The usual naming is <option
value="[VALUE]">[TEXT]</option>. The criterium that is used to remove
is not case sensitive.

When deleting a double entry, the one that comes first is kept with its
(albeit unique) value. If you want the last one to be kept, change
if (!N[S.options[0].text]) N[S.options[0].text] = S.options[0].value;
into
N[S.options[0].text] = S.options[0].value;

Do you really need a name as
"urn:schema s-microsoft-com:office:offi ce#CatLookup" for the select ? I
would counsel to change it into something shorter and more
alphanumericalo id.

There is a syntax error in your code at the double >(at </OPTION>>).

Hope this helps,

--
Bart
Jan 22 '07 #3
After days of searching and reading about javascript, you just made my
day <big smile>

It works.

Thansk you so much...

Peter
Beholder schreef:
Thank you Bart,

I will try your suggestions asap. Thanks for your clear comments and
suggestions.

As for the select name, this is the default naming which is used by
sharepoint. It has given me a hard time too when taking this nam up in
ie javascript code. It cannot be changed.

Bart Van der Donck schreef:
Beholder wrote:
Short background explenation:
I have a shrfepoint page (newform.aspx) in a item list. On this page is
a lookup column that displays a lookup of all category items in
previous items. In the code this results in a select/options list like
this:
>
<SELECT TABINDEX=1
NAME="urn:schem as-microsoft-com:office:offi ce#CatLookup">< OPTION
Value="">(None) </OPTION><OPTION VALUE="8">name 1</OPTION><OPTION
VALUE="10">name 2</OPTION>><OPTION VALUE="11">name 1</OPTION></SELECT>
>
Is there a way to clean-up or rewrite this select list before it is
published and remove the double entry using javascript?
To clean up:

-----------------------------------------

<form>
<select tabindex="1"
name="urn:schem as-microsoft-com:office:offi ce#CatLookup">
<option value="">(None) </option>
<option value="8">name 1</option>
<option value="10">name 2</option>
<option value="11">name 1</option>
</select>
</form>
<script type="text/javascript">
var S =
document.forms[0].elements['urn:schemas-microsoft-com:office:offi ce#CatLookup'];
while (S.options.leng th) S.options[0] = null;
</script>

-----------------------------------------

To rewrite the options "without double entries":

-----------------------------------------

<form>
<select tabindex="1"
name="urn:schem as-microsoft-com:office:offi ce#CatLookup">
<option value="">(None) </option>
<option value="8">name 1</option>
<option value="10">name 2</option>
<option value="11">name 1</option>
</select>
<input type=submit>
</form>
<script type="text/javascript">
var N = new Object();
var S =
document.forms[0].elements['urn:schemas-microsoft-com:office:offi ce#CatLookup'];
while (S.options.leng th) {
if (!N[S.options[0].text]) N[S.options[0].text] = S.options[0].value;
S.options[0] = null;
}
for (i in N) S.options[S.length] = new Option(i,N[i]);
</script>

-----------------------------------------

I define "removing double entries" as "removing options with the same
text" which is probably what you meant. The usual naming is <option
value="[VALUE]">[TEXT]</option>. The criterium that is used to remove
is not case sensitive.

When deleting a double entry, the one that comes first is kept with its
(albeit unique) value. If you want the last one to be kept, change
if (!N[S.options[0].text]) N[S.options[0].text] = S.options[0].value;
into
N[S.options[0].text] = S.options[0].value;

Do you really need a name as
"urn:schema s-microsoft-com:office:offi ce#CatLookup" for the select ? I
would counsel to change it into something shorter and more
alphanumericalo id.

There is a syntax error in your code at the double >(at </OPTION>>).

Hope this helps,

--
Bart
Jan 22 '07 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
11255
by: headware | last post by:
I have a <select> control that contains many entries. It allows the user to multi-select a group of them, click a button, and store the selected data in a database. Normally they do this starting at the top of the list moving down towards the bottom. The problem I was having was that the <select> control was scrolling back to the top of the page after the postback and the user would lose their place in the <select> control forcing them to...
3
2346
by: Rob | last post by:
Hi, I've got a small javascript problem and I'm kinda stuck. I'm using classic ASP. I have a select box which is populated by a database query and there is a buttom that when clicked it will move the selected item from the first select box and move it to another select box: document.form2.list.options = new Option(count + 1 + ". " + name,company); Then I want to remove it from the first select box:
1
1903
by: Chris Lieb | last post by:
In a form, I have two select lists. One holds the available options. I have some buttons between them for moving items from one list to the other. When the form first loads, all of the items are in the available list and none are in the used list. Available Used --------------- --------------- |item1 | |item3 | |item2 | >> | | |item4 | > | ...
7
16875
chunk1978
by: chunk1978 | last post by:
hello. so i have 2 select menus which add and remove options from a 3rd select menu... it seems, however, that it's not possible to use different select menus to toggle a 3rd, because when an options is removed, the list's options switch, making written javascript unusable? the following code is an example: <script type="text/javascript"> function ToggleEmail()
16
2738
by: Richard Maher | last post by:
Hi, I have this Applet-hosted Socket connection to my server and in an ONevent/function I am retrieving all these lovely rows from the server and inserting them into the Select-List. (The on screen appearance of the Select List grows for the first 5 rows then the scroll bar appears if there's more). So far so good. . . The problem is that none of the rows I'm inserting appear on the screen until I have RETURNed from my function; so If...
11
4492
by: Richard Maher | last post by:
Hi, I have read many of the copius entries on the subject of IE performance (or the lack thereof) when populating Select Lists. I don't mind the insert performance so much, (I get 100x120byte rows inserted/sec up to 500, and 100rows/6secs up to 3000, which isn't great but then the Row Count is clicking away for the user to see and they can hit the "cancel" button at anytime, so overall I'm happy), what really disappoints me is the...
4
4386
by: rn5a | last post by:
A Form has 2 select lists. The 1st one whose size is 5 (meaning 5 options are shown at any given time) allows multiple selection whereas the 2nd one allows only 1 option to be selected at a time. When an option is selected in the 2nd select list, the ASP page posts itself. Assume that the 1st select list has the following 10 options (note that both the select lists are actually populated from 2 different database tables): Australia
1
5064
by: madflytom | last post by:
Hello, I'm trying to move the options of one select list to another select list. The "source" select list is divided into optgroups, and the "target" select list is not. I want to somehow keep track of the moved option's optgroup, so that if I remove it from the "target" select list, it moves back into it's respective optgroup in the "source" select list. I have things moving back and forth, but I'm not sure how to handle the optgroup...
0
7899
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8392
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8397
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8050
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8264
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
5850
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
3897
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
3939
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1250
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.