Solved

Why did JS on stop working?

Posted on 2014-03-21
6
221 Views
Last Modified: 2014-03-22
Hi,
I have a simple form that needs to display additional fields if visitors select "yes". It worked fine but stopped working.

I don't recall making changes that would have impacted the form and need help.

Will update with link or send entire page if needed.

Thanks,

Sally
____________________________________

The JS functions:

<script type="text/javascript" >
// to display the return trip data if the return trip box is checked //
// DisplayReturn//
function DisplayReturn() {
	var selectreturn = document.getElementById("returntrip");
    if (selectreturn.value=='yes') {
        document.getElementById("returnride").style.display = 'block';
        document.getElementById("returndate").value = '';
        document.getElementById("returntime").value = '';
        document.getElementById("returndate").focus;
    } else {
        document.getElementById("returnride").style.display = 'none';
        document.getElementById("returndate").value = 'n/a';
        document.getElementById("returntime").value = 'n/a';
    }

// get name of Adult at destination for after school //
// DisplayAdultName//
function DisplayAdultName() {
	var selectcp = document.getElementById("AdultAtDestination");
    if (selectcp.value=='yes') {
        document.getElementById("adultnamediv").style.display = 'block';
        document.getElementById("adultname").value = '';
        document.getElementById("adultname").focus;
    } else {
        document.getElementById("adultnamediv").style.display = 'none';
        document.getElementById("adultname").value = 'n/a';
    }
} 

</script>


My form elements:
					<p ><label for="returntrip">Is return car service needed?</label>
					<select name="returntrip" id="returntrip" onchange="javascript:DisplayReturn()" >
						<option value="no">choose</option>
						<option value="yes">yes</option>
						<option value="no">no</option>
					</select> </p>
					<div id="returnride" >
						<p ><label for="returndate">Return Flight Arrival Date</label>
						<input type="text" name="returndate" id="returndate" class="REQUIRED LENGTH_INPUT DATE medium" value="n/a"  placeholder="" />
						</p>
						<p ><label for="returntime">Return Flight Arrival Time</label>
						<input type="text" name="returntime" id="returntime" class="REQUIRED LENGTH_INPUT medium" value="n/a"  placeholder="" />
						</p>
						<p ><label for="returnairline">Return Airline</label>
						<input type="text" name="returnairline" id="returnairline" class="medium"  />
						</p>
						<p ><label for="returnflightno">Return Flight number</label>
						<input type="text" name="returnflightno" id="returnflightno" class="medium"  placeholder="" />
						</p>
						<p ><label for="cellphone">Cell Phone</label>
						<input type="text" name="cellphone" id="cellphone" class="medium"  placeholder="" />
						</p>
					</div>

Open in new window

0
Comment
Question by:sallywizard
  • 2
  • 2
6 Comments
 
LVL 82

Accepted Solution

by:
Dave Baldwin earned 500 total points
Comment Utility
You're missing a '}' after the first function.
<script type="text/javascript" >
// to display the return trip data if the return trip box is checked //
// DisplayReturn//
function DisplayReturn() {
      var selectreturn = document.getElementById("returntrip");
    if (selectreturn.value=='yes') {
        document.getElementById("returnride").style.display = 'block';
        document.getElementById("returndate").value = '';
        document.getElementById("returntime").value = '';
        document.getElementById("returndate").focus;
    } else {
        document.getElementById("returnride").style.display = 'none';
        document.getElementById("returndate").value = 'n/a';
        document.getElementById("returntime").value = 'n/a';
    }
}  // <<<<<<<<<<<<<<<--------------------------------
// get name of Adult at destination for after school //
// DisplayAdultName//
function DisplayAdultName() {
      var selectcp = document.getElementById("AdultAtDestination");
    if (selectcp.value=='yes') {
        document.getElementById("adultnamediv").style.display = 'block';
        document.getElementById("adultname").value = '';
        document.getElementById("adultname").focus;
    } else {
        document.getElementById("adultnamediv").style.display = 'none';
        document.getElementById("adultname").value = 'n/a';
    }
}

</script>

Open in new window

0
 

Author Closing Comment

by:sallywizard
Comment Utility
Thank you! I looked and looked and just missed it. That did the job.
0
 

Author Comment

by:sallywizard
Comment Utility
To padas - Thank you. Should I have attached the code in a text file? not sure how I missed the code box but after missing the end bracket... ~ Sally
0
 
LVL 82

Expert Comment

by:Dave Baldwin
Comment Utility
You're welcome, glad to help.
0
 
LVL 52

Expert Comment

by:Scott Fell, EE MVE
Comment Utility
>Should I have attached the code in a text file?

No, the best thing is to use the code box.  In the comment box you can see there is Bold, Italics, Underling, Bullet, Number, H2, Link, Quote, Code, Snippet, Image.

I think the snippet creates an attachment and the Code just embeds and that is what I did.
0

Featured Post

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo…
Any business that wants to seriously grow needs to keep the needs and desires of an international audience of their websites in mind. Making a website friendly to international users isn’t prohibitively expensive and can provide an incredible return…
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

772 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now