Multiple inputs to one
Posted: Mon Mar 27, 2006 3:29 pm
Hi,
After a messy attempt at using php to populate a text field from multiple sources, i've decided to use javascript instead.
Basically the user is presented with two list boxes, a text field input and up to three drop down menus that will populate a text area 'search box' when the user has finished populating the text area, the contents are then submitted for a search.
The code i have been using is
I've never used javascript before - well not like this anyway - can anyone give me any pointers to get me started?
Also if I am using sql to dynamically populate the list boxes and drop down menus, am i right in thinking that the javascript will be able to pull those values without any direct communication between the javascript and the php code.
Thanks a lot for any help you can give
rj
After a messy attempt at using php to populate a text field from multiple sources, i've decided to use javascript instead.
Basically the user is presented with two list boxes, a text field input and up to three drop down menus that will populate a text area 'search box' when the user has finished populating the text area, the contents are then submitted for a search.
The code i have been using is
Code: Select all
<!-- Web Site: http://www.web-savant.com/users/kathi/asp -->
<!-- This script and many more are available free online at -->
<!-- The JavaScript Source!! http://javascript.internet.com -->
<!-- Begin
function moveOver()
{
var boxLength = document.choiceForm.choiceBox.length;
var selectedItem = document.choiceForm.available.selectedIndex;
var selectedText = document.choiceForm.available.options[selectedItem].text;
var selectedValue = document.choiceForm.available.options[selectedItem].value;
var i;
var isNew = true;
if (boxLength != 0) {
for (i = 0; i < boxLength; i++) {
thisitem = document.choiceForm.choiceBox.options[i].text;
if (thisitem == selectedText) {
isNew = false;
break;
}
}
}
if (isNew) {
newoption = new Option(selectedText, selectedValue, false, false);
document.choiceForm.choiceBox.options[boxLength] = newoption;
}
document.choiceForm.available.selectedIndex=-1;
}
function removeMe() {
var boxLength = document.choiceForm.choiceBox.length;
arrSelected = new Array();
var count = 0;
for (i = 0; i < boxLength; i++) {
if (document.choiceForm.choiceBox.options[i].selected) {
arrSelected[count] = document.choiceForm.choiceBox.options[i].value;
}
count++;
}
var x;
for (i = 0; i < boxLength; i++) {
for (x = 0; x < arrSelected.length; x++) {
if (document.choiceForm.choiceBox.options[i].value == arrSelected[x]) {
document.choiceForm.choiceBox.options[i] = null;
}
}
boxLength = document.choiceForm.choiceBox.length;
}
}Also if I am using sql to dynamically populate the list boxes and drop down menus, am i right in thinking that the javascript will be able to pull those values without any direct communication between the javascript and the php code.
Thanks a lot for any help you can give
rj