Jump to content

Php and Javascript


flyersun

Recommended Posts

I asked about this a while ago didn't really get anywhere with the project. Now I've working on it again I've pretty much got the whole thin worked out in my head I only have one problem which I'm hoping to get some help with.

 

Here's the problem.

 

The site is a quotation system for a travel insurance company. I need the information on the form to change depending on what sort of trip  is selected from a drop down menu. I know this is done using the on select java script fuction.. but I don't know where to go from there. I would normaly just go find the js on the web but I'm not even really sure what I'm looking for.

 

 

Link to comment
Share on other sites

You want to research the HtmlDOM.

 

There's two basics approach you can take:

 

1)  You send all of the possible changes to the form in a single document as hidden page elements.  As the drop down changes, you use the DOM to move the hidden elements into their visible positions on the page.  How useful this approach is depends on how much dynamic content there is.  If you're only talking about two hidden list boxes, each with 10 to 20 items, and based on another drop down selection one of them is displayed, this method is fine.  If there's lots of possibilities of which dynamic information to display and there's a good chance most of it will never be displayed, you'll want to go with approach #2.

 

2)  Use AJAX.  There's an AJAX discussion area on these forums to help you out with this as well as useful information at the w3schools website.  The basic concept is as the user interacts with the form, you use javascript to make requests to the server.  Javascript on the page will be called when the server finishes the request and your page can process the results, such as inserting dynamic HTML elsewhere in the page.  Typically, when the user changes a field you'd send their input to the server and the server would respond with possibly more form content; you then use the DOM to stick this content into your page.

 

HtmlDOM

http://www.w3schools.com/htmldom/default.asp

 

Javascript

http://www.w3schools.com/js/default.asp

 

AJAX

http://www.w3schools.com/ajax/default.asp

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.