/    Sign up×
Community /Pin to ProfileBookmark

booking movie tickets javascript help!

hi,could anyone show me the codes for online movie tickets booking html and javascript,,,i need it for my school project,,please help me

to post a comment
JavaScript

11 Comments(s)

Copy linkTweet thisAlerts:
@irf2kApr 01.2011 — You're probably not going to find someone to write the code for you (at least not here).

This is more for people who are trying to do something themselves and run into specific problems, or perhaps need general pointers...not complete solutions built from scratch.

Sorry if that sounds a bit rude, but I'm actually trying to help you, otherwise this question would just remain unanswered.

Have you tried writing any of it yourself? What are you stuck on?
Copy linkTweet thisAlerts:
@JMRKERApr 01.2011 — Ticket booking, at least to me, implies some sort of database to read from and write to.

Javascript has limited read capabilities (ajax) and even more limited write (activex MS only) ability.

I don't think you will have much success with this project using JS only.

Might consider PHP / mySql / or some other server side program.
Copy linkTweet thisAlerts:
@dean_ramseyauthorApr 02.2011 — i have problems on calculating the ammount of tickets,like adult price + child price..always error,,is there any other simple way to calculate them?

javascript

function printPrice() {

var movie = document.getElementById("movie").value;

var name = document.getElementById("textbox").value;

var price = document.getElementById("tickets").value;

var quantity = document.getElementById("quantity").value;

var sentence = " ";

for (var i = 1; i<=quantity; i++) {

sentence += name + " purchased ticket ";

sentence += movie + " for $";

sentence += price;

sentence += "n";

}

document.getElementById("insert").value=sentence;

}


html


<head>

<title>Tickets booking</title>

<script src="movie.js" type="text/javascript"></script>

<form name="form1">

<div>

Choose a movie: <select name="movie" id="movie">

<option value="Never say never">Never say never</option>

<option value="Hop">Hop</option>

<option value="Rio">Rio</option>

</select>

</div>

<div>

Name: <input type="text" name="textbox" id="textbox" />

</div>

<div>

<label>

<input type="radio" name="tickets" id="tickets1"

value="3" />Child

</label>

<label>

<input type="radio" name="tickets" id="tickets2"

value="8" />Adult

</label>

</div>

<div>

How many: <input type="text" name="quantity" id="quantity" />

<input type="button" value="Purchase"

onclick="printPrice();" />

<p id="output">

</p>

</div>

</form>

<div id="insert">

</div>

</html>
Copy linkTweet thisAlerts:
@JMRKERApr 02.2011 — From your script, note the following modifications...?
<i>
</i>&lt;html&gt;
&lt;head&gt;
&lt;title&gt;Movie Ticket Prices&lt;/title&gt;
&lt;!-- script src="movie.js" type="text/javascript"&gt;&lt;/script --&gt;
&lt;script type="text/javascript"&gt;

function printPrice() {
var movie = document.getElementById("movie").value;
var name = document.getElementById("textbox").value;
var price = getRBtnName('tickets') * 1;
var quantity = document.getElementById("quantity").value * 1;
var total = 0;
var sentence = "";
for (var i = 1; i&lt;=quantity; i++) {
sentence += name + " purchased ticket "";
sentence += movie + "" for $";
sentence += price;
total += price;
sentence += "&lt;br&gt;";
}
sentence += 'Total cost: $'+total;
document.getElementById("inserts").innerHTML=sentence;
// alert(movie+'n'+name+'n'+price+'n'+quantity+'n'+sentence);
}

function getRBtnName(GrpName) {
var sel = document.getElementsByName(GrpName);
var fnd = -1;
var str = '';
for (var i=0; i&lt;sel.length; i++) {
if (sel[i].checked == true) { str = sel[i].value; fnd = i; }
}
// return fnd; // return option index of selection
// comment out next line if option index used in line above <br/>
return str;
}

&lt;/script&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;form name="form1"&gt;

&lt;div&gt; Choose a movie:
&lt;select name="movie" id="movie"&gt;
&lt;option value="Never say never"&gt;Never say never&lt;/option&gt;
&lt;option value="Hop"&gt;Hop&lt;/option&gt;
&lt;option value="Rio"&gt;Rio&lt;/option&gt;
&lt;/select&gt;
&lt;/div&gt;

&lt;div&gt;
Name: &lt;input type="text" name="textbox" id="textbox" value="" /&gt;
&lt;/div&gt;

&lt;div&gt;
&lt;label&gt; &lt;input type="radio" name="tickets" value="3" /&gt;Child &lt;/label&gt;
&lt;label&gt; &lt;input type="radio" name="tickets" value="8" checked /&gt;Adult &lt;/label&gt;
&lt;/div&gt;

&lt;div&gt;
How many: &lt;input type="text" name="quantity" id="quantity" value="2" size="3" /&gt;
&lt;input type="button" value="Purchase" onclick="printPrice()" /&gt;
&lt;/div&gt;
&lt;/form&gt;

