Forums

Simple Drop Down Redirect???

rong 17 Nov, 2010
I have a form with one drop down box with 4 choices and the submit button and I want the form to take you to the page relative to the drop down chosen.

choose option A = goto http://index.php?option=com_content&view=article&id=101&Itemid=1

choose option B = goto http://index.php?option=com_content&view=article&id=102&Itemid=2

choose option B = goto http://index.php?option=com_content&view=article&id=103&Itemid=3

choose option B = goto http://index.php?option=com_content&view=article&id=104&Itemid=4

How is this done? I have the latest versions of everything.
GreyHead 18 Nov, 2010
Hi rong ,

There are several ways to redirect. One would be this:
<?php
$option = JRequest::getString('option', '', 'post');
switch ($option) {
  case 'A':
  default: 
    $url = '&id=101&Itemid=1';
    break;
  case 'B':
    $url = '&id=102&Itemid=2';
    break;
  case 'C':
    $url = '&id=103&Itemid=3';
    break;
  case 'D':
    $url = '&id=104&Itemid=4';
    break;
}
$url = 'index.php?option=com_content&view=article'.$url;
$mainframe->redirect($url);
?>

Bob
rong 04 Dec, 2010
Thank Bob! This is exactly what I was looking for I will post the form and website as soon as its finished. Thanks again...hopefully after x-mas I can get you a beer or a case!
majidkhan 12 Dec, 2010
Hello all!

I am weak to programing.
Where to put this
<?php
$option = JRequest::getString('option', '', 'post');
switch ($option) {
  case 'A':
  default:
    $url = '&id=101&Itemid=1';
    break;
  case 'B':
    $url = '&id=102&Itemid=2';
    break;
  case 'C':
    $url = '&id=103&Itemid=3';
    break;
  case 'D':
    $url = '&id=104&Itemid=4';
    break;
}
$url = 'index.php?option=com_content&view=article'.$url;
$mainframe->redirect($url);
?>

in this one mine code.
<script>
function setOptions(chosen) {
var selbox = document.ChronoContact_course_finder.opttwo;
 
selbox.options.length = 0;
if (chosen == ' ') {
  selbox.options[selbox.options.length] = new Option('Choose Option',' ');
 
}
if (chosen == '85') {
  selbox.options[selbox.options.length] = new Option('ITEC Beauty Specialist Diploma','index.php?option=com_content&view=article&id=49&Itemid=68');
  selbox.options[selbox.options.length] = new Option('ITEC Professional Makeup','index.php?option=com_content&view=article&id=57&Itemid=76');
  selbox.options[selbox.options.length] = new Option('Fashion Catwalk & Photographic Makeup Course','index.php?option=com_content&view=article&id=67&Itemid=91');
  selbox.options[selbox.options.length] = new Option('Bridal Makeup Course','index.php?option=com_content&view=article&id=68&Itemid=92');
  selbox.options[selbox.options.length] = new Option('Special Effects Makeup','index.php?option=com_content&view=article&id=56&Itemid=77');
  selbox.options[selbox.options.length] = new Option('Gel Nails Course','index.php?option=com_content&view=article&id=65&Itemid=88');
  selbox.options[selbox.options.length] = new Option('Acrylic Nails Course','index.php?option=com_content&view=article&id=66&Itemid=89');
  selbox.options[selbox.options.length] = new Option('Spray Tanning Course','index.php?option=com_content&view=article&id=55&Itemid=73');  
}
if (chosen == '69') {
  selbox.options[selbox.options.length] = new Option('ITEC Holistic Massage Course','index.php?option=com_content&view=article&id=51&Itemid=2');
  selbox.options[selbox.options.length] = new Option('ITEC Sports Massage Diploma','index.php?option=com_content&view=article&id=59&Itemid=78');
  selbox.options[selbox.options.length] = new Option('Indian Head Massage Course','index.php?option=com_content&view=article&id=60&Itemid=79');
  selbox.options[selbox.options.length] = new Option('ITEC Reflexology Diploma','index.php?option=com_content&view=article&id=64&Itemid=87');
}
if (chosen == '80') {
  selbox.options[selbox.options.length] = new Option('ITEC Teaching Diploma','index.php?option=com_content&view=article&id=61&Itemid=81');
  selbox.options[selbox.options.length] = new Option('FETAC Train The Trainer Level 6','index.php?option=com_content&view=article&id=63&Itemid=86');
}
if (chosen == '83') {
  selbox.options[selbox.options.length] = new Option('ITEC Sports Massage Diploma','index.php?option=com_content&view=article&id=59&Itemid=90');

}
}
</script>


