wrathican Posted July 19, 2007 Share Posted July 19, 2007 from the title this may sound simple. and to be honest i am a complete newb to JS and i have been redirected here by someone in the php section but i have my form and everything works perfectly. i want to add a new feature in. my form is a booking form where a user can book an activity. i have it linked to a mysql database so that there is a combo box with the titles of the activites, also in the table is the price of the activity. what i want to happen is when the user selects one of the activities i want the price for that particular activity to be shown in a non-editable input box so that it can be passed onto the email send script. any ideas on how i can do this? also i want something for a date selector. since there are not the same amount of days in each month i want my form to be able to determine what month the user selected and then the right amount of days show in the day combo box. for example if the user selects february in the month box, the day list should only go up to 28. then maybe when the user selects 2008 (the next year to be a leap year) the days in feb goes up to 29. suggestions would be awesome! thanks for reading! Quote Link to comment Share on other sites More sharing options...
RichardRotterdam Posted July 19, 2007 Share Posted July 19, 2007 what i want to happen is when the user selects one of the activities i want the price for that particular activity to be shown in a non-editable input box Do you mean you want this price to be in a hidden input? Or do you wish to show the costumer the price of an activity? If you just want to show it you shouldn't use an input tag for security reasons Quote Link to comment Share on other sites More sharing options...
wrathican Posted July 19, 2007 Author Share Posted July 19, 2007 wi want the customer to be able to see the price of the activity yes. but i want it to be still stored in a variable to i can send it to the next script Quote Link to comment Share on other sites More sharing options...
RichardRotterdam Posted July 19, 2007 Share Posted July 19, 2007 if your using your page for commercial goals i seriously recommends you don't pass the price to another page using a hidden input or normal input since anyone can just alter the price by saving the page to their drive and post different value's. I know for sure that i could do every activity for free then. But anyway to your problem. to show the price in a div when you selected a activity from the selectbox without refreshing the page you can use the following code. It's just a little something that gets you on your way. You will need to follow an ajax tutorial to complete the code which there are plenty of online even on phpfreaks.com. Read the comments how it works it should be a good start <script> function getPrice(activityValue){ //in this function you will have to do a call to an external AKA ajax that gets the price //alert(activityValue); //this is how to set the html inside the price_div document.getElementById('price_div').innerHTML=activityValue; } </script> <br /> <select onchange="getPrice(this.value)"> <option value="1">activity 1</option> <option value="2">activity 2</option> <option value="3">activity 3</option> </select> <br /> <b>function will place the value inside the following div</b> <div style="heigth:20px;width:100px;border-width:1px;border-color:#000000;border-style:solid;" id="price_div"> </div> Quote Link to comment Share on other sites More sharing options...
wrathican Posted July 20, 2007 Author Share Posted July 20, 2007 well the user is not going to pay online this justs sends an email to my clientalerting him that someone wishes to book this activity, its more for convenience sakes than anything. it saves my client having to find out the price of the activity himself. but thatnks for the advice. ill have a look and see how i get on with it Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.