onChangeEvent in PHP code.

T

techjohnny

I have the following event worked into my php code. I would like this
event to change multiple input boxes, instead of just the one
"searchbox"


<script language="javascript">
function CopyAttributes(src, dest)
{
var i;

dest.id = src.id;
dest.name = src.name;
}

// Performs the mutation on the node with id given by the argument
searchbox.
// opt specifies the type of mutation to make.
function UpdateSearchField(opt, searchbox)
{
var inputbox = document.getElementById(searchbox);

// Based on search type, choose which element to create and
// set its attributes accordingly.

if (opt == 'textarea') { // make a textarea
var el = document.createElement("TEXTAREA");
CopyAttributes(inputbox, el);
el.cols = 27;
el.rows = 4;
el.value = "This is a preview of the TEXTAREA with 30 cols and 4
rows. Please enter the size of your text area in BOX 1 and BOX 2";
}
else if (opt == 'password') { // make a standard text box
var el = document.createElement("INPUT");
CopyAttributes(inputbox, el);
el.type = 'password';
el.size = 30;
el.value = "kljkljlkjl";
}
else if (opt == 'text') { // make a standard text box
var el = document.createElement("INPUT");
CopyAttributes(inputbox, el);
el.type = 'text';
el.size = 30;
el.value = "size=30 change size in BOX 1";

}
else if (opt == 'email') { // make a standard text box
var el = document.createElement("INPUT");
CopyAttributes(inputbox, el);
el.type = 'text';
el.size = 30;
el.value = "(e-mail address removed)";
}
else if (opt == 'checkbox') { // make a standard text box
var el = document.createElement("input");
CopyAttributes(inputbox, el);
el.setAttribute('type', 'checkbox');

}
else if (opt == 'radio') { // make a standard text box
var el = document.createElement("input");
CopyAttributes(inputbox, el);
el.setAttribute('type', 'radio');
el.setAttribute('name','radio');

}
else if (opt == 'select') { // make a drop-down list
var el = document.createElement("SELECT");
CopyAttributes(inputbox, el);
el.size = 1;
el.value = "preview";



var i;
var str = new Array('# ITEMS IN BOX 1----->>');
for (i = 0; i < str.length; i++) {
var opt = document.createElement("OPTION");
opt.appendChild(document.createTextNode(str));
opt.setAttribute('value', str);
if (inputbox.value == str) // check for selected item
opt.setAttribute('selected', 'selected');
el.appendChild(opt);
}
}

// Use the DOM function replaceChild to put in the newly created
// node.

inputbox.parentNode.replaceChild(el, inputbox);
}
</script>

echo "<td><input id=\"searchbox[$i]\" type=\"text\" value=\"\" name=
\"searchbox\" size=\"30\" /></td>";


For example, I might have another input box call box1 that I would
like to use the value selected from searchbox, but return a different
result.

Thanks,

--TJ
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Staff online

Members online

Forum statistics

Threads
473,995
Messages
2,570,230
Members
46,816
Latest member
SapanaCarpetStudio

Latest Threads

Top