<div class="form_item">
  <div class="form_element cf_heading">
    <h1 class="cf_text">course finder</h1>
  </div>
  <div class="cfclear"> </div>
</div>

<div class="form_item">
  <div class="form_element cf_dropdown">
    <label class="cf_label" style="width: 200px;">step1:choose type of course</label>
    <select name="optone" class="cf_inputbox" size="1" onchange="setOptions(document.ChronoContact_course_finder.optone.options[document.ChronoContact_course_finder.optone.selectedIndex].value);">
      <option value=" " selected="selected">Choose Option</option>
      <option value="85">beauty courses</option>
	  <option value="69">complimentary courses</option>
	  <option value="80">teaching courses</option>
	  <option value="83">fitness courses</option>	  

    </select>
    
  </div>
  <div class="cfclear"> </div>
</div>

<div class="form_item">
  <div class="form_element cf_dropdown">
    <label class="cf_label" style="width: 200px;">step2: choose a subject</label>
    <select size="1" name="opttwo" class="cf_inputbox" >
    <option value=" " selected="selected">Choose Option</option>
      
    </select>
    <!--<input type="button" name="go" value="Value Selected" onclick="window.open(document.ChronoContact_course_finder.opttwo.options[document.ChronoContact_course_finder.opttwo.selectedIndex].value);">-->
  </div>
  <div class="cfclear"> </div>
</div>

<div class="form_item">
  <div class="form_element cf_button">
    <input type="submit" name="go" value="search" onclick="window.open(document.ChronoContact_course_finder.opttwo.options[document.ChronoContact_course_finder.opttwo.selectedIndex].value);">
  </div>
  <div class="cfclear"> </div>
    
</div>


please help! I am stuck
GreyHead 12 Dec, 2010
Hi majidkhan,

The code in the first box goes into either the OnSubmit After Email or the OnSubmit Before Email box (you need to set Send Emails to Yes on the General Tab to make sure that the OnSubmit Before Email code is executed).

Bob
sclarkstone 15 Dec, 2010
Hi, i used the following in the on submit box;

<?php
$radio0 = JRequest::getString('radio0');

switch ($radio0 ) {
  case 'I would like to download the information':
  default:
    $url = 'option=com_docman&Itemid=395';
    break;
  default:
    $url = 'option=com_content&view=article&id=84&Itemid=391';
    break;
  }
$url = 'index.php?'.$url;
$mainframe->redirect($url);?>


However, it stops the emails from being sent, as soon as i take the code out the emails send. what am i doing wrong?

thank you
GreyHead 15 Dec, 2010
Hi sclarkstone,

If you use an immediate redirect then ChronoForms can't process beyond that point. So if you redirect before the emails are sent then the emails won't be sent.

You can use the ChronoForms ReDirect URL (which executes after the processing) using:
$MyForm->formrow->redirecturl = $url;

Bob
sclarkstone 15 Dec, 2010
Ok, sorry for my stupidity, please could you explain a bit further;

would
$MyForm->formrow->redirecturl = $url;


replace the switch statement? if so how do you make it go to different pages depending on what is selected in radio0?

thank you so much for your help
GreyHead 15 Dec, 2010
Hi sclarkstone ,

<?php
$radio0 = JRequest::getString('radio0');
switch ($radio0 ) {
  case 'I would like to download the information':
  default:
    $url = 'option=com_docman&Itemid=395';
    break;
  default:
    $url = 'option=com_content&view=article&id=84&Itemid=391';
    break;
  }
$url = 'index.php?'.$url;
$MyForm->formrow->redirecturl = $url;
?>

Bob
sclarkstone 15 Dec, 2010
Spot on,your awesome, thank you.
V@lentine 07 Mar, 2011
Can we do the same with the form "submit url" ?
GreyHead 07 Mar, 2011
Hi V@lentine ,

The same as what exactly?

