Snitz Forums 2000
Snitz Forums 2000
Home | Profile | Register | Active Topics | Members | Search | FAQ
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 Community Forums
 Code Support: ASP (Non-Forum Related)
 refresh page????
 New Topic  Topic Locked
 Printer Friendly
Next Page
Author Previous Topic Topic Next Topic
Page: of 2

quince
Junior Member

Canada
103 Posts

Posted - 04 January 2005 :  12:43:38  Show Profile
hello everyone ... this is my first post ... so i wish if you could help me in my problem....

i am doing a drop down list for example list of countries... when i choose one i want it to refresh the page and add new label as another drop down list or input type text and so on till all the information is given then when i submit i want all the information to stored in a databse ....
i know how to store the data in the database, i only want how to refresh the page depending on the value it is choosen in the previous drop down list....

and one more question i know that i am asking too much but i want to know "if i could choose in a page an item which has a price and it is hyperlinked to another page which is a form and when i fill it and submit it i want the name of this item which is not included in the form and also the price ... my question is could i do it or not ? and if i can will you show me how .... as i know i might put the name and the price of this item in a hidden input and then when the form is submitted i send it to the database .. will you answer me my questions please .. and thank you all ...

Edited by - quince on 04 January 2005 13:28:42

Da_Stimulator
DEV Team Forum Moderator

USA
3373 Posts

Posted - 04 January 2005 :  13:14:48  Show Profile  Send Da_Stimulator an AOL message  Send Da_Stimulator a Yahoo! Message
I can't help you out with the first part, as I'm no good with javascript. Perhaps davio could help you out with that.

As for the displaying data on the second page without much input fromt he first page...

You could do this several ways.

If the information is in a database, you could retrieve it from the database based on the information you have.

If not, you could do a "Select Case" on the page recieving the form input to decide which data to show.


strItem = request.form("item_name")
Select Case strItem
  Case "item 1"
     '## Show what info you want for this item
  Case "item 2"
     '## Show what info you want for this item
  Case else
     '## invalid form input? show an error message
End Select


Something like that

-Stim
Go to Top of Page

quince
Junior Member

Canada
103 Posts

Posted - 04 January 2005 :  13:32:42  Show Profile
thanks Da stimulator ...
now after i retrieve it from the database how could i send it to the database again in another table and with new data which the user is gonna fill in the form...
Go to Top of Page

Shaggy
Support Moderator

Ireland
6780 Posts

Posted - 04 January 2005 :  17:01:03  Show Profile
If nobody else replies to your first question before tomorrow morning GMT, I'll lash a couple of examples together for you; head's all floaty light at the mo' - can't think straight. If you want to get a headstart and can make any sense of me code, have a look at this registration page; I've done something similar when you change the year or month under date of birth to display the correct number of days for that month.


Search is your friend
“I was having a mildly paranoid day, mostly due to the
fact that the mad priest lady from over the river had
taken to nailing weasels to my front door again.”
Go to Top of Page

Shaggy
Support Moderator

Ireland
6780 Posts

Posted - 05 January 2005 :  05:02:53  Show Profile
[black]OK, here goes - bit of a simplified version this as I'm working under a couple of assumptions. The primary assumption is that the values of the options in the "parent" select (the one that will control the other) are incrementing numbers.

i.e. <option value="0">Option 0</option><option value="1">Option 1</option> ...

If not, we're going to have to add an if statement to the function below so let me know (probably handiest if you post the HTML for the select)
function changeselect(va,el){
 var arrValue,arrDisplay;
 arrValue=new Array();
 arrDisplay=new Array();
 arrValue[0]=[0,1,2];
 arrDisplay[0]=["one","two","three"];
 if(va!=""){
  document.getElementById(el).options.length=0;
  for(var x=0;x<arrValue[va].length+1;x++){
   document.getElementById(el)[x]=new Option(arrDisplay[va][x],arrValue[va][x]);
  }
 }
}
The two lines highlighted in green above are the ones you'll need to edit and duplicate for each list of options you want for the "child" select (the one that's going to be changing) where arrValues will be used to pouplate the value attribute of each option and arrDisplay will be what is displayed to the user in the drop down.

