Needs help as i am trying to pull all recrods from the listbox

C

colleen1980

Hi: I am trying to pull all the values from the listbox. But the ASP
code shows only the last record. Needs help



HTML

<html>
<head>

<body>
<h2><center>DECEASED DATA SEARCH</center></h2>
<br><br>
<table border='0' align='center'>
<form name='deceasedsocial' id='deceasedsocial' method='POST'
onsubmit="return selectAllOptions()">

<tr>
<td>Enter Social Security Number</td><td><input type='text' name='ssn'
id='ssn'>&nbsp&nbsp<select id="lstSSN" name="lstSSN"></select></td></
tr>
<tr><td><input type="button" value="Add" onclick="return
loadList();"></select>
<input type="button" value="Delete" onclick="return deleteIt();"></
select>
<input type="submit" value="Process"
onClick="this.form.action='ProcessDeceased.asp'";>

</td></tr>
<tr><td><input type="submit" value="Todays Deceased"
onClick="this.form.action='hello.asp'";>
</td></tr>

</table>
</form>
<script language="JavaScript">
var frm = document["deceasedsocial"];
function loadList() {
intCount = frm.lstSSN.length;
frm.lstSSN.options[intCount] = new
Option(frm.ssn.value,frm.ssn.value);

// Get textbox, clear it then focus onto it.
var textbox = document.getElementById('ssn');
textbox.text = "";
textbox.focus();
document.getElementById('ssn').value=""
document.getElementById('ssn').focus();
return true;
}

function deleteIt()
{
for (var i=(frm.lstSSN.options.length-1); i>=0; i--)
{
var o=frm.lstSSN.options;
if (o.selected) {
frm.lstSSN.options = null;
document.getElementById('ssn').focus();
return true;
}
}
return true;
}

function selectAllOptions() {
var ref = document.getElementById('lstSSN');
for(i=0; i<ref.options.length; i++)
ref.options.selected = true;
return true;
}

</script>
</body>




ASP

lstSSN = request.form( "lstSSN")
response.write(lstSSN)
 
R

RobG

Hi: I am trying to pull all the values from the listbox. But the ASP
code shows only the last record. Needs help

I don't understand the point, surely you already know all the values
in the select. But anyhow, below is some help, you'll likely need
more.
HTML

<html>
<head>

<body>

It's always a good idea to start with valid HTML - the W3C validator
is free and quite good:

<h2><center>DECEASED DATA SEARCH</center></h2>
<br><br>
<table border='0' align='center'>
<form name='deceasedsocial' id='deceasedsocial' method='POST'
onsubmit="return selectAllOptions()">

More invalid HTML. A form can't be a child of a table, put the table
inside the form:

<form ...>
<tr>
<td>Enter Social Security Number</td><td><input type='text' name='ssn'
id='ssn'>&nbsp&nbsp<select id="lstSSN" name="lstSSN"></select>

An empty select is invalid, it must have at least one option. If you
want to select and submit more than one option, make it a multiple
select.

<URL: http://www.w3.org/TR/html401/interact/forms.html#edef-SELECT >

tr>
<tr><td><input type="button" value="Add" onclick="return
loadList();"></select>

There is no opening tag for that select closing tag. Input elements
don't have a closing tag.

[...]
</table>
</form>
<script language="JavaScript">

The language attribute is deprecated, remove it. Type is required.
var frm = document["deceasedsocial"];
function loadList() {
intCount = frm.lstSSN.length;

Where is frm defined?

frm.lstSSN.options[intCount] = new
Option(frm.ssn.value,frm.ssn.value);

// Get textbox, clear it then focus onto it.
var textbox = document.getElementById('ssn');
textbox.text = "";

Input elements don't have a text attribute.

textbox.focus();
document.getElementById('ssn').value=""
document.getElementById('ssn').focus();

You can reuse the text box reference, call its focus method once at
the end:

var textbox = document.getElementById('ssn');
textBox.value = '';
textbox.focus();
return true;

}

function deleteIt()
{
for (var i=(frm.lstSSN.options.length-1); i>=0; i--)

Where is frm defined?
{
var o=frm.lstSSN.options;
if (o.selected) {
frm.lstSSN.options = null;
document.getElementById('ssn').focus();
return true;
}
}
return true;

}

function selectAllOptions() {
var ref = document.getElementById('lstSSN');


Change ref to a multiple select here, its appearance may change so you
might need to control that.
 

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

Members online

Forum statistics

Threads
473,744
Messages
2,569,482
Members
44,900
Latest member
Nell636132

Latest Threads

Top