If you use the Submit URl then the form will be submitted to that URL, ChronoForms will never see the results and so cannot check the submission, send emails, save data or anything else.

Bob
V@lentine 15 Mar, 2011
Sorry GreyHead I went too fast😉
I managed to use this redirection after my form is submitted and my data inserted, adding this at the end of my "on Submit Code" :
$source = JRequest::getString('typeClient', '', 'post');
echo gettype($source);
switch ($source) {
  case 'ind':
    $url = '&id=44&Itemid=5&cand='.$idAuditeur;
    break;
  case '27':
    $url = '&id=17&Itemid=27';
    break;
  case '103':
    $url = '&id=44&Itemid=5&cand='.$idAuditeur.'&idClient='.$idClient;
    break;

}
$url = 'index.php?option=com_content&view=article'.$url;
$mainframe->redirect($url);

And this works pretty fine ! I wish I had known that earlier😉

Now I'd like to do one more thing in specific cases.
I need to redirect $mainframe and at the same time open another url in another page after the form is submitted.
Something like :
$url = 'index.php?option=com_content&view=article'.$url;
$mainframe->redirect($url);
$url2 = 'index.php?option=com_content&view=article'.$url2;
$newframe->open($url2);

(newframe and open are invented by me)
I searched through the web, but found no solution...

What I'm trying to do is create a contract with a client.
When the form is submitted, data about that contract is inserted in my database and a link is displayed so that users can generate the contract in pdf and print it to have it signed.
When they click on the link, the pdf opens in a new page and the mainframe is redirected elsewhere. And I have 2 types of contracts possible because the client can be individual or employer.
if($_POST["typeClient"]=="ind") {
	echo '<a href="fpdf/cfp.php?idConvention='.$idConvention.'" target="_blank" onclick=window.location.href="index.php?option=com_content&view=article&id=23&Itemid=28">Imprimer le contrat</a>';
		}else {
	echo '<a href="fpdf/cvn.php?idConvention='.$idConvention.'" target="_blank" onclick=window.location.href="index.php?option=com_content&view=article&id=23&Itemid=28">Imprimer la convention</a>';
	}

But I'd rather do this automatically because if they don't click the link, the pdf is not generated and won't exist.


Hope I'm clear...😛
GreyHead 15 Mar, 2011
Hi V@lentine,

You can't open a Window with PHP because the code runs on the server not in the browser. The best I can think of is that you can add a JavaScript to the page you are redirecting the user too and have the script open a window. Would that work?

Bob
V@lentine 16 Mar, 2011
I'll try this... and come back to tell😉
Thx
badbrad 14 Aug, 2012
Hi,
I'm struggling getting this dropdown method to work. I just can't seem to make it switch when selecting value 4. Could someone please help me. I'm using version 3.1 RC5.5. Here is my code:

This is my HTML - Main onLoad/View Code
<?php date_default_timezone_set('Pacific/Auckland'); ?>
<h1>Get a free quote...</h1>
<?php 
	if($_GET['From_Day']==NULL){
			$current_day=date("d");
		}
	else{
			$current_day=htmlspecialchars($_GET['From_Day']);
		}
	if($_GET['From_Month']==NULL){
			$current_month=date("m")-1;
		}
	else{
			$current_month=htmlspecialchars($_GET['From_Month']);
		}	
	if($_GET['From_Year']==NULL){
			$current_year=date("Y");
		}
	else{
			$current_year=htmlspecialchars($_GET['From_Year']);
		}	
		
	$to_day=htmlspecialchars($_GET['To_Day']);	
	$to_month=htmlspecialchars($_GET['To_Month']);	
	$to_year=htmlspecialchars($_GET['To_Year']);	

$months=array(0=>'January',1=>'February',2=>'March',3=>'April',4=>'May',5=>'June',6=>'July',7=>'August',8=>'September',9=>'October',10=>'November',11=>'December');
$locations=array('Christchurch'=>0,'Auckland'=>250,'Queenstown'=>180,'Nelson'=>180);