&lt;div id="inserts"&gt; &lt;/div&gt;
&lt;/body&gt;
&lt;/html&gt;

Note the differences between the codes.

Good Luck!

?

BTW: You should use [ code] and [ /code] tags (without the spaces)

to make your script stand out in the post.
Copy linkTweet thisAlerts:
@dean_ramseyauthorApr 03.2011 — thank you!but where should in put it?is this the html code only?
Copy linkTweet thisAlerts:
@dean_ramseyauthorApr 03.2011 — btw, how what should be changed to calculate the total cost of adults + the total cost of childrens



presentation is tomorrow :eek:
Copy linkTweet thisAlerts:
@JMRKERApr 04.2011 — btw, how what should be changed to calculate the total cost of adults + the total cost of childrens



presentation is tomorrow :eek:[/QUOTE]


You would need to change the radio buttons to checkboxes. You can only select one radio button at a time. You would also need to add a field for the number of children and the number of adults as you have only one field to enter the number of tickets to purchase.

BTW: The script provided is BOTH JS and HTML.

?
Copy linkTweet thisAlerts:
@dean_ramseyauthorApr 04.2011 — thank you sir!but i dont know where to add the field for no of childrens and adult ?

but overall,i managed to get a C for my presentation..thank you
Copy linkTweet thisAlerts:
@JMRKERApr 04.2011 — Well, since your homework is done and graded ...

This is what I was suggesting, based upon your original script:
<i>
</i>&lt;html&gt;
&lt;head&gt;
&lt;title&gt;Movie Ticket Prices&lt;/title&gt;
&lt;!-- script src="movie.js" type="text/javascript"&gt;&lt;/script --&gt;
&lt;script type="text/javascript"&gt;

function printPrice() {
var movie = document.getElementById("movie").value;
var name = document.getElementById("textbox").value;
var Cquantity = document.getElementById("Cquantity").value * 1;
var Aquantity = document.getElementById("Aquantity").value * 1;
var total = 0;
var sentence = "";
var price = document.getElementById('Ctickets').value * Cquantity;

sentence += name + "&lt;br&gt;purchased "+Cquantity+" Child ticket(s) to "";
sentence += movie + "" for $";
sentence += price;
total += price;

price = document.getElementById('Atickets').value * Aquantity;
sentence += "&lt;br&gt;and "+Aquantity+" Adult ticket(s) to "";
sentence += movie + "" for $";
sentence += price +'&lt;br&gt;';
total += price;

sentence += "&lt;br&gt;";
sentence += 'Total cost: $'+total;
document.getElementById("inserts").innerHTML=sentence;
}

&lt;/script&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;form name="form1"&gt;

&lt;div&gt; Choose a movie:
&lt;select name="movie" id="movie"&gt;
&lt;option value=""&gt;Select Movie&lt;/option&gt;
&lt;option value="Never say never"&gt;Never say never&lt;/option&gt;
&lt;option value="Hop"&gt;Hop&lt;/option&gt;
&lt;option value="Rio"&gt;Rio&lt;/option&gt;
&lt;/select&gt;
&lt;/div&gt;

&lt;div&gt;
Name: &lt;input type="text" name="textbox" id="textbox" value="" /&gt;
&lt;/div&gt;

&lt;div&gt;
&lt;label&gt; &lt;input type="checkbox" id="Ctickets" value="3" checked /&gt;Child tickets: &lt;/label&gt;
How many: &lt;input type="text" id="Cquantity" value="1" size="3" /&gt;
&lt;br&gt;
&lt;label&gt; &lt;input type="checkbox" id="Atickets" value="8" checked /&gt;Adult tickets: &lt;/label&gt;
How many: &lt;input type="text" id="Aquantity" value="1" size="3" /&gt;

&lt;p&gt;&lt;input type="button" value="Purchase" onclick="printPrice()" /&gt;
&lt;/div&gt;

&lt;/form&gt;

&lt;div id="inserts"&gt; &lt;/div&gt;
&lt;/body&gt;
&lt;/html&gt;
<i>
:)
Copy linkTweet thisAlerts:
@hashim95Apr 21.2019 — hi JMRKER

4 hours agoJoined Dec '05

I want to ask you, how you can create a PHP page for Customer Details Form for the booking ticket website ?

thanks
Copy linkTweet thisAlerts:
@JMRKERApr 25.2019 — @hashim95#1602993

Sorry for the late reply. On the road on a short vacation.

To answer your questions about how to create a PHP page ... I have no idea. I have not yet programmed in PHP.

All suggestions I provided earlier were in HTML and javascript. Good luck though :)
×

Success!

Help @dean_ramsey spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 4.19,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,

tipper: @Samric24,
tipped: article
amount: 1000 SATS,
)...