WordPress.org

Ready to get started?Download WordPress

Forums

Add Existing inline Javascript/HTML form to page and sidebar (1 post)

  1. elmo112
    Member
    Posted 1 year ago #

    Hi I am busy redesigning a site for a hotel using WordPress, however they have an existing booking engine whom have provided me with the following code:

    <form method="post" action="http://fe.avvio.com/convert/site/Lagoon%20Beach%20Hotel/index.php" id="c5QuickBook">
    	<table id="c5QuickBookTable">
    		<tbody>
    			<tr>
    				<td>
    					<select id="ci_day" name="ci_day"></select>
    					<select id="ci_ym" name="ci_ym"></select>
    					<input type="hidden" value="" name="checkin" id="checkin"/>
    					<input type="hidden" value="1" name="fw_submitted" id="fw_submitted"/>
    					<input type="hidden" value="search" name="av" id="av" />
    				</td>
    			</tr>
    			<tr>
    				<td>
    					Nights Stay
    					<select id="nights" name="nights"></select>
    				</td>
    			</tr>
    			<tr>
    				<td>
    					<button id="c5QuickBookButton" type="button" value="Check Availability" onclick="submitC5QuickBook();">
    						<noscript><div>This quickbook uses JavaScript. Please enable JavaScript in your browser!</div></noscript>
    						<div>Check Availability</div>
    					</button>
    				</td>
    			</tr>
    		</tbody>
    	</table>
    </form>
    
    <script type="text/Javascript"><!--
    	var select_month = new Array('Null','Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec');
    	var datenow = new Date();
    	var month = datenow.getMonth() + 1;
    	var year = datenow.getFullYear();
    
    	// days
    	for (var i = 1; i <= 31; i++)
    	{
    		var newOption = document.createElement("option");
    		newOption.value = i;
    		newOption.appendChild(document.createTextNode(i));
    		document.getElementById("ci_day").appendChild(newOption);
    	}
    	document.forms['c5QuickBook'].elements['ci_day'].value = datenow.getDate();
    
    	// years, month
    	for(var i=1; i<=13; i++)
    	{
    		var newOption = document.createElement("option");
    		newOption.value = year + "-" + month;
    		newOption.appendChild(document.createTextNode(select_month[month] + "-" + year));
    		document.getElementById("ci_ym").appendChild(newOption);
    		if ( month >= 12 )
    		{
    			year++;
    			month=1;
    		}
    		else
    		{
    			month++;
    		}
    	}
    	document.forms['c5QuickBook'].elements['ci_ym'].value = datenow.getFullYear() + '-' + ( parseInt(datenow.getMonth() + 1) );
    
    	// length of stay
    	for (var i = 1; i <= 20; i++)
    	{
    		var newOption = document.createElement("option");
    		newOption.value = i;
    		newOption.appendChild(document.createTextNode(i));
    		document.getElementById("nights").appendChild(newOption);
    	}
    	document.forms['c5QuickBook'].elements['nights'].value = 1;
    
    	// submit func
    	function submitC5QuickBook()
    	{
    		yearMonth = document.forms['c5QuickBook'].elements['ci_ym'].value;
    		day  = document.forms['c5QuickBook'].elements['ci_day'].value;
    		document.forms['c5QuickBook'].elements['checkin'].value = yearMonth + '-' + day;
    		_gaq.push(['_linkByPost', document.forms['c5QuickBook']]);
    		document.forms['c5QuickBook'].submit();
    	}
    --></script>

    I cannot seem to get it to work.

    I have to include it on the home page in a content area of a custom theme as well as in the sidebar.

    it displays in the sidebar but the submit button does nothing.

    I have tried numerous plugins and techniques but cant seem to get it right.

    Maybe I am missing something stupid.

    Please help

Topic Closed

This topic has been closed to new replies.

About this Topic