473,405 Members | 2,444 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,405 software developers and data experts.

Using Post to take values from Javascript listbox and passing to PHP

1
I am trying to use a Javascript picklist box and then echo the chosen values back to the screen (and insert in the db later) but I am getting the Button value rather than the list values. I have followed the advice on the forum to us and ID and getElementByID in the <select> line, but no luck.

Thanks in advance

HTML
[HTML]</head>
<body>

<form method="post" name="combo_box" action=subscribe3.php>
<table cellpadding="4" cellspacing="0" border="0">
<tr>
<td>
<select multiple size="10" name="list1" style="width:150" onDblClick="move(document.combo_box.list1,document .combo_box.list2)">
<option value="12">Alabama</option>
<option value="54">Alaska</option>
<option value="65">Arizona</option>
<option value="45">Arkansas</option>
<option value="2">California</option>
<option value="6">Colorado</option>
<option value="81">Connecticut</option>
<option value="5">Delaware</option>
<option value="23">District of Columbia</option>
<option value="58">Florida</option>
<option value="87">Georgia</option>
<option value="98">Hawaii</option>
<option value="53">Idaho</option>
<option value="22">Illinois</option>
<option value="28">Indiana</option>
<option value="89">Iowa</option>
<option value="71">Kansas</option>
<option value="35">Kentucky</option>
<option value="85">Louisiana</option>
<option value="9">Maine</option>
<option value="7">Maryland</option>
<option value="77">Massachusetts</option>
<option value="36">Michigan</option>
<option value="87">Minnesota</option>
<option value="66">Mississippi</option>
<option value="34">Missouri</option>
<option value="50">Montana</option>
<option value="20">Nebraska</option>
<option value="25">Nevada</option>
<option value="32">New Hampshire</option>
<option value="27">New Jersey</option>
<option value="74">New Mexico</option>
<option value="17">New York</option>
<option value="3">North Carolina</option>
<option value="13">North Dakota</option>
<option value="4">Ohio</option>
<option value="21">Oklahoma</option>
<option value="12">Oregon</option>
<option value="48">Pennsylvania</option>
<option value="63">Rhode Island</option>
<option value="82">South Carolina</option>
<option value="14">South Dakota</option>
<option value="72">Tennessee</option>
<option value="49">Texas</option>
<option value="47">Utah</option>
<option value="92">Vermont</option>
<option value="59">Virginia</option>
<option value="52">Washington</option>
<option value="41">West Virginia</option>
<option value="46">Wisconsin</option>
<option value="95">Wyoming</option>
</select>
</td>
<td align="center" valign="middle">
<input type="button" onClick="move(this.form.list2,this.form.list1)" value="<<" id=button1 name=button1>
<input type="button" onClick="move(this.form.list1,this.form.list2)" value=">>" id=button2 name=button2>
</td>
<td>
<select multiple size="10" name="list2[]" id="list2" style="width:150" onDblClick="move(document.getElementByID(list2),do cument.combo_box.list1)">
</select>
</td>
</tr>
<input type="hidden" name="submitted" value="TRUE" />
<tr><td align="center" colspan="3"><input type="submit" name="submit_button[]" value="Subscribe" onClick="selectAll(document.getElementByID(list2)) ;"></td></tr>
</table>
</form

</body>
</html>
[/HTML]

PHP
[PHP]<?php

if (isset($_POST['submitted'])) {
foreach ($_POST['submit_button'] as $key => $value){
echo $value;}
}

?>[/PHP]
Dec 2 '07 #1
1 2164
acoder
16,027 Expert Mod 8TB
Welcome to TSDN!

Post the code for the "move" function.
Dec 3 '07 #2

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

Similar topics

6
by: A P | last post by:
Hi! I have seen some techniques like this on the web. Currently, I'm using Combo box which values came from database table. One disadvantage is when the combo box have lots of values, users are...
19
by: James Fortune | last post by:
I have a lot of respect for David Fenton and Allen Browne, but I don't understand why people who know how to write code to completely replace a front end do not write something that will automate...
4
by: PH | last post by:
Does anyone know how to have the pop-up javascript alert, Response.Write("<script language=javascript>alert('HEY!');</script>); , pop-up after the page has been posted back? I am pressing a...
3
by: Ryan Taylor | last post by:
Hello. I have an application where I need the user to be able to add items to a listbox. I've implemented this via javascript. The listbox is an <asp:ListBox>. However, when the user submits the...
10
by: glenn | last post by:
I am use to programming in php and the way session and post vars are past from fields on one page through to the post page automatically where I can get to their values easily to write to a...
7
by: pamelafluente | last post by:
The precious input given by Laurent, Martin, Benjamin about XMLHttpRequest in Javascript, has made me think that perhaps I could improve what I am currently doing by using Ajax. Let's make it...
6
by: probashi | last post by:
Hi, Issue: After post back selected item of a list box is getting out of focus (when it contains more items than it's size). I have a List Box in an ASPX page. I select an item from the...
0
Fary4u
by: Fary4u | last post by:
Hi Guys i'm trying to upload a file, i've tried 3 different methods but still not work out i don't know how to over come this problem hidden file value, multiple form or popup uploading. 1-...
9
by: Ajinkya | last post by:
Hello friends ! , I am very new to java script.If anyone can help me then I will be very very thankful to his/her. I am using php and mysql in my project and I have one textarea and one...
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
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...
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
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...
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
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.