?>
<fieldset>
<!--=== Vehicle Types ===-->
<div>
          <label for="Van_Type">Van Type</label>
          <select size="1" name="Van_Type" id="Van_Type">
            <option value="" selected="selected">Select</option>
            <option value="1">2/3 Berth Sportster Camper</option>
            <option value="2">2/3 Berth Clubby Camper</option>
            <option value="3">4 Berth Motorhome</option>
            <option value="4">Economy Vehicle</option>
            <option value="5">Tourist Vehicle</option>
            <option value="6">Touring Wagon</option>
            <option value="7">Premium Vehicle</option>
            <option value="8">People Mover</option>
            </select>
</div>
<!--=== From Date ===-->
<div>
          <label for="From_Day">Pick up</label>Day
          <select size="1" name="From_Day">
            <?php
				for($day=1; $day<=31; $day++)
				{
					$thisday="<option ";
					$thisday.="value=".$day." ";
					if($day==$current_day)
						{
							$thisday.="selected='selected' ";
						}
					$thisday.=">".$day."</option>";
					echo $thisday;
				}
	 		?>
            </select>
          Month <select size="0" name="From_Month">
          <?php 
		  foreach($months as $pos=>$name)
		  	{
				$thismonth="<option value={$pos} ";
				if($pos==$current_month)
					  {
						  $thismonth.="selected='selected' ";
					  }
				$thismonth.=">".$name."</option>";
				echo $thismonth;
			}
          
            ?>
          </select>
			Year
			<select size="1" name="From_Year">
			<?php
				for($year=date("Y"); $year<$current_year+2; $year++)
				{
					
					$thisyear="<option ";
					if($year==$current_year)
						{
							$thisyear.="selected='selected' ";
						}
					$thisyear.="value=".$year." ";
					$thisyear.=">".$year."</option>";
					echo $thisyear;
				}
			?>
			</select>
            Location
			<select size="1" name="pickup" disabled="disabled">

			<?php 
			  foreach($locations as $place=>$cost)
				{
					$thisplace="<option value={$place} ";
					if($place==htmlspecialchars($_GET['pickup']))
						  {
							  $thisplace.="selected='selected' ";
						  }
					$thisplace.=">".$place."</option>";
					echo $thisplace;
				}
			  
            ?>
			</select>
</div>


<!--=== To Date ===-->    
<div>   
<label for="To_Day">Drop off</label>
          Day
          <select size="1" name="To_Day">
		  	<?php
				for($day=1; $day<=31; $day++)
				{
					$thisday="<option ";
					$thisday.="value=".$day." ";
					if($day==$to_day)
						{
							$thisday.="selected='selected' ";
						}
					elseif($to_day==NULL)
						{
							if($day==$current_day+1)
								{
									$thisday.="selected='selected' ";
								}
						}
					$thisday.=">".$day."</option>";
					echo $thisday;
				}
	 		?>
          </select>
         
         Month <select size="0" name="To_Month">
            <?php 
		  foreach($months as $pos=>$name)
		  	{
				$thismonth="<option value={$pos} ";
				if($pos==$to_month)
						{
							$thismonth.="selected='selected' ";
						}
				elseif($to_month==NULL)
						{
							if($pos==$current_month)
								  {
									  $thismonth.="selected='selected' ";
								  }
						}
				$thismonth.=">".$name."</option>";
				echo $thismonth;
			}


          
            ?></select>
          
          Year
			<select size="1" name="To_Year">
			<?php
				for($year=date("Y"); $year<$current_year+2; $year++)
				{
					$thisyear="<option ";
					$thisyear.="value=".$year." ";
					if($year==$to_year)
						{
							$thisyear.="selected='selected' ";
						}
					$thisyear.=">".$year."</option>";
					echo $thisyear;
				}
			?>
			</select>
            Location
			<select size="1" name="dropoff">

			<?php 
			foreach($locations as $place=>$cost)
				{
					$thisplace="<option value={$place} ";
					if($place==htmlspecialchars($_GET['dropoff']))
						  {
							  $thisplace.="selected='selected' ";
						  }
					$thisplace.=">".$place."</option>";
					echo $thisplace;
				}
			  
            ?>
			</select>
</div>
</fieldset>

<fieldset>
<!--=== Optional Extras ===--> 
<div>  
    <label for="gps">G.P.S</label>
	<input type="checkbox" name="gps" />
    <span>($50 per hire)</span>
</div>

