i have these 2 selections
Code:

<select id="rooms" name="rooms">
  <option>Please Choose</option>
  <option value="1" >1</option>
  <option value="2" >2</option>
  <option value="3" >3</option>
  <option value="4" >4</option>
   </select>

      <select id="type" name="type">

  <option>Please Choose</option>
  <option>Single - 50£</option>
  <option>Double - 60£</option>
  <option>Luxury double - 70£</option>
  </select>

i would like to give these values
single:50
double:60
luxury double:70
1)how can i do that?
2)if i choose for example single room and number of rooms 2 how can i have the result 100?

Thank you

Recommended Answers

All 2 Replies

You need to put the value attribute at the second option list of options like the first:

<select id="type" name="type">

<option>Please Choose</option>
<option value="50">Single - 50£</option>
<option value="60">Double - 60£</option>
<option value="70">Luxury double - 70£</option>
</select>

Then submit the form to another page and take from the request the values and multiply them. That will require java

Or if you want it to happen at the client you can use javascript to take their values.

But my guess is that you want the first choice

try this example, but in javascript:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
<script type="text/javascript">
function calculation()
{
   var total=0;
   total=(document.getElementById('rooms').value)*(document.getElementById('type').value);
   document.getElementById('diaplay_total').innerHTML="total: "+total+"£";
}
</script>
</head>

<body onload="calculation();">
<form name="test" action="">

    <select id="rooms" name="rooms" onchange="calculation();">
   <option value="1" >1</option>
  <option value="2" >2</option>
  <option value="3" >3</option>
  <option value="4" >4</option>
   </select>
<br /><br />
      <select id="type" name="type" onchange="calculation();">

  <option value="0">Please Choose</option>
  <option value="50" selected="selected">Single - 50£</option>
  <option value="60">Double - 60£</option>
  <option value="70">Luxury double - 70£</option>
  </select>
<br /><br />
<div id="diaplay_total">Total : 0£
</div>
</form>
</body>
</html>
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.