Now we just need to call the function so add the following handler to the opening tag of your parent select
onchange="changeselect(this.options[this.selectedIndex].value,"ID")
where ID is the id of the child element.

Apologies if the above seems a bit all over the place, didn't get much sleep last night

Search is your friend
“I was having a mildly paranoid day, mostly due to the
fact that the mad priest lady from over the river had
taken to nailing weasels to my front door again.”
Go to Top of Page

quince
Junior Member

Canada
103 Posts

Posted - 05 January 2005 :  05:41:38  Show Profile
shaggy sorry for bothering you but could you do send me an example by two drop lists on my email so i could see exactly what did u do cause i am trying to do it but it isn't working ... please shaggy it is important to know this cause i am gonna use it in my senior project .... and thanks a lot for you help shaggy....
my email is qb_103@hotmail.com
Go to Top of Page

Shaggy
Support Moderator

Ireland
6780 Posts

Posted - 05 January 2005 :  05:52:13  Show Profile
When you say it's not working, what exactly is going wrong? Are you receiving any Javascript errors? The only example I have online is the one I linked to above. If you post links to *.txt copies of the files in question, I'll have a look at them.


Search is your friend
“I was having a mildly paranoid day, mostly due to the
fact that the mad priest lady from over the river had
taken to nailing weasels to my front door again.”
Go to Top of Page

quince
Junior Member

Canada
103 Posts

Posted - 05 January 2005 :  06:02:47  Show Profile
shaggy the codes that u post them where shell i put them exactly ... ?
Go to Top of Page

Shaggy
Support Moderator

Ireland
6780 Posts

Posted - 05 January 2005 :  06:20:27  Show Profile
The first block of code should go in your javascript file or, if you don't have one, in the head of the HTML of the page in question. If you're putting them in the head then you'll need to put <script type="text/javascript"> above the code I posted and </script> below it.

The second line, as I said, should go in the opening select tag of the first drop down and should read: onchange="changeselect(this.options[this.selectedIndex].value,"ID");" not what I posted above.


Search is your friend
“I was having a mildly paranoid day, mostly due to the
fact that the mad priest lady from over the river had
taken to nailing weasels to my front door again.”

Edited by - Shaggy on 05 January 2005 06:21:00
Go to Top of Page

quince
Junior Member

Canada
103 Posts

Posted - 05 January 2005 :  06:36:59  Show Profile
hello shaggy here is the code will you check it for me and tell me if i am right or wrong


<script type="text/javascript">
function changeselect(va,el){
 var arrValue,arrDisplay;
 arrValue=new Array();
 arrDisplay=new Array();
 <FONT color=green>arrValue[0]=[0,1,2];
 arrDisplay[0]=["one","two","three"];</FONT>
 if(va!=""){
  document.getElementById(el).options.length=0;
  for(var x=0;x<arrValue[va].length+1;x++){
   document.getElementById(el)[x]=new Option(arrDisplay[va][x],arrValue[va][x]);
  }
 }
}
</script>
<html>
<select size="1" name="D0" onchange="changeselect(this.options[this.selectedIndex].value,"ID");">
<option value="0">country</option>
.
<option value="1">ckk</option>
<option value="2"uss</option>
</select>
<p>
<select size="1" name="D1">


 

 function changeselect(va,el){
 var arrValue,arrDisplay;
 arrValue=new Array();
 arrDisplay=new Array();
 arrValue[0]=[0,1,2];
 arrDisplay[0]=["one","two","three"];
 if(va!=""){
  document.getElementById(el).options.length=0;
  for(var x=0;x<arrValue[va].length+1;x++){
   document.getElementById(el)[x]=new Option(arrDisplay[va][x],arrValue[va][x]);
  }
 }
}

<option value="0">uk</option>
<option value="1">usa</option>
<option value="2">canada</option>
</select></p>
</html>


Go to Top of Page

Shaggy
Support Moderator

Ireland
6780 Posts

