Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Multiple variables in string - what am I missing??

Status
Not open for further replies.

programmher

Programmer
May 25, 2000
235
US
I have a select/drop-down box that allows users to select a value. This value is composed of three variables. My problem is passing all three variables to their corresponding SEPARATE text fields.

I can successfully pass one variable; but nothing happens when I include all the variables in a string. What am I missing?

Below is the string that works and how I am attempting to enhance the same string to include all the variables:

<select name=&quot;change_delivery_name&quot; onChange=&quot;this.form.delivery_name.value=this.value;&quot;>

<select name=&quot;change_delivery_name&quot; onChange=&quot;this.form.delivery_name.value=this.value?this.form.delivery_number.value=this.value;&quot;>

I have also attempted this using an ampersand.
 
why don't you just call a function to set the things you want? Send the function 'this' and operate ddirectly on it:


<script>
function setStuff(obj_select){
obj_select.form.delivery_name.value=this.value;
obj_select.form.delivery_number.value=this.value;
}
</script>

<select name=&quot;change_delivery_name&quot; onChange=&quot;setStuff(this)&quot;>


This way you can do more things, more clearly, and change it for all instances of select you're using at once.;)
b2 - benbiddington@surf4nix.com
 
Sorry I left a this in there:

<script>
function setStuff(obj_select){
obj_select.form.delivery_name.value=obj_select.value;
obj_select.form.delivery_number.value=obj_select.value;
}
</script>

b2 - benbiddington@surf4nix.com
 
b2,

I have attempted to implement your suggestion. I keep getting &quot;obj_select&quot; is undefined whenever I try to select a value. I have tried several variations of your tip; but, to no avail.

I cut and pasted your code - what else could I be missing?
 
<select name=&quot;change_delivery_name&quot; onChange=&quot;setStuff(this);&quot;>
luciddream@subdimension.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top