?
Solved

challenge quesion about save result set

Posted on 2003-03-25
19
Medium Priority
?
131 Views
Last Modified: 2013-12-24
I have one form. I have 3 texbox and one drop down. My drop down two selected. means when u chose the value from the first drop down it should change value in next drop down. and this is onchage event.

I fill up the first three textbox and select the value from the drop down u know my drop down base on the value u select it will display in next drop down. So when i select the value from the first drop down it will refresh the page to get the value in the next drop down at that time i am lossing the value from my text box.

How can save the value in text box once i will come back. when ever i choose the value from the drop down i am lossing the value i type in the textbox... any idea

thanx
0
Comment
Question by:ts20032
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 6
  • 3
  • 3
  • +4
19 Comments
 

Accepted Solution

by:
demarco earned 80 total points
ID: 8202081
This is an often asked for Feature in Coldfusion and are a number of ways of doing what you ask

In fact there are custom tags and fuctions for exactly what you ask


http://www.macromedia.com/v1/developer/taggallery/details.cfm?component_ID=985

http://www.macromedia.com/v1/developer/taggallery/details.cfm?component_ID=936

both by Nate Weiss

And
3 - related selects
<CF_ThreeSelectsRelated>


http://www.macromedia.com/v1/developer/taggallery/details.cfm?component_ID=1004

0
 
LVL 11

Expert Comment

by:hart
ID: 8202324
see its simple.

you can populate the second select box using javascript.

thus the refreshing problem won't occur.

see you query the table get all the records of the first select box.

then you form arrays as per these id's from the related table. (for 2nd select box)

i can write down the code and give, if you give me the options of select box 1 and all the correponding values of select box 2.

its very easy, just put the values down and i will form the code and give.

Though doing this for just 20 points is not worth it.
But i don't mind. Atleast it will help you understand a new way of forming select box options using javascript.

let me know..

Regards
Hart(Harish)
0
 
LVL 17

Expert Comment

by:anandkp
ID: 8202384
hi,

all the above + something rather simpler & much easier to implement - without ne-headache

2 select boxes - use this tag
[No need to worry abt the 3 textboxes - their value will remain as it is]

http://www.macromedia.com/v1/developer/taggallery/details.cfm?Component_ID=985

let me know - if it helps

K'Rgds
Anand
0
Moving data to the cloud? Find out if you’re ready

Before moving to the cloud, it is important to carefully define your db needs, plan for the migration & understand prod. environment. This wp explains how to define what you need from a cloud provider, plan for the migration & what putting a cloud solution into practice entails.

 
LVL 11

Expert Comment

by:hart
ID: 8202398
use demarco' suggestion, it will solve ur hassle :-)

Regards
Hart(harish)
0
 
LVL 17

Expert Comment

by:anandkp
ID: 8202401
oops

guess i didnt see the link in demarco's comment - he has got it for u <CF_TwoSelectsRelated>

i got confused with the text  he mentioned abt 3 tags related so i put up the earlier comment - sorry pls ignore it

K'Rgds
Anand
0
 

Author Comment

by:ts20032
ID: 8202825
My qustion is that My drop down is working ok, I am just lossing my value from the textbox..
Means

<input type="text" name="t1">
<input type="text" name="t2">
my selectbox <select> this is daynamic drop down select the value from first down it will show you value in next drop down</select>

i put the value in first input box
i put the value in second input box
then i select the value from drop down my onchange event refresh the page and display the value in  my next drop down
at that time i am lossing the value from my first input box and second input box.

thanks
0
 

Author Comment

by:ts20032
ID: 8203224
My qustion is that My drop down is working ok, I am just lossing my value from the textbox..
Means

<input type="text" name="t1">
<input type="text" name="t2">
my selectbox <select> this is daynamic drop down select the value from first down it will show you value in next drop down</select>

i put the value in first input box
i put the value in second input box
then i select the value from drop down my onchange event refresh the page and display the value in  my next drop down
at that time i am lossing the value from my first input box and second input box.

thanks
0
 

Author Comment

