i take the code of java script for drop down list but i dont know how can i take the value to the search page .asp
and how can i submit to this page in java script
thanks...
ShrineDesigns
12-14-2002, 08:49 PM
you mean a navigatoin menu ???
roby
12-15-2002, 09:34 AM
hi,Dave
the code is here just copy it and change it to take the value from drop down box and send the value to search.asp
and add it to the forum OK...
<!-- TWO STEPS TO INSTALL AUTO DROP DOWN:
1. Copy the coding into the HEAD of your HTML document
2. Add the last code into the BODY of your HTML document -->
<!-- STEP ONE: Paste this code into the HEAD of your HTML document -->
<!-- This script and many more are available free online at -->
<!-- The JavaScript Source!! http://javascript.internet.com -->
<!-- Begin
team = new Array(
new Array(
new Array("Saku Koivu", 39482304),
new Array("Martin Rucinsky", 34802389),
new Array("Jeff Hackett", 39823498),
new Array("Sheldon Sourray", 87587343),
new Array("Richard Zednik", 68798735),
new Array("Brian Savage", 98098509),
new Array("Stephane Robidas", 49490583),
new Array("Patrice Brisebois", 32898334),
new Array("Oleg Petrov", 92340934),
new Array("Chad Kilger", 34923409),
new Array("Benoit Brunet", 59384093),
new Array("Jan Bulis", 83948023),
new Array("Patrick Traverse", 41239812),
new Array("Jose Theodore", 98402398),
new Array("Craig Darby", 82393434),
new Array("Patric Poulin", 34290348),
new Array("Karl Dykhuis", 89092834)
),
new Array(
new Array("Mario Lemieux", 23840238),
new Array("Jaromir Jagr", 92390484),
new Array("Robert Lang", 29048203),
new Array("Alexei Kovalev", 94098230),
new Array("Jean-Sebastien Aubin", 39234923),
new Array("Kevin Stevens", 29345423)
),
null,
new Array(
new Array("Alexei Yashin", 20394802),
new Array("Daniel Alfredson", 34982039),
new Array("Marian Hossa", 92348902),
new Array("Patrick Lalime", 98203894),
new Array("Radek Bonk", 98234902)
)
);
function fillSelectFromArray(selectCtrl, itemArray, goodPrompt, badPrompt, defaultItem) {
var i, j;
var prompt;
// empty existing items
for (i = selectCtrl.options.length; i >= 0; i--) {
selectCtrl.options[i] = null;
}
prompt = (itemArray != null) ? goodPrompt : badPrompt;
if (prompt == null) {
j = 0;
}
else {
selectCtrl.options[0] = new Option(prompt);
j = 1;
}
if (itemArray != null) {
// add new items
for (i = 0; i < itemArray.length; i++) {
selectCtrl.options[j] = new Option(itemArray[i][0]);
if (itemArray[i][1] != null) {
selectCtrl.options[j].value = itemArray[i][1];
}
j++;
}
// select first item (prompt) for sub list
selectCtrl.options[0].selected = true;
}
}
// End -->
</script>
</HEAD>
<!-- STEP TWO: Copy this code into the BODY of your HTML document -->
<!-- This script and many more are available free online at -->
<!-- The JavaScript Source!! http://javascript.internet.com -->
<!-- Begin
team = new Array(
new Array(
new Array("Saku Koivu", 39482304),
new Array("Martin Rucinsky", 34802389),
new Array("Jeff Hackett", 39823498),
new Array("Sheldon Sourray", 87587343),
new Array("Richard Zednik", 68798735),
new Array("Brian Savage", 98098509),
new Array("Stephane Robidas", 49490583),
new Array("Patrice Brisebois", 32898334),
new Array("Oleg Petrov", 92340934),
new Array("Chad Kilger", 34923409),
new Array("Benoit Brunet", 59384093),
new Array("Jan Bulis", 83948023),
new Array("Patrick Traverse", 41239812),
new Array("Jose Theodore", 98402398),
new Array("Craig Darby", 82393434),
new Array("Patric Poulin", 34290348),
new Array("Karl Dykhuis", 89092834)
),
new Array(
new Array("Mario Lemieux", 23840238),
new Array("Jaromir Jagr", 92390484),
new Array("Robert Lang", 29048203),
new Array("Alexei Kovalev", 94098230),
new Array("Jean-Sebastien Aubin", 39234923),
new Array("Kevin Stevens", 29345423)
),
null,
new Array(
new Array("Alexei Yashin", 20394802),
new Array("Daniel Alfredson", 34982039),
new Array("Marian Hossa", 92348902),
new Array("Patrick Lalime", 98203894),
new Array("Radek Bonk", 98234902)
)
);
function fillSelectFromArray(selectCtrl, itemArray, goodPrompt, badPrompt, defaultItem) {
var i, j;
var prompt;
// empty existing items
for (i = selectCtrl.options.length; i >= 0; i--) {
selectCtrl.options[i] = null;
}
prompt = (itemArray != null) ? goodPrompt : badPrompt;
if (prompt == null) {
j = 0;
}
else {
selectCtrl.options[0] = new Option(prompt);
j = 1;
}
if (itemArray != null) {
// add new items
for (i = 0; i < itemArray.length; i++) {
selectCtrl.options[j] = new Option(itemArray[i][0]);
if (itemArray[i][1] != null) {
selectCtrl.options[j].value = itemArray[i][1];
}
j++;
}
// select first item (prompt) for sub list
selectCtrl.options[0].selected = true;
}
}
// End -->
</script>
</HEAD>
<!-- STEP TWO: Copy this code into the BODY of your HTML document -->
OK i am just want tha code to send the data from page java script to page ASP just like that, and i want you to explain
the
var sel = document.formName.selectName;
//what is the selectName...is it const or i can change it
var str = sel.options[sel.selectedIndex].value;
//what is the selectedIndex...is it const or i can change it
self.location.href = "yourpage.asp?str=" + str;
roby
roby
12-17-2002, 05:17 PM
hi, dave
i want you to know some things like
i just want to use java script in my web site and i dont know the java script but i know the ASP and use the java script to solve some problem in my page the ASP not available to use like change the data in the page direct like the code that i write it yesterday ok finaly i hope you to solve my problem completly just copy the code and make change to run Succesfully and write it here pleeeeeeeez...
roby
khalidali63
12-18-2002, 01:12 AM
Hello Roby,
There is more that needs to be done in this code, but as dave said you should reference the tutorials,
1. Copy the code below in its entirety.
2.Create a new empty HTML Page
3. Paste the code below in its entirety in this new html page.
The only thing that you need to do is from the line below
<!-- This script and many more are available free online at -->
<!-- The JavaScript Source!! http://javascript.internet.com -->
<!-- Customised for Roby by Khalid Ali[k_aali@shaw.ca]-->
var itemsArray = new Array();
<!-- Begin
team = new Array(
new Array(
new Array("Saku Koivu", 39482304),
new Array("Martin Rucinsky", 34802389),
new Array("Jeff Hackett", 39823498),
new Array("Sheldon Sourray", 87587343),
new Array("Richard Zednik", 68798735),
new Array("Brian Savage", 98098509),
new Array("Stephane Robidas", 49490583),
new Array("Patrice Brisebois", 32898334),
new Array("Oleg Petrov", 92340934),
new Array("Chad Kilger", 34923409),
new Array("Benoit Brunet", 59384093),
new Array("Jan Bulis", 83948023),
new Array("Patrick Traverse", 41239812),
new Array("Jose Theodore", 98402398),
new Array("Craig Darby", 82393434),
new Array("Patric Poulin", 34290348),
new Array("Karl Dykhuis", 89092834)
),
new Array(
new Array("Mario Lemieux", 23840238),
new Array("Jaromir Jagr", 92390484),
new Array("Robert Lang", 29048203),
new Array("Alexei Kovalev", 94098230),
new Array("Jean-Sebastien Aubin", 39234923),
new Array("Kevin Stevens", 29345423)
),
null,
new Array(
new Array("Alexei Yashin", 20394802),
new Array("Daniel Alfredson", 34982039),
new Array("Marian Hossa", 92348902),
new Array("Patrick Lalime", 98203894),
new Array("Radek Bonk", 98234902)
)
);
teamNames = new Array();
teamNames[0] = "null";
teamNames[1] = "Montreal Canadiens";
teamNames[2] = "Pittsburg Penguins";
teamNames[3] = "Toronto Maple Leafs";
teamNames[4] = "Ottawa Senators";
teamNames[5] = "";
var tn = "";
function teamSelected(param){
tn = param;
}
function fillSelectFromArray(selectCtrl, itemArray, goodPrompt, badPrompt, defaultItem) {
var i, j;
var prompt;
// empty existing items
for (i = selectCtrl.options.length; i >= 0; i--) {
selectCtrl.options[i] = null;
}
prompt = (itemArray != null) ? goodPrompt : badPrompt;
if (prompt == null) {
j = 0;
}
else {
selectCtrl.options[0] = new Option(prompt);
j = 1;
}
if (itemArray != null) {
// add new items
for (i = 0; i < itemArray.length; i++) {
selectCtrl.options[j] = new Option(itemArray[i][0]);
if (itemArray[i][1] != null) {itemsArray = itemArray;
selectCtrl.options[j].value = itemArray[i][1];
}
j++;
}
// select first item (prompt) for sub list
selectCtrl.options[0].selected = true;
}
}
// End -->
function playerSelected(player){
var teamname = teamNames[tn];
var playername = itemsArray[player][0];
alert("Team = "+teamname+", player = "+playername)
self.location.href = "ASPReceiverPage.html?team="+teamname+"&playername="+playername;
}
</script>
</HEAD>
<!-- STEP TWO: Copy this code into the BODY of your HTML document -->
thanks for help and i have a small problem again
that is (if i select any team then press to refresh the names of player are deleted i don't konw why )
roby
khalidali63
12-19-2002, 09:04 AM
Hello Roby,
Here is what happens when you select a team,
in the function "playerSelected" take a loo at the line below.
You see when u select something value,it tries to pass those values to the page listed in this line which is
"ASPReceiverPage.html"
You are suppose to replace this pages name with your ASP recieving page or the ASP page where you want to send this information to.
Khalid
roby
12-19-2002, 10:30 AM
hi, khalid
ok the problem is solved i saved the page as ASP page and the problem is solved but if i click back the problem is stay
the player is moved if you have answer write it ok... bye
roby
khalidali63
12-19-2002, 11:15 AM
Hello Roby,
What happens when you click back, it reloads,and when it reloads it refreshes the selection lists,and when it refreshes the list there is nothing that is selected.
You will have re-select a team at this point..
have fun..
Khalid
roby
12-19-2002, 04:37 PM
hi, khalid
thank you very much
roby
webdeveloper.com
Copyright Internet.com Inc., All Rights Reserved.