473,403 Members | 2,270 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,403 software developers and data experts.

Values from drop down box

Hi

I am trying to get the following code to work I believe it should work but i don't understand why it doesn't :(

I am trying to get it to take words that have been placed into the accepted dropdown box, and place a semi-colon at the end of each word, so that I have a delimited list of words.

Which I then wish to pass into to the URL, which would allow me to do the necessary processing on the words in my PHP scripts


my code looks like the following

Expand|Select|Wrap|Line Numbers
  1. function createLinks()
  2. {
  3.   var Values = '';
  4.     var selectBox = document.getElementById('acceptwords').options;
  5.     for(var i=0; i<selectBox.length; i++) { // Loop through the options.
  6.       Values += selectBox[i].value + ";"; // Concatenate the option values into the Value string.
  7.     }
  8.     Values=Values.replace(/;$/,""); // Trim the leading semi-colon.
  9.   window.location="http://www.asite.com?words="+Values;  
  10. }
  11.  
and i call it using the

[HTML]
<input type="button" value="Make Link" onClick="createLinks()">
[/HTML]

any help would be greatly appreciated

Boyindie
Jan 21 '08 #1
9 1611
acoder
16,027 Expert Mod 8TB
It should work. Show the code for the select element.
Jan 21 '08 #2
It should work. Show the code for the select element.
What do you mean by the select element?

The actual drop down box

sorry i am new to javascript
Jan 21 '08 #3
acoder
16,027 Expert Mod 8TB
Yes, the drop down box.
Jan 21 '08 #4
the dropdown box looks like the following

[HTML]<table border="0">
<tr>
<td>
<select id="wordlist" name="sel1" size="10" multiple="multiple">
<option value="">Word List</option>
</select>
</td>
<image src=""
onClick="moveOptions1();"/><br /><br />
<image src="h"
onClick="moveOptions2();"/>
</td>
<td>

</select>
<input type="button" value="Make Link" onClick="createLinks()">

</td>
</tr>
</table>[/HTML]
Jan 21 '08 #5
acoder
16,027 Expert Mod 8TB
Where's the drop down box with id "acceptwords"?
Jan 21 '08 #6
Where's the drop down box with id "acceptwords"?
Appologies

I must of messed up the paste somehow

this is my drop down box

[HTML]<table border="0">
<tr>
<td>
<select id="wordlist" name="sel1" size="10" multiple="multiple">
</select>
</td>
<td align="center" valign="middle">
<image src="http://right_arrow.png"
onClick="moveOptions1();"/><br />
<image src="http:///left_arrow.png"
onClick="moveOptions2();"/>
</td>

<td>
<select id="acceptWords" name="sel2" size="10" multiple="multiple">
</select>
<input type="button" value="Create Links" onClick="createLinks();">
</td>
</tr>
</table>[/HTML]
Jan 21 '08 #7
acoder
16,027 Expert Mod 8TB
JavaScript is case-sensitive. The element has an id of "acceptWords" and you're looking for "acceptwords".
Jan 21 '08 #8
thats it working thank you

i can't believe i haven't noticed that after almost two days!
Jan 21 '08 #9
acoder
16,027 Expert Mod 8TB
Just a capital W, it was. Glad you got it working.
Jan 21 '08 #10

Sign in to post your reply or Sign up for a free account.

Similar topics

5
by: Rob Wire | last post by:
For the code below, how could I add an item in the drop down lists for both company and location to be an "All" selection that would send to the stored proc. spRptAttachments a value of "%" so...
2
by: R-D-C | last post by:
Hi, got a drop-down list on a windows form in VS.NET2003. In the form load when NOT a postback, we add four values to the drop-down list. These appear in Internet Explorer. When you click...
2
by: macyp | last post by:
I have to pass values from one aspx page to another. The controls I have in the first page are: a textbox, 3 drop down lists, and 2 check boxes, and a submit button. It is a search page, and the...
19
by: nazgulero | last post by:
Hello all, I wonder if anybody can give me a hint about what I have to do to get this working: I am creating a drop down box using the script below. The result is two text fields; now I want...
6
by: John | last post by:
I have a drop down on my form and I need all the values in that drop down and pass to a stored procedure, how can I get the values of the drop down and pass them all to my stored procedure call?
0
by: kajir | last post by:
Hi, I am new at using ASP.Net 2.0. I have various drop down lists on my master page. They refer to an SQL database. I also have a menu on the master page. I can select the values in the drop...
2
by: Jim Gregg | last post by:
Hello all, I am faced with some logic that I am unsure how to handle. Imagine that I am running a WMI query and I am outputting the data into a dynamically created ASP table control. Here is my...
3
by: jcassan | last post by:
Hello folks. I am new to these forums and have something, which has been stumping me for little while. I am using pspell to spellcheck a scrolling textbox (textarea) containing user input. I...
1
by: bytenut | last post by:
I would like to display two field values in a combo after selecting from the list items... i.e. my drop-down shows two fields from a lookup, but when I select the item, only the first field value is...
3
by: phpmagesh | last post by:
Hi, I have a drop down in my page, what i will do with that drop down is i have a table in my database, which have values and this table will refer that ID and pick the name of that values and...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
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,...
0
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...
0
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...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
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...

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.