by:ts20032
ID: 8206194
Hi this link doesn't work  i did try to download that but not working. can u send me the code thanks
0
 
LVL 14

Expert Comment

by:Renante Entera
ID: 8207519
Hello there! I have here my simple example. Try to have this code.

<html>
<head>
<script language=javascript>
var m_arr = new Array();
m_arr[0] = "Verzekeraar|Tussenpersoon|Bank-verzekeraar";
m_arr[1] = "Rijksoverheid|Provinciale overheid";
m_arr[2] = "Landelijke politiek|provinciale politiek"
m_arr[3] = "Landelijk dagblad|blah";


var m2_arr = new Array();
m2_arr [0] = "So1mething|So1mething|So1mething";
m2_arr [1] = "So2mething|So1mething|So1mething";
m2_arr [2] = "So3mething|So1mething|So1mething";
m2_arr [3] = "So4mething|So1mething|So1mething";

var oArrays = [m_arr, m2_arr];

function sh(obj, o_objn, Index)
{
   f = obj.form;
   other_obj = f[o_objn];
s = oArrays[Index][obj.selectedIndex].split("|");
if(document.all) other_obj.options.length = 0
for(i=0;i<s.length;i++)
{
if(document.all) other_obj[i] = new Option();
other_obj[i].value = s[i]
other_obj[i].text= s[i];
}
}
</script>
</head>
<body onload="sh(document.forms[0]['firstselect'], 'otherselect', 0)">
<form>
  <p>
    <input type="text" name="textfield">
    <input type="text" name="textfield2">
    <input type="text" name="textfield3">
  </p>
  <p>
    <select onChange="sh(this, 'otherselect', 0)" name='firstselect'>
      <option>Financieel-economisch</option>
      <option>Overheid</option>
      <option>Politiek</option>
      <option>Media</option>
    </select>
    <select name="otherselect" onChange="sh(this, 'otherselect2', 1)" >
      <option>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</option>
      <option></option>
      <option></option>
      <option></option>
    </select>
    <select name="otherselect2">
      <option>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</option>
      <option></option>
      <option></option>
      <option></option>
    </select>
  </p>
</form>
</body>
</html>

I hope this will give you an idea regarding your problem.

No need to refresh the page but you have to focus only on the selected menu.

GOODLUCK!
0
 
LVL 14

Expert Comment

by:Renante Entera
ID: 8207548
Oooopss....

By the way, I misinterpret your question...

Take this other code, this is what you are looking for:

<html>
<head>
<script language=javascript>
var m_arr = new Array();
m_arr[0] = "Value1";
m_arr[1] = "Value2";
m_arr[2] = "Value3" ;
m_arr[3] = "Value4";

var oArrays = [m_arr];

function sh(obj, o_objn, Index)
{
   f = obj.form;
   other_obj = f[o_objn];
s = oArrays[Index][obj.selectedIndex].split("|");
if(document.all) other_obj.options.length = 0
for(i=0;i<s.length;i++)
{
if(document.all) other_obj[i] = new Option();
other_obj[i].value = s[i]
other_obj[i].text= s[i];
}
}
</script>
</head>
<body onload="sh(document.forms[0]['firstselect'], 'otherselect', 0)">
<form>
  <p>
    <input type="text" name="textfield">
    <input type="text" name="textfield2">
    <input type="text" name="textfield3">
  </p>
  <p>
    <select onChange="sh(this, 'otherselect', 0)" name='firstselect'>
      <option>Value1</option>
      <option>Value2</option>
      <option>Value3</option>
      <option>Value4</option>
    </select>
    <select name="otherselect" onChange="sh(this, 'otherselect2', 1)" >
      <option>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</option>
      <option></option>
      <option></option>
      <option></option>
    </select>
  </p>
</form>
</body>
</html>

Best wishes...
0
 
LVL 14

Expert Comment

by:Renante Entera
ID: 8207564
Am I right this time?

Instead of this one:

<select name="otherselect" onChange="sh this, 'otherselect2', 1)" >
<option>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</option>
  <option></option>
  <option></option>
  <option></option>
</select>

You may have it this way:

<select name="otherselect" onChange="sh this, 'otherselect2', 1)" ></select>

The options are just optional. OK
0
 
LVL 11

Expert Comment

by:hart
ID: 8208304
see i think you are submiting the page when you are changing the first select box.

The above solutions do not submit the page.

but if you want to stick to your code then all you have to do is i think you are submitting your form for getting the id of the first select box so to retain the values do this


for eg:
<html>
<head>
<title>select me</title>
</head>
<body>
<form name="frm">
<input type="text" name="text1" <cfif isdefined('text1')>value="#text1#"<cfelse>value=""</cfif>>
<input type="text" name="text2" <cfif isdefined('text2')>value="#text2#"<cfelse>value=""</cfif>>
<input type="text" name="text1" <cfif isdefined('text3')>value="#text3#"<cfelse>value=""</cfif>>
</form>
</body>
</html>
0
 
LVL 10

Expert Comment

by:substand
ID: 8215994
I've answered a couple of questions like this before, and I would sugguest you use one of the above answers.  I didn't look at them, but I assume they work.

they are the same things or similar to what I would sugguest.  

if you can't get them to work however, here is a very ugly way to do it:

say you have 2 files, form1.cfm and form2.cfm.

both files look the same. but:

<!--- form1.cfm is as follows --->
<cfquery name="yourqueryname" datasource="yourDS">
select blah from tableblah where blahcolumn=#blahblah#;
</cfquery>
<form action="form2.cfm" method="post" name="form">
<select name="sel1" onchange="form.submit();">
<cfloop query="yourqueryname">
<option value="#valuefromquery#">#labelfromquery#
</cfloop>
</select>

<select name="sel1" onchange="form.submit();">
<options are nothing for now>
</select>

<all your other form fields>

</form>
<!--- end form1.cfm ---->


<!--- form2.cfm is as follows --->
<cfquery name="yourqueryname" datasource="yourDS">
select blah from tableblah where blahcolumn=#blahblah#;
</cfquery>
<cfquery name="yourqueryname2" datasource="yourDS">
select whatever you need where blah=#form.sel1#;
</cfquery>

<form action="form2.cfm" method="post" name="form">
<select name="sel1" onchange="form.submit();">
<cfloop query="yourqueryname">
<option value="#valuefromquery#" <cfif valuefromquery is form.sel1>selected</cfif>>#labelfromquery#
</cfloop>

<select name="sel2">
<cfloop query="yourqueryname2">
<option value="#valuefromquery2#" >#labelfromquery2#
</cfloop>

<all your other form2 fields>
</form>

<!--- end form2.cfm --->
0
 

Author Comment

by:ts20032
ID: 8230451
OK i am using twoselected tag but it not allow multiple
select in my second drop down,

Means i select one value from first drop down and it will display the result in next drop down. In next drop down i would like to select two values.

We generally press the ctrl and mouce to select multiple value. but it is not allowing me to select. only allow one
is there any proerty which allow to select multiple one
thanks
0
 
LVL 17

Expert Comment

by:anandkp
ID: 8236414
<select name="x" size="5" Multiple>

</select>

K'Rgds
Anand
0
 
LVL 35

Expert Comment

by:mrichmon
ID: 10940883
No comment has been added lately, so it's time to clean up this question.
I will leave the following recommendation in the Cleanup topic area:

Accept demarco

Please leave any comments here within the next four days.

mrichmon
EE Cleanup Volunteer
0

Featured Post

Want to be a Web Developer? Get Certified Today!

Enroll in the Certified Web Development Professional course package to learn HTML, Javascript, and PHP. Build a solid foundation to work toward your dream job!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This is a guide to setting up a new WHM/cPanel Server to be used for web hosting accounts. It is intended for web hosting company administrators and dedicated server owners. For under $99 per month (considering normal rate of Big Data Cetnters like …
Have you ever sent email via ColdFusion and thought of tracking this mail to capture the exact date and time when the message was opened ?  If yes, then this article is for you ! First we need a table user_email with columns user_id , email , sub…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…
Suggested Courses

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question