<div>  
    <label for="Bikes">Bikes</label>
    <select size="1" name="Bikes">
        <option value="0" selected="selected">0</option>
        <option value="1">1</option>
        <option value="2">2</option>
    </select>
    (All Campers)
</div>
          
<div>
  <label for="Kayaks">Kayaks</label>
  <select size="1" name="Kayaks">
    <option value="0" selected="selected">0</option>
    <option value="1">1</option>
    <option value="2">2</option>
  </select>
  (Sportster Only)
</div>
          
<div>
    <label for="DVD">DVD Player</label>
    <input type="checkbox" name="DVD" />
    <span>($50 per hire)</span>
</div>
          
<div>
    <label for="Ski_Racks">Ski Racks</label>
    <input type="checkbox" name="Ski_Racks" />
    <span>($50 per hire)</span>
</div>

<div>  
    <label for="portaloo">Porta Loo</label>
    <input type="checkbox" name="portaloo" />
    <span>($50 per hire)</span>
</div>

<div>  
    <label for="snowchains">Snow Chains</label>
	<input type="checkbox" name="snowchains" />
    <span>($50 per hire)</span>
</div>

<div>  
    <label for="babyseat">Baby Seat</label>
	<input type="checkbox" name="babyseat" />
    <span>($50 per hire)</span>
</div>

<div>  
    <label for="boosterseat">Booster Seat</label>
	<input type="checkbox" name="boosterseat" />
    <span>($50 per hire)</span> 4-7 years old
</div>

</fieldset>

<fieldset> 

<div>
      <input onClick="quoteNow()" type="button" value="Get/Refresh Quote" name="Go" />
</div>

<div>  
          <label for="Quote_Result">Quote Breakdown</label>
          <textarea name="Quote_Result" rows="8" cols="40"></textarea>
</div>

<div>      
          <label for="Total">Total Cost</label>
          <input style="float: left;" type="text" size="14" value="$0.00 NZD" name="Total" />
            
</div>
<div style="margin-left:130px; padding-top:13px"><img src="images/cards.png" width="123" height="19" /><span style="font-size:9px; color:#555555">*Available from the 15<sup>th</sup> Apr - 30<sup>th</sup> Oct. Subject to availability</span></div>

<div style="margin-top:15px">     
          <input type="image" name="Print" src="images/printquote.jpg" onclick="printField(); return false;" id="Printquote" />
          <input type="image" name="BookNow" src="images/booknow.jpg" onclick="goToURL(); return false;" id="Booknow" />
</div></fieldset>