Posted - 05 January 2005 :  06:45:38  Show Profile
Should look something like this:
<html>
<head>
<script type="text/javascript">
function changeselect(va,el){
 var arrValue,arrDisplay;
 arrValue=new Array();
 arrDisplay=new Array();
 arrValue[0]=[0,1,2];
 arrDisplay[0]=["one","two","three"];
 if(va!=""){
  document.getElementById(el).options.length=0;
  for(var x=0;x<arrValue[va].length+1;x++){
   document.getElementById(el)[x]=new Option(arrDisplay[va][x],arrValue[va][x]);
  }
 }
}
</script>
</head>
<body>
<select size="1" name="D0" onchange="changeselect(this.options[this.selectedIndex].value,"D1");">
<option value="0">country</option>
<option value="1">ckk</option>
<option value="2"uss</option>
</select>
<p>
<select size="1" name="D1" id="D1">
<option value="0">uk</option>
<option value="1">usa</option>
<option value="2">canada</option>
</select></p>
</body></html>

Search is your friend
“I was having a mildly paranoid day, mostly due to the
fact that the mad priest lady from over the river had
taken to nailing weasels to my front door again.”
Go to Top of Page

quince
Junior Member

Canada
103 Posts

Posted - 05 January 2005 :  10:32:37  Show Profile
hi shaggy i tried to do this but it is not working.... may i say where is the code that it will select what i want if i choose one of the countries?????
Go to Top of Page

Shaggy
Support Moderator

Ireland
6780 Posts

Posted - 05 January 2005 :  10:58:02  Show Profile
What do you mean by "it is not working"? Can't do much debugging without error messages.

As I said in my original post, to define the values for D1 when D0 is changed, you will need to change the values in the arrValue[0] & arrDisplay[0] arrays and you'll also need to duplicate them for each additional country, incrementing 0 each time. For example:
// values for 'country'
arrValue[0]=[0,1,2]
// dropdown for 'country'
arrDisplay[0]["one","two","three"]
// values for 'ckk'
arrValue[1]=[3,4,5]
// dropdown for 'ckk'
arrDisplay[1]=["four","five","six"]
// values for 'uss'
arrValue[2]=[6,7,8]
// dropdown for 'uss'
arrDisplay[2]=["seven","eight","nine"]

Search is your friend
“I was having a mildly paranoid day, mostly due to the
fact that the mad priest lady from over the river had
taken to nailing weasels to my front door again.”
Go to Top of Page

quince
Junior Member

Canada
103 Posts

Posted - 05 January 2005 :  11:26:37  Show Profile
okay i will show you what i have done shaggy ...

<script type="javascript">
function changeselect(va,el){
var arrValue,arrDisplay;
arrValue=new Array();
arrDisplay=new Array();
arrValue[0]=[0,1,2];
arrDisplay[0]=["zero","one","two"];
arrValue[1]=[3,4,5];
arrDisplay[1]=["three","four","five"];
arrValue[2]=[6,7,8];
arrDisplay[2]=["six","seven","eight"];
if(va!=""){
document.getElementById(el).options.length=0;
for(var x=0;x<arrValue[va].length+1;x++){
document.getElementById(el)[x]=new Option(arrDisplay[va][x],arrValue[va][x]);
}
}
}
</script>

so is this how i duplicate it or not ....
Go to Top of Page

Shaggy
Support Moderator

Ireland
6780 Posts

Posted - 05 January 2005 :  11:30:18  Show Profile
Exactly it All you got to do now is change the variables in each array to suit your needs.


Search is your friend
“I was having a mildly paranoid day, mostly due to the
fact that the mad priest lady from over the river had
taken to nailing weasels to my front door again.”
Go to Top of Page

quince
Junior Member

Canada
103 Posts

Posted - 05 January 2005 :  11:53:14  Show Profile
shaggy i am back ... but it didn't select anything.... for example i choose a country it show me all the list but it didn't select only what i want ... shell i show you the whole code ???
Go to Top of Page
Page: of 2 Previous Topic Topic Next Topic  
Next Page
 New Topic  Topic Locked
 Printer Friendly
Jump To:
Snitz Forums 2000 © 2000-2021 Snitz™ Communications Go To Top Of Page
This page was generated in 0.48 seconds. Powered By: Snitz Forums 2000 Version 3.4.07