Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5
  1. #1
    New to the CF scene
    Join Date
    Oct 2004
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    client side refresh using JavaScript

    Hi guys,

    I have coded a page using a mixture of PHP, MYSQL, HTML. Basically it is a form where the user makes a selections from a series of radio buttons, everytime the user makes a selection it updates the total, pretty simple. The problem is the refresh is way to long for every item selected, I've heard using javascript you can nearly eliminate the refresh time by making the code execute client side. I cannot find any books, guides, or sample code related this particular problem. Help would be greatly appreciated. Thanks.

  • #2
    Regular Coder
    Join Date
    Jul 2004
    Location
    mile high city
    Posts
    482
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Javascript makes use of event handlers that often make it unnecessary to do any type of refresh when reacting to user input.

    Here's a quick example:
    Code:
    <form>
      <label for="yes">Yes</label><input name="pick_one" type="radio" value="Yes" id="yes" onclick="alert('You clicked yes!');">
      <label for="no">No</label><input name="pick_one" type="radio" value="No" id="no" onclick="alert('You clicked no!');">
    </form>
    To elaborate, you could total your user's input by replacing the alert with a calculation function relevant to what you're doing.

    For more info, here's a link to get you going.

    And welcome to the forums.
    Last edited by mcdougals4all; 10-28-2004 at 09:30 PM. Reason: more info
    Computer, kill Flanders... Did I hear my name? My ears are burning...
    Good start. Now finish the job.

  • #3
    New to the CF scene
    Join Date
    Oct 2004
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thanks for the help. Event handlers are awesome, these should work perfectly. Now I have a very "newb" question. What is the propper syntax for printing my variables(.$Warranty) value($100) using event handlers in javascript? I see ways of using alerts, and changing the color of things. But cannot find the syntax to just print and add together values (everytime the user selects a new radio box in a section, it needs to add to the previouse radio boxes selected). Is this even possible using even handlers? Thanks again!


    <form>
    <label for="yes">Yes</label><input name="pick_one" type="radio" value="Yes" id="yes" onclick="alert('You clicked yes!');">
    <label for="no">No</label><input name="pick_one" type="radio" value="No" id="no" onclick="alert('You clicked no!');">
    </form>

  • #4
    New to the CF scene
    Join Date
    Oct 2004
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Ignore the code below my last post. I did not mean to repost the code. Oops

  • #5
    New to the CF scene
    Join Date
    Oct 2004
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Actually that worked great. I I'm not completely done now, but I'm well on my way. Thanks a ton!!!


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •