Jquery :: Sending Array From Multiple Selection Box To Server
May 25, 2010
I have a selection box that allows me to select muliple items. I'm trying to use the click event handler to send an array of multiple selections back to the server using the $.ajax function and I'm having some issues. Below is my html, javascript code, and PHP server-side code:
HTML CODE:
<label>Select a Color</label><br/>
<select name="ddl" id="multiple" size=9 multiple>
<option value='blue'>Blue</option>
<option value='green'>Green</option>
<option value='red'>Red</option>
<option value='yellow'>Yelllow</option>
<option value='white'>White</option>
<option value='brown'>Brown</option>
<option value='black'>Black</option>
<option value='orange'>Orange</option>
<option value='purple'>Purple</option>
</select>
<input name="btn" id="btn" type="button" value="Submit" /><br/><br/><br/>
<div></div>
JAVASCRIPT CODE:
$(document).ready (
function(){
$('#btn').click(
function(){
$.ajax ({
type: "POST",
url: "phpMultiple.php",
data: {data: $('#multiple :selected').serialize()},
success: callback
});
});
});
function callback(data, status) {
$("div").text(data);
}
PHP SERVER-SIDE CODE:
<?php
$data = ($_POST['data']);
?>
View 2 Replies
ADVERTISEMENT
Mar 18, 2009
I need to send 15 requests to my server and get results, these results are queries to other sites. I then update my page with the results. I need to know if I am taking the correct approach, as things are working a bit slow, and i.e., seems the be as slow as a snail.
Here is my function for the first request
Code:
function one(){
var xmlHttpa=null;
try{
xmlHttpa=new XMLHttpRequest();
} catch (e){
try {
xmlHttpa=new ActiveXObject("Msxml2.XMLHTTP");
} catch (e){
try {
xmlHttpa=new ActiveXObject("Microsoft.XMLHTTP");
} catch (e) {
alert("Your browser does not support AJAX!");
return false;
}}}
xmlHttpa.onreadystatechange=function(){
if(xmlHttpa.readyState==4){
document.getElementById('resulta').innerHTML = xmlHttpa.responseText;
var el = document.getElementById('showMessagea');
el.parentNode.removeChild(el);
applystyle();
}}
xmlHttpa.open("GET","one.php",true);
xmlHttpa.send(null);
}
I then call this function and others from my page, one(); two(); etc. Am I correct in my approach?
View 1 Replies
View Related
Apr 5, 2006
Do you know a dynamic way to send 10kb of text or more using an iframe?
I tried to do that with by creating, in javascript, a dynamic iframe,
then create a form into this iframe and put the data in a textarea and
then call a sumbit(). Code:
View 1 Replies
View Related
Jul 27, 2011
I am trying to send the login info from a form into a IIS server and the asp file on the server will just respond back with the following text "Welcome, &name" on a ajax form on the client side. Currently, i am using a GET response and would like to send using JSON instead.
html file on client side
Quote:
<!-- AJAX component-->
<!DOCTYPE HTML>
<html>
<head>
[Code]....
View 5 Replies
View Related
Apr 13, 2009
Is it somehow possible to setup a backend server to send a message to a client? Or it is a client always have to establish a connection? What I'm trying to code is a simple chat script that sends a message to the client once a member of the chatroom has logged out. The only way that I can make this work is if the client either sends a message (which is a POST call) or when a time delay occurs (I've set a timer to run every 30s after the last GET or POST call). But both of these are basically CLIENT -> SERVER calls. I don't assume that the other way (SERVER -> CLIENT) is possible? no?
View 2 Replies
View Related
Mar 20, 2007
I spent the best part of yesterday trying to get my form to be sent to the server however for the life of me I cannot figure out the problem. I haven't used prototype before but here is my code that I think should work perfectly fine,The php script works perfectly, i've entered test data into it and it makes a connection to the third party server using curl and then requests information that I get back i.e. the routing id comes back. But I cannot test the data using the form as the request isn't working for some reason.
View 3 Replies
View Related
Jul 21, 2010
I'm having troubles with sending array via $.post (it sends just keys) my code:
[Code]...
View 1 Replies
View Related
Aug 10, 2010
I got something like that:
<script type="text/javascript">
$(document).ready(function(){
$('#demo1').quickEdit();
});
[Code].....
View 7 Replies
View Related
Mar 29, 2006
i have made an application in php so that people can make, on the fly, a
form. when they submit the form there is a javascript formvalidation.
because we do not know how many fields there are in the form (it is made on
the fly) i collect all the form fieldnames in an php array and sent it to
the javascript function: Code:
View 5 Replies
View Related
Jan 12, 2011
I need to set Jquery Date picker with multiple selection, But condition is to select consecutive date only. How to achieve this?
View 2 Replies
View Related
Aug 1, 2011
The problem I have is that the NETiom board will only accept single commands to the HTML server built in to the NETiom.
What I dould like to do is send the following commands, timed 500ms apart to switch off 4 outputs before initilising 1 of the 4 inputs.
The commands I need to send are : B01 B02 B03 B04 T01
These 5 commands switch off relays 1 2 3 4 beofre energising relay 1
OK the code I'm using currently is as follows which gives me the correct buttons and action upto the point of cancelling any of the first 4 relays before energising one.
The buttons I would like this action on are NE SE SW NW
Maybe the NE button calls a section of code which will send B01 pause B02 pause B03 pause etc etc
Mak
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Netiom Inputs</title>
[Code].....
View 3 Replies
View Related
Sep 21, 2009
As stated in your documentation, it's possible to iniciate the selector with more than one filter of "^=" kind. But when I try to use that feature it doesn's seem to work. Should it work that way? May I actually use two or more filters of that kind (^=) in the same expression?[code]
View 3 Replies
View Related
Jul 20, 2005
I have a Hyperlink within a String like below:
sSql = "SELECT DISTINCT " + "'Action' = '<center><a
href='+char(34)+'ChangeRequest.aspx?ID='+cast(Chan geRequest.ChangeRequest_ID
as nvarchar) +CHAR(34)+'>Open</a></center>',"
I want to invoke a Client side javascript function and pass the value
of the ID. How can I accomplish this such when a user clicks "Open" he
goes to a new window with the same ID.
I tried this but it does not work:
On Server side:
sSql = "SELECT DISTINCT " + "'Action' = '<center><a href= 'javascript:
NewWindow('+cast(ChangeRequest.ChangeRequest_ID as nvarchar)+
CHAR(34)+)'>Open</a></center>',"
On Client side:
function NewWindow(myID)
{
window.open("ChangeRequest.aspx?ID="+myID,"WindowName","width=500,height=600");
}
</script>
View 1 Replies
View Related
Mar 25, 2010
I have three radio button groups with different values. My script only works for one group.
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<script>
function emailTo(){
var emails = document.getElementsByName("email1");
var emailAdress = null;
[Code].....
View 3 Replies
View Related
Jan 16, 2011
I've got a form which I want to validate using jQuery to ensure that the same value for a dropdown has not been entered more than once. The form consists of the following:
Code HTML4Strict:
<li class="clonedInput" id="input1">
Name:
<select id="player[1][userid]" name="player[1][userid]"></select>
<select class="hours" id="player[1][hours]" name="player[1][hours]"></select>
<select class="mins" id="player[1][mins]" name="player[1][mins]"></select>
[Code]...
View 2 Replies
View Related
Jul 23, 2005
I am trying to create a web page in which the contents of one selection list
depends upon which element in another selection list is chosen, but where
the information to populate the first selection list comves from an SQL
database on the web server.
There are a couple of these situations in my application but, for example,
the first list might be a list of counties, and the second list a list of
states/provinces. Obviously the names of counties depend upon which
state/province is chosen, but there are too many possibilities to be able to
embed them within the web page itself. So when the user selects a
state/province I need to go to the server to ask for the list of counties.
I have seen a number of posts that sort of address this issue. For example
it is suggested to use <script src="a URL"/> to ask the server side code to
send up data of type "text/javascript". However the examples do not seem to
address how the server side code would know which state/province the user
had selected.
If there is a web site that addresses this sort of thing, I would appreciate
any pointers.
View 5 Replies
View Related
Sep 3, 2011
I am developing a messaging service between members of my site. I am developing this with asp.net mvc. When a user goes to the SendMessage view to send a message to another member, there is a dropdown list which presents the sender with all the members of the site, which he or she will pick as the recipient. However, i don't want it to be a dropdown, i want it to be a text box, where a user types in the first couple of letters of a name, and the dropdown appears then with only the members which have the same couple of letters. This is basically like every email system out there (facebook and gmail have it just like that). And after they chose one, they can select another one in the same textbox, just separated by a comma or something like that. Basically, how do i achieve that in javascript? I'm not even sure what that functionality is called, that's why i had to explain it properly.
View 3 Replies
View Related
Feb 22, 2011
I am doing a password reset form using Jquery and PHP. If I try to submit an email id it should sent and email and report back the response text as success so that the user knows email has been sent. But I am stuck with JSON submit as I have an empty array to decode at the serverside. I am using minified version of json2.js from the official json.org website
Here is the code.
Code JavaScript:
var formdata = $("#log-box").serializeArray();
formdata = JSON.stringify(formdata);
var notifymsg;
alert(formdata);
$.ajax({
type: "POST",
url: "forgot-pass.php",
contentType: 'application/json',
data: formdata,
success: function(responsedata){
var some = responsedata.split("&");
$.each(some, function(index,value){
//alert("index="+index+"value="+value);
});
},
error: function(o, s, e){
alert("Form not posted
"+e);
}});
formdata alerted gives:
[{"name":"email","value":"ravi.k@gmail.com"},{"name":"acctype","value":"loginaccount"}]
PHP forgot-pass.php
Code PHP:
print_r($_POST);
Gives
Array(
)
View 3 Replies
View Related
Nov 17, 2010
My goal is to get the value in the array from selection drop down list.Basically, I create an Array in Javascript and a selection drop down list in the body.
Code:
<script type="text/javascript">
var even = new Array(2, 4, 6);
[code]....
View 1 Replies
View Related
Jul 20, 2005
I am trying to retrieve selected values from a multiple select object on a page:
*** Selection Page ***
<form name="theForm">
<select name="numbers" MULITPLE>
<option value="1">One</option>
<option value="2">Two</option>
<option value="2">Three</option>
</select>
</form>
What I want to do is to pass the selected values from "Selection page" to its parent window. Right now, I pass the values by doing this (in JavaScript):
window.opener.parentForm.num.value = document.theForm.numbers.value;
I'm assuming if mulitple selections are made (lets say One and Two are selected), document.theForm.numbers.value will be a collection of the selected option values. Is this correct?
If so, how can I retrieve each option value when coding parent window?
View 1 Replies
View Related
Dec 15, 2011
I have a script I am trying to manipulate. I can do some basics with it but really need to work something out.
It is basically a calender script where I can select multiple days. I really need to be able to reference the id's of each day(div) selected and basically list how many have been selected.
I'm guessing this might not be enough to go on so I may need to post all of the code but this is the part that makes me able to select the days (divs):
Code:
initBackendEvents:function(){// Init Events for the days of the Calendar.
$('.DOP_BackendBookingCalendar_Day', Container).click(function(){
var day = $(this);
if (!day.hasClass('past_day')){
[Code].....
View 1 Replies
View Related
Apr 4, 2011
I have a TreeView populated from a SQL Server database (via an XML doc). The TreeView includes checkboxes on each branch and leaf. Each entry on the TreeView may or may not inherit access permission from its parent. That is, if you're granted access to branch "A", you automatically get permission to leaves "A1", "A2", and "A4", but not to "A3", as its inheritance flag is set to false.I have created an array of struct's on the server-side.
Struct format is:
public struct TreeInheritData
{
public Int32 namespaceID; // this identifies the node
[code]...
The array is populated with these structs.The TreeView I'm using (from Infragistics) has a client-side event when the CheckBox status changes.So, what I need help on is getting this array of structs from the server to the JavaScript, and then being able to access the structs so that I can determine whether to change the status of the child nodes' checkboxes.
View 6 Replies
View Related
Mar 22, 2011
TASK: Convert a 1D javascript array into a 2D array and then save on server as .txt file.
Currently, I have a string of data in a javascript variable [code]...
View 1 Replies
View Related
Mar 5, 2011
I'm doing kind of a form that at the end you can pay thru paypal. I have like a table made of anchor tags <a> and each one is styled as a table cell. What I need to do is to have the ability of multiple select this links. It would be: the user select one or more links and then a variable would carry these links name so he could pay with paypal.
View 5 Replies
View Related
Feb 13, 2010
Is it possible to pull multiple variables from a single dropdown menu selection?
Example:
I have this:
function material_choices_menu() /* Provides Specific Gravity for various materials */{
var data = "Material <select name='material'>";
data += "<option value='.926'>CYCOLAC MG47 (ABS)</option>";
data += "<option value='1.050'>CYCOLAC MG47MD (ABS)</option>";
data += "<option value='.958'>CYCOLAC T (ABS)</option>";
data += "</select>";
document.write(data);
}
I'd like to have multiple option values:
function material_choices_menu() /* Provides Specific Gravity for various materials */{
var data = "Material <select name='material'>";
data += "<option value1='.926', option value2='.005-.008'>CYCOLAC MG47 (ABS)</option>";
data += "<option value1='1.050', option value2='.005-.008'>CYCOLAC MG47MD (ABS)</option>";
data += "<option value1='.958', option value2='.005-.008'>CYCOLAC T (ABS)</option>";
data += "</select>";
document.write(data);
}
I plan to use the first value in some math formulas to determine weights and the rest of the values will just be shown as data for the user and/or possibly a link to the datasheet for the material selected.
View 6 Replies
View Related
Feb 27, 2011
I would like to read a csv file that is on the server into a Javascript array but not sure how to do this. It needs to work on more than just IE.
View 1 Replies
View Related