Go Back   CodingForums.com > :: Client side development > JavaScript programming

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 04-30-2008, 06:03 PM   PM User | #1
XTREEMMAK
New to the CF scene

 
Join Date: Apr 2008
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
XTREEMMAK is an unknown quantity at this point
Change a Value in Dropdown menu?

Hey Guys,
I'm new here, what's up ?! Anyway, I'm creating a form which I need the values of certain options selected to return as strings to an option value in a drop down list. I dont know what's going on:

<!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=utf-8" />
<title>Untitled Document</title>
<style type="text/css">
<!--
h1 {
font-family: Arial, Helvetica, sans-serif;
text-decoration: underline;
}
.style1 {color: #FFFFFF}
.MailHide {
display: none;
}
.MailSee {
display: block;
}
-->
</style>
<script type="text/javascript">
<!--
function MM_setTextOfTextfield(objId,x,newText) { //v9.0
with (document){ if (getElementById){
var obj = getElementById(objId);} if (obj) obj.value = newText;
}
}
//-->
</script>
<script type ="text/javascript">
//Initial Rebate Form Month Case Check
function Rebate() {
if (document._xclick.months.value > 3)
{
var myDiv = document.getElementById("RebateText");
myDiv.innerHTML = "Your order may qualify for a monthly rebate! Please use the contact form below FIRST before you begin the transaction.";
document.getElementById("submit").disabled = true
var DisplayMe = document.getElementById("NewForm");
DisplayMe.setAttribute("class", "MailSee")
}
else{
var myDiv = document.getElementById("RebateText");
myDiv.innerHTML = ""
document.getElementById("submit").disabled = false
var DisplayMe = document.getElementById("NewForm");
DisplayMe.setAttribute("class", "MailHide")
}
}

// Opens Form for Inquiry
function makeForm() {
if (document._xclick.months.value > 3){

}
}

//House Selection Checker
function HouseSel(){
if (document.getElementById("HouseSelect").value == 0) {
document.getElementById("submit").disabled = true
if (document._xclick.months.value > 3) {
var myDiv = document.getElementById("RebateText");
myDiv.innerHTML = "You did not choose a house, and for the amount of time you wish to stay, You may also qualify for a monthly rebate! Please select a house first.";
var DisplayMe = document.getElementById("NewForm");
DisplayMe.setAttribute("class", "MailHide")
}
else{
var myDiv = document.getElementById("RebateText");
myDiv.innerHTML = "You did not choose a house!";
var DisplayMe = document.getElementById("NewForm");
DisplayMe.setAttribute("class", "MailHide")
}
}
else {
document.getElementById("submit").disabled = false
}
//Validate Selection for PayPal
if (document.getElementById("HouseSelect").value == 1) {
alert ("Checked and True")

//---This is Where the problem is...
document.getElementById("HouseSelect").value = "Rent Deposite: Nags Head: " + document.getElementById("fromf").value + " to " + document.getElementById("tof").value
//---------------------------------
alert (document.getElementById("HouseSelect").value)
}
}

//End Customs
function MM_callJS(jsStr) { //v2.0
return eval(jsStr)
}
function MM_goToURL() { //v3.0
var i, args=MM_goToURL.arguments; document.MM_returnValue = false;
for (i=0; i<(args.length-1); i+=2) eval(args[i]+".location='"+args[i+1]+"'");
}
function MM_validateForm() { //v4.0
if (document.getElementById){
var i,p,q,nm,test,num,min,max,errors='',args=MM_validateForm.arguments;
for (i=0; i<(args.length-2); i+=3) { test=args[i+2]; val=document.getElementById(args[i]);
if (val) { nm=val.name; if ((val=val.value)!="") {
if (test.indexOf('isEmail')!=-1) { p=val.indexOf('@');
if (p<1 || p==(val.length-1)) errors+='- '+nm+' must contain an e-mail address.\n';
} else if (test!='R') { num = parseFloat(val);
if (isNaN(val)) errors+='- '+nm+' must contain a number.\n';
if (test.indexOf('inRange') != -1) { p=test.indexOf(':');
min=test.substring(8,p); max=test.substring(p+1);
if (num<min || max<num) errors+='- '+nm+' must contain a number between '+min+' and '+max+'.\n';
} } } else if (test.charAt(0) == 'R') errors += '- '+nm+' is required.\n'; }
} if (errors) alert('The following error(s) occurred:\n'+errors);
document.MM_returnValue = (errors == '');
} }
function MM_callJS(jsStr) { //v2.0
return eval(jsStr)
}
function MM_callJS(jsStr) { //v2.0
return eval(jsStr)
}
function MM_callJS(jsStr) { //v2.0
return eval(jsStr)
}
</script>
</head>

<body>
<div align="center">
<h1>CLIENT PAYMENT SYSTEM</h1>
<div id="DonationH">
<form action="https://www.paypal.com/us/cgi-bin/webscr" method="post" name="_xclick">
<h4>-Please Enter your Name -<br />
*First Name:
<input type="text" name="first_name" id="firstname" />
<br />
*Last Name:
<input type="text" name="last_name" id="lastname" />
</h4>
<h4>-Which house do you wish to reside in?-<br />
<label>
*
<select name="item_name" id="HouseSelect">
<option value="0" selected="selected">--Please Select a House--</option>
<option value="1">Nags Head</option>
<option value="Rent Deposite: Calibre: ">Calibre</option>
</select>
</label>
</h4>
<h4>-Find your Available Dates-
<br />
<input type="hidden" name="cmd" value="_xclick">
<input type="hidden" name="business" value="RobertZveibil@comcast.net">
<input type="hidden" name="currency_code" value="USD">
<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000"
codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" name="CoffeeCup"
width="200" height="220" align="middle" id="CoffeeCup">
<param name="movie" value="flash/Calendar/Availability.swf"/>
<param name="quality" value="high" />
<param name="FlashVars" value="ww=200&hh=220"/>
<param name="salign" value="lt" />
<param name="bgcolor" value="FFFFFF" />
<embed src="flash/Calendar/Availability.swf" quality="high" bgcolor="FFFFFF" width="200" height="220"
flashvars="ww=200&hh=220" name="CoffeeCup" salign="lt" align="middle" type="application/x-shockwave-flash"
pluginspage="http://www.macromedia.com/go/getflashplayer" />
</object>
<br>
<br />-Please enter the date range you found above-<br />
From (MM/DD/YY/):
<label>
<input name="fromf" type="text" id="fromf" maxlength="8" />
</label>
</h4>
<h4>To (MM/DD/YY/):
<label>
<input name="tof" type="text" id="tof" maxlength="8" />
</label>
<br />
<br />
Nights
:
<input name="nights" type="text" id="nights" tabindex="1" onfocus="MM_setTextOfTextfield('amount','','[CLEARED]');MM_callJS('document.getElementById(\&quot;submit\&quot.disabled = true')" value="4" />
<label></label>
=
<label> $
<input type="text" name="nightprice" id="nightprice" />
</label>
<br />
Weeks
:
<input name="weeks" type="text" id="weeks" tabindex="1" onfocus="MM_setTextOfTextfield('amount','','[CLEARED]');MM_callJS('document.getElementById(\&quot;submit\&quot.disabled = true')" value="0" />
<label></label>
=
$
<input type="text" name="weekprice" id="weekprice" />
<br />
Months
:
<input name="months" type="text" id="months" tabindex="1" onfocus="MM_setTextOfTextfield('amount','','[CLEARED]');MM_callJS('document.getElementById(\&quot;submit\&quot.disabled = true')" value="0" />
<label></label>
=$
<input type="text" name="monthprice" id="monthprice" />
<br />
<input name="calculate3" type="button" id="calculate3" tabindex="2"
onclick=
"var input= parseFloat(document._xclick.nights.value);
document._xclick.nightprice.value= (1530 * input);
var input= parseFloat(document._xclick.weeks.value);
document._xclick.weekprice.value= (input * 5310);
var input= parseFloat(document._xclick.months.value);
document._xclick.monthprice.value= (18800 * input);
document._xclick.amount.value= (parseFloat(document._xclick.nightprice.value) + parseFloat(document._xclick.weekprice.value) + parseFloat(document._xclick.monthprice.value));Rebate(); makeForm(); HouseSel();

" value="Calculate"/>
<br />
</h4>
<div id =RebateText></div>

<div class="MailHide" id = NewForm>
<input type="button" onclick="MM_goToURL('parent','contactform.html');return document.MM_returnValue" value="MAIL NOW">
<input name="Name" type="hidden" id="Name" value = "Sarah Vaugn" />
</div>
-----------------------------------------------------------------------------------<br />
*Price:
<label>
$
<input name="amount" type="text" id="amount" tabindex="3" onfocus="MM_setTextOfTextfield('amount','','DO NOT CLICK HERE!');MM_callJS('document.getElementById(\&quot;submit\&quot.disabled = true')" onchange="MM_setTextOfTextfield('amount','','Enter a Value Above');MM_callJS('document.getElementById(\&quot;submit\&quot.enable = true')" value="0.00" />
</label>
USD<br />
(This Field MUST have a price quote else the form will not submit! Please be sure that all fields are filled out.)<br />
<label>
<input name="submit" type="submit" id="submit" onclick=" MM_validateForm('firstname','','R','lastname','','R','amount','','R');return document.MM_returnValue" value="Submit Payment" />
</label>
<br>
</form>

</div>
</p>
</div>
</body>
</html>


And here's where I think the problem is:
//---This is Where the problem is...
document.getElementById("HouseSelect").value = "Rent Deposite: Nags Head: " + document.getElementById("fromf").value + " to " + document.getElementById("tof").value


I think it's because you cant set something using a return statement like this. But I dont know what to use...

You can see the script in full action thus far here:
http://riverfrontluxuries.com/paysys2.html
XTREEMMAK is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 03:40 AM.


Advertisement
Log in to turn off these ads.