And this is what I have in my Javascript - Main onLoad/View Code
<?php
global $mainframe;
$case = JRequest::getString(Van_Type', '', 'post');
switch ($Van_Type) {
      case '1':
      default:
        $url = 'quote_form1';
        break;
      case '2':
      default:
        $url = 'quote_form1';
        break;
      case '3':
      default:
        $url = 'quote_form1';
        break;
      case '4':
      default:
        $url = 'cars_quote';
        break;
      case '5':
        $url = 'cars_quote';
        break;
      case '6':
        $url = 'cars_quote';
        break;
      case '7':
        $url = 'cars_quote';
        break;
         case '8':
        $url = 'cars_quote';
        break;
    }
    $url = 'index.php?option=com_chronocontact&chronoformname='.$url;
    $mainframe->redirect($url);?>

var totalPrice = 0
var totalDays;

function roundNumber(num, dec) {
	var result = Math.round(num*Math.pow(10,dec))/Math.pow(10,dec);
	return result;
}

function extracost(oneCost,twoCost,threeCost){
	if(vehicletype==1)
		{
			xtraCost=oneCost;
		}
	else if(vehicletype==2)
		{
			xtraCost=twoCost;
		}
	else if(vehicletype==3)
		{
			xtraCost=threeCost;
		}
		return xtraCost;
}

function goToURL()
{
	quoteNow();
	var tg = "https://www.roadrunnerrentals.co.nz/index.php?Itemid=5&option=com_chronocontact&chronoformname=booking_form&Total="+totalPrice+
	"&From_Day=" + document.getElementById("ChronoContact_quote_form").From_Day.value +
	"&From_Month=" + document.getElementById("ChronoContact_quote_form").From_Month.value +
	"&From_Year=" + document.getElementById("ChronoContact_quote_form").From_Year.value +
	"&To_Day=" + document.getElementById("ChronoContact_quote_form").To_Day.value +
	"&To_Month=" + document.getElementById("ChronoContact_quote_form").To_Month.value +
	"&To_Year=" + document.getElementById("ChronoContact_quote_form").To_Year.value +
	"&Van_Type=" + document.getElementById("ChronoContact_quote_form").Van_Type.value +
	"&Bikes=" + document.getElementById("ChronoContact_quote_form").Bikes.value +
	"&dropoff=" + document.getElementById("ChronoContact_quote_form").dropoff.value +
	"&Kayaks=" + document.getElementById("ChronoContact_quote_form").Kayaks.value;
	
	if (document.getElementById("ChronoContact_quote_form").DVD.checked)
	{
		tg = tg + "&DVD=" + document.getElementById("ChronoContact_quote_form").DVD.checked;
	}
	if (document.getElementById("ChronoContact_quote_form").Ski_Racks.checked)
	{
		tg = tg + "&Ski_Racks=" + document.getElementById("ChronoContact_quote_form").Ski_Racks.checked;
	}
	if (document.getElementById("ChronoContact_quote_form").gps.checked)
	{
		tg = tg + "&gps=" + document.getElementById("ChronoContact_quote_form").gps.checked;
	}
	if (document.getElementById("ChronoContact_quote_form").portaloo.checked)
	{
		tg = tg + "&portaloo=" + document.getElementById("ChronoContact_quote_form").portaloo.checked;
	}
	if (document.getElementById("ChronoContact_quote_form").snowchains.checked)
	{
		tg = tg + "&snowchains=" + document.getElementById("ChronoContact_quote_form").snowchains.checked;
	}
	if (document.getElementById("ChronoContact_quote_form").babyseat.checked)
	{
		tg = tg + "&babyseat=" + document.getElementById("ChronoContact_quote_form").babyseat.checked;
	}
	if (document.getElementById("ChronoContact_quote_form").boosterseat.checked)
	{
		tg = tg + "&boosterseat=" + document.getElementById("ChronoContact_quote_form").boosterseat.checked;
	}
	
	if(totalDays<5)
		{
			alert("Your booking is too short, the minimum hire period is 5 days. Please adjust your dates and try again.")
		}
	else{
			top.location = tg;
		}
}


function quoteNow()
{
	var oneday = 1000*60*60*24;
	var fromDate = new Date(document.getElementById("ChronoContact_quote_form").From_Year.value,document.getElementById("ChronoContact_quote_form").From_Month.value,document.getElementById("ChronoContact_quote_form").From_Day.value);
	var todaysDate= new Date();
	var toDate = new Date();
	var tempDate = new Date();
	var p1Days;
	var p2Days;
	var quoteText = "";
	var vehiclePrice = 0;
	var bikePrice = 0;
	var kayakPrice = 0;
	var DVDPrice = 0;
	var SkiRackPrice = 0;
	var dropoffPrice = 0;
	var gpsPrice = 0;
	var portalooPrice = 0;
	var snowchainsPrice = 0;
	var boosterseatPrice = 0;
	var babyseatPrice = 0;

	var xtraCost = 0;
	
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////	
	//WORKING OUT THE DIFFERENCE BETWEEN TODAYS DATE AND THE START OF THE BOOKING
	var todayms = todaysDate.getTime();
	var tillms = fromDate.getTime();
    // Calculate the difference in milliseconds
    var difference_ms = Math.abs(todayms - tillms);
    // Convert back to days and return
    var daysOut= Math.floor(difference_ms/oneday);
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

	toDate.setMonth(document.getElementById("ChronoContact_quote_form").To_Month.value) ;
	toDate.setDate(document.getElementById("ChronoContact_quote_form").To_Day.value) ;
	toDate.setYear(document.getElementById("ChronoContact_quote_form").To_Year.value) ;

	totalDays = Math.ceil((toDate.getTime() - fromDate.getTime()) / oneday) ;

	vehicletype = document.getElementById("ChronoContact_quote_form").Van_Type.value;

	if (totalDays < 0)
	{
		totalDays = 0 ;
	}

	tempDate = fromDate ;
	for (i = 0; i < totalDays; i++)
	{
		tempDate.setTime(tempDate.getTime() + oneday) ;
			if (tempDate.getMonth() ==0)
                  {
					//January
					xtraCost=extracost(115,135,215);
					vehiclePrice = vehiclePrice + xtraCost;
                  }
			  
			else if (tempDate.getMonth() ==1)
                  {
					//February
					xtraCost=extracost(115,135,215);
					vehiclePrice = vehiclePrice + xtraCost;
                  }
				  
			else if (tempDate.getMonth() ==2)
                  {
					//March
					xtraCost=extracost(115,135,215);
					vehiclePrice = vehiclePrice + xtraCost;
                  }
				  
			else if (tempDate.getMonth() ==3)
                  {
					//April
					xtraCost=extracost(65,69,175);
					vehiclePrice = vehiclePrice + xtraCost;
                  }				  

			else if (tempDate.getMonth() ==4)
                  {
					//May
					xtraCost=extracost(49,49,125);
					vehiclePrice = vehiclePrice + xtraCost;
                  }				  
		  
			else if (tempDate.getMonth() ==5)
                  {
					//June
					xtraCost=extracost(49,49,125);
					vehiclePrice = vehiclePrice + xtraCost;
                  }				  
		  
			else if (tempDate.getMonth() ==6)
                  {
					//July
					xtraCost=extracost(49,49,125);
					vehiclePrice = vehiclePrice + xtraCost;
                  }		
		  
			else if (tempDate.getMonth() ==7)
                  {
					//August
					xtraCost=extracost(49,49,125);
					vehiclePrice = vehiclePrice + xtraCost;
                  }				  

			else if (tempDate.getMonth() ==8)
                  {
					//September
					xtraCost=extracost(49,49,125);
					vehiclePrice = vehiclePrice + xtraCost;
                  }				  

			else if (tempDate.getMonth() ==9)
                  {
					//October
					xtraCost=extracost(65,65,175);
					vehiclePrice = vehiclePrice + xtraCost;
                  }				  
		  
			else if (tempDate.getMonth() ==10)
                  {
					//November
					xtraCost=extracost(85,85,175);
					vehiclePrice = vehiclePrice + xtraCost;
                  }				  
			  
			else if (tempDate.getMonth() ==11)
                  {
					//December
					xtraCost=extracost(115,135,215);
					vehiclePrice = vehiclePrice + xtraCost;
                  }				  
			  else
				{
				vehiclePrice = vehiclePrice + 115 + xtraCost ;
				}
	}
	//quoteText = quoteText + "Vehicle Hire for " + totalDays + " Days = $" + vehiclePrice + "\n" ;
	
	if(document.getElementById("ChronoContact_quote_form").dropoff.value=='Christchurch')
		{
			dropoffPrice=0;
		}
	else if(document.getElementById("ChronoContact_quote_form").dropoff.value=='Auckland')
		{
			dropoffPrice=250;
		}
	else if(document.getElementById("ChronoContact_quote_form").dropoff.value=='Queenstown')
		{
			dropoffPrice=180;
		}
	else if(document.getElementById("ChronoContact_quote_form").dropoff.value=='Nelson')
		{
			dropoffPrice=180;
		}
			
	quoteText = quoteText + "Relocation Fee = $" + dropoffPrice + "\n";
	
	if (document.getElementById("ChronoContact_quote_form").Bikes.value > 0)
	{
		/*Mountain Bikes*/
		bikePrice = document.getElementById("ChronoContact_quote_form").Bikes.value*100; 
		quoteText = quoteText + "Hire " + document.getElementById("ChronoContact_quote_form").Bikes.value + " Bike(s) = $" + bikePrice + "\n" ;
	}
	if (document.getElementById("ChronoContact_quote_form").Kayaks.value > 0)
	{
		/*Kayaks*/
		if(document.getElementById("ChronoContact_quote_form").Kayaks.value==2){
				var perkayak=75;
			}
		else{
				perkayak=100;
			}
		kayakPrice = document.getElementById("ChronoContact_quote_form").Kayaks.value*perkayak; 
		quoteText = quoteText + "Hire " + document.getElementById("ChronoContact_quote_form").Kayaks.value + " Kayak(s) = $" + kayakPrice + "\n" ;
	}
	
	
	if (document.getElementById("ChronoContact_quote_form").DVD.checked)
	{
		/*DVD Player*/
		DVDPrice = 50;
		quoteText = quoteText + "DVD Hire = $" + DVDPrice + "\n" ;
	}
	if (document.getElementById("ChronoContact_quote_form").Ski_Racks.checked)
	{
		/*Ski Rack*/
		SkiRackPrice = 50;
		quoteText = quoteText + "Ski Rack Hire = $" + SkiRackPrice + "\n" ;
	}
	if (document.getElementById("ChronoContact_quote_form").gps.checked)
	{
		/*GPS*/
		gpsPrice = 50;
		quoteText = quoteText + "G.P.S = $" + gpsPrice + "\n" ;
	}
	if (document.getElementById("ChronoContact_quote_form").portaloo.checked)
	{
		/*Portaloo*/
		portalooPrice = 50;
		quoteText = quoteText + "Portaloo = $" + portalooPrice + "\n" ;
	}
	if (document.getElementById("ChronoContact_quote_form").snowchains.checked)
	{
		/*Snowchains*/
		snowchainsPrice = 50;
		quoteText = quoteText + "Snowchains = $" + snowchainsPrice + "\n" ;
	}
	if (document.getElementById("ChronoContact_quote_form").boosterseat.checked)
	{
		/*Booster Seat*/
		boosterseatPrice = 50;
		quoteText = quoteText + "Booster Seat= $" + boosterseatPrice + "\n" ;
	}
	if (document.getElementById("ChronoContact_quote_form").babyseat.checked)
	{
		/*Baby Seat*/
		babyseatPrice = 50;
		quoteText = quoteText + "Babyseat = $" + babyseatPrice + "\n" ;
	}
	
		
	
	totalPrice = (vehiclePrice + bikePrice + kayakPrice + DVDPrice + SkiRackPrice + snowchainsPrice + portalooPrice + gpsPrice + dropoffPrice + babyseatPrice + boosterseatPrice);
	
	
	
	var average_perday=totalPrice/totalDays;
	var rounded_average_perday = roundNumber(average_perday,2);
	
	
	quoteText = quoteText + "Total Days = " +totalDays + "\n";
	
	quoteText = quoteText + "Average Cost Per Day = $" + rounded_average_perday + "\n";
	
	if(daysOut>30){
		var earlybird=totalPrice*0.1;
		totalPrice=totalPrice * 0.9;
		quoteText = quoteText + "Earlybird discount = $" + earlybird + "\n";
		}
	
	document.getElementById("ChronoContact_quote_form").Total.value = "$" + totalPrice + ".00 NZD" ;
	
	quoteText = quoteText + "Total Amount for Hire = $" + totalPrice + "\n\n";
	
	var deposit = roundNumber((totalPrice*.2),2);

	quoteText = quoteText + "20% Deposit of $"+deposit+" will be charged on confirmation of booking";
		document.getElementById("ChronoContact_quote_form").Quote_Result.value = quoteText ;
}


function printField()
{
   var s = document.getElementById("ChronoContact_quote_form").Quote_Result.value ;
   var regExp=/\n/gi ;
   s = s.replace(regExp,'<br />') ;
   pWin = window.open('','pWin','location=yes, menubar=yes, toolbar=yes') ;
   pWin.document.open() ;
   pWin.document.write('<html>')
   pWin.document.write('<style type="text/css">*{font-family:arial, sans-serif;} img{display:block;}</style>')
   pWin.document.write('<head></head><body>')
   pWin.document.write('<img src="/images/quote_logo.jpg" />')
   pWin.document.write(s) ;
   pWin.document.write('</body></html>') ;
   pWin.print() ;
   pWin.document.close() ;
   pWin.close() ;
}
GreyHead 18 Aug, 2012
Hi badbrad,

Sorry, I have no idea which parts of these scripts do what or even which part you are referring to :-(

I did spot that this line is missing a '
$case = JRequest::getString(Van_Type', '', 'post');


You also seem to have a $mainframe->redirect in your JavaScript block which seems unusual???

Bob
This topic is locked and no more replies can be posted.