Forum Moderators: open

Message Too Old, No Replies

form validations

         

javakid

2:40 pm on Jul 14, 2003 (gmt 0)

10+ Year Member



Hi there!
I am newkid of this block and just start learning HTML, javascript and ASP. I need the help in one case.
I have two forms on a single ASP page.The two forms having one list boxes each. For instance, take one listbox as a category and other as sortby. Both of them contain few entries like business,general......( in category listbox) and Name,Company,fname, lname(in sortby list box) respectively.

I wish to refresh the same page again and again. I mean to say if the user select business categories form category listbox then the later part of the page of the content is refresh and the upper page contain the same as mentioned above except firstlist box heading change to " BUSINESS" .

Is it possible? if yes then how? Can anyone provide the code for the same.

Thanks in advance!

hakre

6:35 pm on Jul 14, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



hi javakid, welcome to webmasterworld [webmasterworld.com].

it is possible to do so with javascript, but the script depends on a lot, what you want to do.

first of all, i created a form with 2 listboxes and filled the first one with the categorie items. then wrote the script which fills the list with the appropriate data for each category (from an array defined first) and voila - done:


<html>
<head><title>test</title>

<script type="text/javascript">
<!--

// define list data
data = new Array();
data[0] = new Array('Dog','Cat','Bird');
data[1] = new Array('Cake','Bread','Croissant');
data[2] = new Array('Perl','PHP','ASP','CFML','VBS');

function list_fill(index) {
// check input
if (index==-1) return;

// listbox reference
listbox = document.test.entries;

// clear the list
m = listbox.options.length;
if (m>1) for (var i=m; i>0; --i) listbox.options[i] = null;

// fill the list
listbox.options.length = data[index].length;
for (var i=0; i < data[index].length; ++i) listbox.options[i].text = data[index][i];

}
//-->
</script>

</head><body>

<form name="test" action="">

<table><tr><td>

<!-- first list -->
<select name="cat" size="4" onclick="list_fill(document.test.cat.selectedIndex);">
<option>Animals</option>
<option>Backwaren</option>
<option>Script Languages</option>
</select>

</td><td>&nbsp;&nbsp;&nbsp;</td><td>

<!-- second list -->
<select name="entries" size="4" >
<option>- select a categorie on the left first -</option>
</select>

</td></tr></table>

<br />

<input type="submit" />

</form>

</body></html>

hope this helps
- hakre

javakid

3:47 am on Jul 15, 2003 (gmt 0)

10+ Year Member



Thanks for your reply. That code definetly help me but not in this case. As this was not what i exactly seeking.You suggest the solutions because either you intrept the things in a wrong way OR i wasn't able to expain myself problem clearly. Taking your code as a example..

If anyone select categorie item ANIMAL from the list1 box then the later part of the page display something like this..

cat_item Quantity
dog 10
Bird 15
cat 20

And so for the other dropdown list box. Assume that the quantity records came from the table name cat_quant.

Hope,this time the pciture is more clear for you.

Thanks for your anticipations.