473,322 Members | 1,241 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,322 software developers and data experts.

how to deal whit vars in this form

Hi,

I have found whit google this form in this group. But i'n not good in
javascript :(. I try and error normal but i only error now :P

Whit i now want to now how can i get access to the vars vis and inv. Normal
when i submit a form then is see something link
formhandler?vis=somthing&inv=something. But i dont see that in this form.
I want the use data form this form to set it in a databse whit php. I cant
get use nog $_GET['vis'] is wil give nothing.

Is there someone who can helpen me ?

The script:
<SCRIPT LANGUAGE="JavaScript"> // Code to move the seletions
function moveSelected(from, to) {
var fl = from.length;
var tl = to.length;
var i;
var n;
var newOpt;
// if there is a blank set <option></option>, get rid of it
if(tl == 1 && to.options[0].text == "") {
to.options[0] = null;
document.recalc(true);
tl--;
}
var index = 0;
for(i = 0; i < fl; i++) {
if(from.options[i].selected == true) {
newOpt = new Option(from.options[i].text, from.options[i].text,
false,
false);
index = findIndex(newOpt, to);
to.options.add(newOpt);
for(n = tl; n > index; n--) {
to.options[n].text = to.options[n - 1].text;
}
tl++;
to.options[index].text = newOpt.text;
from.options[i--] = null;
document.recalc(true);
fl--;
}
}
return;
}
function findIndex(insert, toList) {
var k;
for(k = 0; k < toList.length; k++) {
if( sorted(insert, toList.options[k]) == false) {
break;
}
}
if(k < 0) {
k = 0;
}
return k;
}
/* NOTE: This function will select all options in a select box.
This is
is often needed in conjunction with the moveSelected function.
Moving
an option into a "selected" box won't send it along when the form
is
submitted unless that box has all options selected.
*/
function doSelects(formElement) {
var i;
for(i = 0; i < formElement.length; i++) {
formElement.options[i].selected = true;
}
return;
}
function sorted(one, two) {
var oneString = one.text;
var twoString = two.text;
if(oneString > twoString) {
return true;
}
else {
return false;
}
}
</SCRIPT>
<form action=test.php method="get">
<table align=center width=400 style="font-family:arial; font-size:9pt;
color:purple;">
<tr>
<td>
<ul>
<li>Use the buttons below to add and remove
suppliers
<li>Hold down shift and use the mouse to select
multiple supliers
<li>Submit changes by clicking 'Update Database'
</ul>
</td>
</tr>
</table>
<p align="center"></p>
<table border=2 bordercolor=purple align=center><tr><td align=center>
<table align=center border=0 bgcolor=#f5f5f5 cellspacing=8
cellpadding=8>
<tr>
<td align=center style="font-family:arial; font-size:9pt;
color:purple;">Unavailable Suppliers</td>
<td width=50 align=center>&nbsp;</td>
<td align=center style="font-family:arial; font-size:9pt;
color:purple;">Available Suppliers</td>
</tr>
<tr>
<td align=center>
<select multiple style="width:150; color:purple;
background:#f5f5f5;"
size=10 id="inv" name="inv">
<option value=1>Supplier 1</option>
<option value=2>Supplier 2</option>
<option value=3>Supplier 3</option>
<option value=4>Supplier 4</option>
<option value=5>Supplier 5</option>
</select></td>
<td align=center> <!-- ################ BUTTONS ############## -->
<table align=center width=100% height=100% border=0 cellspacing=4
cellpadding=4>
<tr>
<td align=center>
<input onClick="moveSelected(inv,vis)"
title="Make selected
suppliers available" type="button" style="BACKGROUND-COLOR: #660066;
COLOR: #ffcc00; width:50;" name="add_to_inv" value=" > "><BR>
<input onClick="doSelects(inv);moveSelected(inv, vis) "
title="Make all suppliers available" type="button"
style="BACKGROUND-COLOR: #660066; COLOR: #ffcc00; width:50;"
name="add_to_vis" value=" >> "><BR>
</td>
</tr>
<tr>
<td align=center>
<input onClick="moveSelected(vis, inv)"
title="Make selected
suppliers unavailable" type="button" style="BACKGROUND-COLOR: #660066;
COLOR: #ffcc00; width:50;" name="add_to_vis" value=" < "><BR>
<input
onClick="doSelects(vis,inv);moveSelected(vis, inv)"
title="Make all suppliers unavailable" type="button"
style="BACKGROUND-COLOR: #660066; COLOR: #ffcc00; width:50;"
name="add_to_inv" value=" << "><BR>
</td>
</tr>
</table>
<td align=center>
<select multiple style="width:150; color:purple;
background:#f5f5f5;"
size=10 id="vis" name="vis">
<option value=6>Supplier 6</option>
<option value=7>Supplier 7</option>
<option value=8>Supplier 8</option>
<option value=9>Supplier 9</option>
<option value=10>Supplier 10</option>
</select>
</tr>
<tr>
<td align=center colspan=3><input type=submit name=submit
value="Update Database" style="BACKGROUND-COLOR: #660066; COLOR:
#ffcc00; width:200;"></td>
</tr>
</table></tr></td></table><form>
Greets Wouter
Feb 19 '06 #1
1 1951
VK

news.wanadoo.nl wrote:
Hi,

I have found whit google this form in this group. But i'n not good in
javascript :(. I try and error normal but i only error now :P

Whit i now want to now how can i get access to the vars vis and inv. Normal
when i submit a form then is see something link
formhandler?vis=somthing&inv=something. But i dont see that in this form.
I want the use data form this form to set it in a databse whit php. I cant
get use nog $_GET['vis'] is wil give nothing.


"inv" and "vis" are not JavaScript variable: these are names of two
form elements (select lists). It is bad that you did not give a name to
your form. Presuming that this is the only form on your page, you get
references to these elements by:

var invRef = document.forms[0].elements['inv'];
var visRef = document.forms[0].elements['vis'];

The further depends on what do you want to do with them. Say you want
to know all selected options in multiple select list:

var tmp = '';
for (var i=0; i<invRef.options.length; i++) {
tmp = 'Option ' + invRef.options[i].text
+ ' with value of ' + invRef.options[i].value + ' is currently ';
tmp+= (invRef.options[i].selected) ? 'selected' : 'not selected';
}

Feb 20 '06 #2

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

Similar topics

0
by: james | last post by:
I am new to php and need some help getting the session variables into include files. (after-thought, Sorry for the drawn out post but I really, really need help....;) Here's what I'm doing.. ...
1
by: nick | last post by:
hi, i have to run php 4 on IIS 6 on win 2k and something seeminly really weird is happening. the first few times i hit the page, any vars posted from the form and any session_vars don't seem...
9
by: bissatch | last post by:
Hi, How would I go about destroying POST vars after their use in a script? Is this possible? The reason is that when I use a script that, for example, add a row to a database. If for some...
1
by: conglomco | last post by:
I a trying to make a form that displays the results of radio buttons, to the user, and at the same time parses the results to an html file to be uses on a larger page. I have some debugging commands...
1
by: Admir Hod?ic via AccessMonster.com | last post by:
I use some old fashion program whit DBF files and now i step by step moving thth to acces. Problem occurs when i try to link DBF tables whit MEMO FILED wich requvest file whit ''name''.ftp extension...
6
by: JDP | last post by:
First off let me say that http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnaspp/html/converttoaspnet.asp would not work as I see it. Right off, I can't have a cookie. ...
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...
14
by: Wouter | last post by:
Hi, I try to make the follow. I want that i can click on a text link and that then a link wil be copyed in a input form box (<input type="text" name="img_url" />). I have google-ed about how...
1
by: Ken Fine | last post by:
I am wondering if there is a build-in method in .NET for arbitrarily and correctly combining/concatenating querystring variables into a valid querystring. i.e. I might have the following vars I...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

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.