?
Solved

Creating a text string from 3 drop down boxes (hopefully pretty easy)

Posted on 2012-03-16
5
Medium Priority
?
234 Views
Last Modified: 2012-03-19
Hi All,

Im pretty new to creating webpages so please be gentle :)

I need a piece of code, php or even a name of an element to create a string from 3 drop down boxes, box1, box2 and box3

Heres an example

Box1 - ford = for, volkswagen = vol, porsche = por
Box2 - red = red, yellow = yel, blue = blu
Box3 - long = lon, medium = med, short = sho

Hence, selecting Volkswagen in box1, yellow in box2 and medium in box3 would produce the string (possibly in a box below the dropdowns) volyelmed (i.e. like a trucated product code)

Hope this makes sense, any help much appreciated.
0
Comment
Question by:johnsit
[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
  • 2
  • 2
5 Comments
 
LVL 1

Expert Comment

by:ScottNL1
ID: 37729553
You are submitting a form?

is so, the easy way is:

$string = $_POST['box1']." ".$_POST['box2']." ".$_POST['box3'];

echo $string;
0
 

Author Comment

by:johnsit
ID: 37729602
Thanks for the reply,

No, I am not, I simply want to display the string underneath the drop downs on the same page.
Basically it is to give a user a product code by selecting from a drop down.
0
 
LVL 1

Accepted Solution

by:
ScottNL1 earned 2000 total points
ID: 37730178
try this

<script>


function product_code(){
  var box1 = document.getElementById("box1");
  var box2 = document.getElementById("box2");
  var box3 = document.getElementById("box3");
  document.getElementById("code").innerHTML = box1.options[box1.selectedIndex].value + box2.options[box2.selectedIndex].value + box3.options[box3.selectedIndex].value;

  ;

}


</script>


Car:
<select id="box1" onchange="product_code();">
       <option value="for">ford</option>
       <option value="vol">volkswagen</option>
       <option value="por">porsche</option>
</select>
<br />
Color:
<select id="box2" onchange="product_code();">
       <option value="red">red</option>
       <option value="yel">yellow</option>
       <option value="blu">blue</option>
</select>
<br />
Type:
<select id="box3" onchange="product_code();">
       <option value="lon">long</option>
       <option value="med">medium</option>
       <option value="sho">short</option>
</select>
<br /><br />

<div id="code" style="color:red;font-size:1.2em"></div>

Open in new window

0
 
LVL 53

Expert Comment

by:COBOLdinosaur
ID: 37730189
Post a link to the page, or the HTML and we should be able to give you some code.


Cd&
0
 

Author Comment

by:johnsit
ID: 37736697
Thanks very much scottNL1, exactly what I was after!
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

When crafting your “Why Us” page, there are a plethora of pitfalls to avoid. Follow these five tips, and you’ll be well on your way to creating an effective page.
When it comes to security, close monitoring is a must. According to WhiteHat Security annual report, a substantial number of all web applications are vulnerable always. Monitis offers a new product - fully-featured Website security monitoring and pr…
Any person in technology especially those working for big companies should at least know about the basics of web accessibility. Believe it or not there are even laws in place that require businesses to provide such means for the disabled and aging p…
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…
Suggested Courses

649 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