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.
Page 1 of 2 12 LastLast
Results 1 to 15 of 21
  1. #1
    New Coder
    Join Date
    Oct 2003
    Posts
    46
    Thanks
    6
    Thanked 0 Times in 0 Posts

    Submit button on form not working

    Can anyone tell me why the submit button on this form does not work?

    See http://www.spendandgive.biz/original.php

    The form works perfectly on its own http://www.spendandgive.biz/table.php but not when I paste it in to the template.

  • #2
    Senior Coder timgolding's Avatar
    Join Date
    Aug 2006
    Location
    Southampton
    Posts
    1,519
    Thanks
    114
    Thanked 110 Times in 109 Posts
    its not nested inside a form tag for starters
    http://www.w3schools.com/TAGS/tag_form.asp
    You can not say you know how to do something, until you can teach it to someone else.

  • #3
    New Coder
    Join Date
    Oct 2003
    Posts
    46
    Thanks
    6
    Thanked 0 Times in 0 Posts
    That seems to have fixed it! Thanks.

    Anyone any idea why a number shows after I submit the form?

    www.spendandgive.biz/original1.php

  • #4
    Supreme Master coder! _Aerospace_Eng_'s Avatar
    Join Date
    Dec 2004
    Location
    In a place far, far away...
    Posts
    19,291
    Thanks
    2
    Thanked 1,043 Times in 1,019 Posts
    I can't seem to duplicate the "number" issue in your form.
    ||||If you are getting paid to do a job, don't ask for help on it!||||

  • #5
    New Coder
    Join Date
    Oct 2003
    Posts
    46
    Thanks
    6
    Thanked 0 Times in 0 Posts
    Okay you cant get past the validation step in IE, but as the validation doesnt work in FF you can get to the next step.

    Repro Steps

    1. Go to http://www.spendandgive.biz/original1.php in Firefox
    2. Select a shop
    3. Press the Submit (Spend and Give) button

    You will see that briefly a blank page with a number in the top left corner is displayed before you are redirected to the next page. This only displays for a couple of seconds at most so blink and you'll miss it!

  • #6
    Supreme Master coder! _Aerospace_Eng_'s Avatar
    Join Date
    Dec 2004
    Location
    In a place far, far away...
    Posts
    19,291
    Thanks
    2
    Thanked 1,043 Times in 1,019 Posts
    You will need to post the php for index.php
    ||||If you are getting paid to do a job, don't ask for help on it!||||

  • #7
    New Coder
    Join Date
    Oct 2003
    Posts
    46
    Thanks
    6
    Thanked 0 Times in 0 Posts
    PHP Code:
    <?  session_start();
    error_reporting(0);

    include 
    "config.php";
    include 
    "functions/functions.php";
    include 
    "db/db.inc.php";


    // delete selected
    echo $yo=$_REQUEST['shop'];
        if(
    $_POST['DelSel']){

             
    $var ="select * from ".SHOP." where shop_name = '".$_POST['search']."'";
            
    $ser=mysql_query$var );
            
    $rs1 mysql_fetch_array$ser );
            
            
        }
    // Activate selected
        
    if($_POST['ActSel']){

             
    $var1 ="select * from ".SHOP." where shop_id = '".$_POST['shop']."'";
            
    $ser1=mysql_query$var1 );
            
    $rs1 mysql_fetch_array$ser1 );
             
    $var2 ="select * from ".CHARITY." where charity_id = '".$_POST['charity']."'";
            
    $ser2=mysql_query$var2 );
            
    $rs2 mysql_fetch_array$ser2 );
             
    $peg1=$rs1['shop_url'];
             
    $peg2=$rs2['charity_url'];
             
    $peg=$peg1."".$peg2;
            {
            
    redirect($peg);
            }
            
            
            }
        
        

    ?>

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    <!--

    Design by Free CSS Templates
    http://www.freecsstemplates.org
    Released for free under a Creative Commons Attribution 2.5 License

    Title      : Cloudy
    Version    : 1.0
    Released   : 20081214
    Description: A two-column, fixed-width and lightweight template ideal for 1024x768 resolutions. Suitable for blogs and small websites.

    -->
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="content-type" content="text/html; charset=utf-8" />
    <title>Cloudy by Free Css Templates</title>
    <meta name="keywords" content="" />
    <meta name="description" content="" />
    <link href="default.css" rel="stylesheet" type="text/css" />
    </head>
    <body>
    <!-- start header -->
    <div id="wrapper">
    <div id="logo">
        <h1><a href="#">Cloudy </a></h1>
        <h2> &raquo;&nbsp;&nbsp;&nbsp;Design by Free Css Templates</h2>
        </div>

    <form id="form1" name="form1" method='post' action="index.php"  onSubmit="return validate2();">    

    <div><center><table width="713" border="0" cellpadding="2" cellspacing="2" bgcolor="#FFFFFF">
    <tr valign="top" height="50">
    <td><center>
    <font color="#000000">
    1. <select name='shop' class="bodytxt" size="1" id="shop_id" onChange="return select_server();">
                                                          <option>---Select your shop----</option>
                                                          <?php     $sql mysql_query("select * from ".SHOP." order by shop_name asc ") or die( mysql_error());
                                    while(
    $rs mysql_fetch_array$sql )){
                                
    ?>
                                <option value="<?=$rs['shop_id']?>"><?=$rs['shop_name']?></option>
                                   <?php
                                    
    }
                                
    ?>
                                                    </select>
                                                    
    </td>
    <td><center>
    <font color="#000000">
    2. <select name="charity" class="bodytxt" size="1">
                                                          <option>---Select your charity----</option>
                                                          <?php     $sql mysql_query("select * from ".CHARITY." order by charity_name asc ") or die( mysql_error());
                                    while(
    $rs mysql_fetch_array$sql )){
                                
    ?>
                                <option value="<?=$rs['charity_id']?>"><?=$rs['charity_name']?></option>
                                   <?php
                                    
    }
                                
    ?>
                                                      </select>

    </td>
    </tr>
    <tr valign="top" height="30">
    <TD COLSPAN="2"><center>

    <font color="#000000"><div id='ajaxDiv'></div></font>
     
    </td>
    </tr>

    </td>
    </tr>
    <tr valign="top" height="50">
    <TD COLSPAN="2"><center><br>
    <font color="#000000">
    3. <span class="smalltxt"><input name="ActSel" type="submit" class="black-text" id="active" value="Spend And Give">

    </td>
    </tr>
    </table>
    </center>
        </form>
        
    </div>
    <div id="header">
        <div id="menu">
            <ul>
                <li class="current_page_item"><a href="#">Homepage</a></li>
                <li><a href="#">Blogs</a></li>
                <li><a href="#">Photos</a></li>
                <li><a href="#">About</a></li>
                <li class="last"><a href="#">Contact</a></li>
            </ul>
        </div>
    </div>
    <!-- end header -->
    <!-- start page -->
    <div id="page">
        <!-- start content -->
        <div id="content">
            <div class="post">
                <h1 class="title">Welcome to our website </h1>
                <div class="entry">
                    <p>This is Cloudy, is a free template from <a href="http://freecsstemplates.org/">Free CSS Templates</a> released under a <a href="http://creativecommons.org/licenses/by/2.5/">Creative Commons Attribution 2.5 License</a>. The flower photo is fromt <a href="http://www.pdphoto.org/">PDPhoto.org</a>. You're free to use this template for both commercial or personal use. I only ask that you link back to <a href="http://freecsstemplates.org/">my site</a> in some way. Enjoy :)</p>
                </div>
                <div class="meta">
                    <p class="byline">Posted by FreeCssTemplates</p>
                    <p class="links"><a href="#" class="more">Read full article</a> &raquo;&nbsp;&nbsp;&nbsp;<a href="#" class="comments">Comments (32)</a></p>
                </div>
            </div>
            <div class="post">
                <h2 class="title">Lorem Ipsum Dolor Volutpat</h2>
                <div class="entry">
                    <p>Curabitur tellus. Phasellus tellus turpis, iaculis in, faucibus lobortis, posuere in, lorem. Donec a ante. Donec neque purus, adipiscing id, eleifend a, cursus vel, odio. Vivamus varius justo sit amet leo. Morbi sed libero. Vestibulum blandit augue at mi. Praesent fermentum lectus eget diam. Nam cursus, orci sit amet porttitor iaculis, ipsum massa aliquet nulla, non elementum mi elit a mauris. </p>
                </div>
                <div class="meta">
                    <p class="byline">Posted by FreeCssTemplates</p>
                    <p class="links"><a href="#" class="more">Read full article</a> &raquo;&nbsp;&nbsp;&nbsp;<a href="#" class="comments">Comments (32)</a></p>
                </div>
            </div>
        </div>
        <!-- end content -->
        <!-- start sidebar -->
        <div id="sidebar">
            <ul>
                <li id="search">
                    <h2>Search</h2>
                    <form method="get" action="">
                        <fieldset>
                        <input type="text" id="s" name="s" value="" />
                        <input type="submit" id="x" value="Search" />
                        </fieldset>
                    </form>
                </li>
                <li>
                    <h2>Lorem Ipsum</h2>
                    <ul>
                        <li><a href="#">Fusce dui neque fringilla</a></li>
                        <li><a href="#">Eget tempor eget nonummy</a></li>
                        <li><a href="#">Magna lacus bibendum mauris</a></li>
                        <li><a href="#">Nec metus sed donec</a></li>
                        <li><a href="#">Magna lacus bibendum mauris</a></li>
                        <li><a href="#">Velit semper nisi molestie</a></li>
                        <li><a href="#">Eget tempor eget nonummy</a></li>
                    </ul>
                </li>
                <li>
                    <h2>Volutpat Dolore</h2>
                    <ul>
                        <li><a href="#">Nec metus sed donec</a></li>
                        <li><a href="#">Magna lacus bibendum mauris</a></li>
                        <li><a href="#">Velit semper nisi molestie</a></li>
                        <li><a href="#">Eget tempor eget nonummy</a></li>
                        <li><a href="#">Nec metus sed donec</a></li>
                        <li><a href="#">Magna lacus bibendum mauris</a></li>
                        <li><a href="#">Velit semper nisi molestie</a></li>
                    </ul>
                </li>
            </ul>
        </div>
        <!-- end sidebar -->
        <div style="clear: both;">&nbsp;</div>
    </div>
    <!-- end page -->
    <!-- start footer -->
    <div id="footer">
        <p id="legal">( c ) 2008. All Rights Reserved. <a href="http://www.freecsstemplates.org/">Bestfriends</a> designed by <a href="http://www.freecsstemplates.org/">Free CSS Templates</a>.</p>
    </div>
    </div>
    <!-- end footer -->
    </body>
    </html>

    <script>

        function validate2(){
            
            if(document.form1.shop.value == ''){
                alert('Please select shop!!');
                document.form1.shop.focus();
                return false;
            }
            if(document.form1.charity.value == ''){
                alert('Please select Charity');
                document.form1.charity.focus();
                return false;
            }
        
        
                            
    }
    </script>

    <script>
    // ajax
        var http = getHTTPObject();
       var url = "azax_select.php?server_id="; 


    function getHTTPObject() { 
      var xmlhttp; 

      if(window.XMLHttpRequest){ 
        xmlhttp = new XMLHttpRequest(); 
      } 
      else if (window.ActiveXObject){ 
        xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); 
        if (!xmlhttp){ 
            xmlhttp=new ActiveXObject("Msxml2.XMLHTTP"); 
        } 
        

      return xmlhttp; 
    }

    function appendOptionLast(num)
    {
      var elOptNew = document.createElement('option');
      elOptNew.text = '---' + num + '---';
      elOptNew.value = num;
      var elSel = document.getElementById('shop_id');
      try {
        elSel.add(elOptNew, null); // standards compliant; doesn't work in IE
      }
      catch(ex) {
        elSel.add(elOptNew); // IE only
      }
    }

    function removeOptionLast(num)
    {
        var elSel = document.getElementById('shop_id');
        
        for(var i=num-1;i>=0;i--)
        {
        
        elSel.remove(i);    
        }
    }

     
    function select_server() 
    {   
        var sId =document.getElementById('shop_id').value;
        var full_url = url+escape(sId);
                
        http.open("GET",full_url,true); 
        http.onreadystatechange = handleHttpResponse; 
        http.send(null); 
     } 
        

    function handleHttpResponse()
     {        
        if (http.readyState == 4)
         {
             if(http.status==200)
             {             
                var results=http.responseText;    
            
                var num;
                //var elOptNew = document.createElement('option');
         
                //var elSel = document.getElementById('shop_id');
                var ajaxDisplay = document.getElementById('ajaxDiv');
                ajaxDisplay.innerHTML = http.responseText;

                num=results.split(",");                
                
                if(elSel.length>0)
                {
        
                removeOptionLast(elSel.length);
                
              }
                for(var i=0;i<num.length;i++)
                {
                    appendOptionLast(num[i]);                                    
                }
                
              
            
        } 
       } 

            

    </script>

  • #8
    Supreme Master coder! _Aerospace_Eng_'s Avatar
    Join Date
    Dec 2004
    Location
    In a place far, far away...
    Posts
    19,291
    Thanks
    2
    Thanked 1,043 Times in 1,019 Posts
    What are you doing here?
    PHP Code:
            {
            
    redirect($peg);
            } 
    There is no conditional statement belonging to those brackets so it should be erroring out. Please post the code for your redirect function. Also I suggest you look into mysql injection: http://www.tizag.com/mysqlTutorial/m...-injection.php
    ||||If you are getting paid to do a job, don't ask for help on it!||||

  • #9
    New Coder
    Join Date
    Oct 2003
    Posts
    46
    Thanks
    6
    Thanked 0 Times in 0 Posts
    I didnt code this, it was outsourced as my skills dont stretch much beyond basic HTML/CSS.

    Im having server problems at the moment but once we're back up I'll get you the rest of the code. I have a functions.php which I guess is what you're after.

  • #10
    Supreme Master coder! _Aerospace_Eng_'s Avatar
    Join Date
    Dec 2004
    Location
    In a place far, far away...
    Posts
    19,291
    Thanks
    2
    Thanked 1,043 Times in 1,019 Posts
    Whoever you paid did a poor job in taking security into account. I recommend not using them again for their services.
    ||||If you are getting paid to do a job, don't ask for help on it!||||

  • #11
    New Coder
    Join Date
    Oct 2003
    Posts
    46
    Thanks
    6
    Thanked 0 Times in 0 Posts
    I paid £30 to an Indian, but you get what you pay for I guess!

  • #12
    Senior Coder timgolding's Avatar
    Join Date
    Aug 2006
    Location
    Southampton
    Posts
    1,519
    Thanks
    114
    Thanked 110 Times in 109 Posts
    I could of found you a far better programmer for £30 an hour. You really need to fix those queries. It hurts my eyes to look at those. Read the article about mysql_injections that _Aerospace_Eng_ posted. And look at http://uk.php.net/manual/en/function...ape-string.php. Its really just a case of real escaping or (validating) your post data. I suggest you fix this fast. As you've just posted a link to your insecure site and shown us the insecure code. Therefore any hacker that looks at this thread can either completely destroy (drop) your database, empty it or gain access to any information stored in it. I could do it now if i was hacker would take me 5 minutes.

    If you really think you can't cope with doing it yourself I will provide the codes myself free of charge. It hurts my eyes that much lol
    You can not say you know how to do something, until you can teach it to someone else.

  • #13
    New Coder
    Join Date
    Oct 2003
    Posts
    46
    Thanks
    6
    Thanked 0 Times in 0 Posts
    I paid £30 for the whole project, not per hour, or maybe you mean this could be done in an hour...

  • #14
    Senior Coder timgolding's Avatar
    Join Date
    Aug 2006
    Location
    Southampton
    Posts
    1,519
    Thanks
    114
    Thanked 110 Times in 109 Posts
    PHP Code:
    <?  
    function escape_str($string) {

                if ( 
    function_exists('mysql_real_escape_string') ) {
     
                return 
    mysql_real_escape_stringstripslashes($string) );
     
            } else {
     
                return 
    addslashesstripslashes($string) );
     
            }
     
        }

    session_start();
    error_reporting(0);

    include 
    "config.php";
    include 
    "functions/functions.php";
    include 
    "db/db.inc.php";


    // delete selected
    echo $yo=$_REQUEST['shop'];
        if(
    $_POST['DelSel']){
                    
    //Bit concerned about SHOP and CHARITY but aslong as these are defined with hardcoded strings and not post data will be fine.
                   // but would need access to these definitions to be sure. If they are coming from POST i got a backticker somewhere  
             
    $var ="select * from ".SHOP." where shop_name = '".escape_str($_POST['search'])."'";
            
    $ser=mysql_query$var );
            
    $rs1 mysql_fetch_array$ser );
            
            
        }
    // Activate selected
        
    if($_POST['ActSel']){

             
    $var1 ="select * from ".SHOP." where shop_id = '".escape_str($_POST['shop'])."'";
            
    $ser1=mysql_query$var1 );
            
    $rs1 mysql_fetch_array$ser1 );
             
    $var2 ="select * from ".CHARITY." where charity_id = '".escape_str($_POST['charity'])."'";
            
    $ser2=mysql_query$var2 );
            
    $rs2 mysql_fetch_array$ser2 );
             
    $peg1=$rs1['shop_url'];
             
    $peg2=$rs2['charity_url'];
             
    $peg=$peg1."".$peg2;
            {
            
    redirect($peg);
            }
            
            
            }
        
        

    ?>

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    <!--

    Design by Free CSS Templates
    http://www.freecsstemplates.org
    Released for free under a Creative Commons Attribution 2.5 License

    Title      : Cloudy
    Version    : 1.0
    Released   : 20081214
    Description: A two-column, fixed-width and lightweight template ideal for 1024x768 resolutions. Suitable for blogs and small websites.

    -->
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="content-type" content="text/html; charset=utf-8" />
    <title>Cloudy by Free Css Templates</title>
    <meta name="keywords" content="" />
    <meta name="description" content="" />
    <link href="default.css" rel="stylesheet" type="text/css" />
    </head>
    <body>
    <!-- start header -->
    <div id="wrapper">
    <div id="logo">
        <h1><a href="#">Cloudy </a></h1>
        <h2> &raquo;&nbsp;&nbsp;&nbsp;Design by Free Css Templates</h2>
        </div>

    <form id="form1" name="form1" method='post' action="index.php"  onSubmit="return validate2();">    

    <div><center><table width="713" border="0" cellpadding="2" cellspacing="2" bgcolor="#FFFFFF">
    <tr valign="top" height="50">
    <td><center>
    <font color="#000000">
    1. <select name='shop' class="bodytxt" size="1" id="shop_id" onChange="return select_server();">
                                                          <option>---Select your shop----</option>
                                                          <?php     $sql mysql_query("select * from ".SHOP." order by shop_name asc ") or die( mysql_error());
                                    while(
    $rs mysql_fetch_array$sql )){
                                
    ?>
                                <option value="<?=$rs['shop_id']?>"><?=$rs['shop_name']?></option>
                                   <?php
                                    
    }
                                
    ?>
                                                    </select>
                                                    
    </td>
    <td><center>
    <font color="#000000">
    2. <select name="charity" class="bodytxt" size="1">
                                                          <option>---Select your charity----</option>
                                                          <?php     $sql mysql_query("select * from ".CHARITY." order by charity_name asc ") or die( mysql_error());
                                    while(
    $rs mysql_fetch_array$sql )){
                                
    ?>
                                <option value="<?=$rs['charity_id']?>"><?=$rs['charity_name']?></option>
                                   <?php
                                    
    }
                                
    ?>
                                                      </select>

    </td>
    </tr>
    <tr valign="top" height="30">
    <TD COLSPAN="2"><center>

    <font color="#000000"><div id='ajaxDiv'></div></font>
     
    </td>
    </tr>

    </td>
    </tr>
    <tr valign="top" height="50">
    <TD COLSPAN="2"><center><br>
    <font color="#000000">
    3. <span class="smalltxt"><input name="ActSel" type="submit" class="black-text" id="active" value="Spend And Give">

    </td>
    </tr>
    </table>
    </center>
        </form>
        
    </div>
    <div id="header">
        <div id="menu">
            <ul>
                <li class="current_page_item"><a href="#">Homepage</a></li>
                <li><a href="#">Blogs</a></li>
                <li><a href="#">Photos</a></li>
                <li><a href="#">About</a></li>
                <li class="last"><a href="#">Contact</a></li>
            </ul>
        </div>
    </div>
    <!-- end header -->
    <!-- start page -->
    <div id="page">
        <!-- start content -->
        <div id="content">
            <div class="post">
                <h1 class="title">Welcome to our website </h1>
                <div class="entry">
                    <p>This is Cloudy, is a free template from <a href="http://freecsstemplates.org/">Free CSS Templates</a> released under a <a href="http://creativecommons.org/licenses/by/2.5/">Creative Commons Attribution 2.5 License</a>. The flower photo is fromt <a href="http://www.pdphoto.org/">PDPhoto.org</a>. You're free to use this template for both commercial or personal use. I only ask that you link back to <a href="http://freecsstemplates.org/">my site</a> in some way. Enjoy :)</p>
                </div>
                <div class="meta">
                    <p class="byline">Posted by FreeCssTemplates</p>
                    <p class="links"><a href="#" class="more">Read full article</a> &raquo;&nbsp;&nbsp;&nbsp;<a href="#" class="comments">Comments (32)</a></p>
                </div>
            </div>
            <div class="post">
                <h2 class="title">Lorem Ipsum Dolor Volutpat</h2>
                <div class="entry">
                    <p>Curabitur tellus. Phasellus tellus turpis, iaculis in, faucibus lobortis, posuere in, lorem. Donec a ante. Donec neque purus, adipiscing id, eleifend a, cursus vel, odio. Vivamus varius justo sit amet leo. Morbi sed libero. Vestibulum blandit augue at mi. Praesent fermentum lectus eget diam. Nam cursus, orci sit amet porttitor iaculis, ipsum massa aliquet nulla, non elementum mi elit a mauris. </p>
                </div>
                <div class="meta">
                    <p class="byline">Posted by FreeCssTemplates</p>
                    <p class="links"><a href="#" class="more">Read full article</a> &raquo;&nbsp;&nbsp;&nbsp;<a href="#" class="comments">Comments (32)</a></p>
                </div>
            </div>
        </div>
        <!-- end content -->
        <!-- start sidebar -->
        <div id="sidebar">
            <ul>
                <li id="search">
                    <h2>Search</h2>
                    <form method="get" action="">
                        <fieldset>
                        <input type="text" id="s" name="s" value="" />
                        <input type="submit" id="x" value="Search" />
                        </fieldset>
                    </form>
                </li>
                <li>
                    <h2>Lorem Ipsum</h2>
                    <ul>
                        <li><a href="#">Fusce dui neque fringilla</a></li>
                        <li><a href="#">Eget tempor eget nonummy</a></li>
                        <li><a href="#">Magna lacus bibendum mauris</a></li>
                        <li><a href="#">Nec metus sed donec</a></li>
                        <li><a href="#">Magna lacus bibendum mauris</a></li>
                        <li><a href="#">Velit semper nisi molestie</a></li>
                        <li><a href="#">Eget tempor eget nonummy</a></li>
                    </ul>
                </li>
                <li>
                    <h2>Volutpat Dolore</h2>
                    <ul>
                        <li><a href="#">Nec metus sed donec</a></li>
                        <li><a href="#">Magna lacus bibendum mauris</a></li>
                        <li><a href="#">Velit semper nisi molestie</a></li>
                        <li><a href="#">Eget tempor eget nonummy</a></li>
                        <li><a href="#">Nec metus sed donec</a></li>
                        <li><a href="#">Magna lacus bibendum mauris</a></li>
                        <li><a href="#">Velit semper nisi molestie</a></li>
                    </ul>
                </li>
            </ul>
        </div>
        <!-- end sidebar -->
        <div style="clear: both;">&nbsp;</div>
    </div>
    <!-- end page -->
    <!-- start footer -->
    <div id="footer">
        <p id="legal">( c ) 2008. All Rights Reserved. <a href="http://www.freecsstemplates.org/">Bestfriends</a> designed by <a href="http://www.freecsstemplates.org/">Free CSS Templates</a>.</p>
    </div>
    </div>
    <!-- end footer -->
    </body>
    </html>

    <script>

        function validate2(){
            
            if(document.form1.shop.value == ''){
                alert('Please select shop!!');
                document.form1.shop.focus();
                return false;
            }
            if(document.form1.charity.value == ''){
                alert('Please select Charity');
                document.form1.charity.focus();
                return false;
            }
        
        
                            
    }
    </script>

    <script>
    // ajax
        var http = getHTTPObject();
       var url = "azax_select.php?server_id="; 


    function getHTTPObject() { 
      var xmlhttp; 

      if(window.XMLHttpRequest){ 
        xmlhttp = new XMLHttpRequest(); 
      } 
      else if (window.ActiveXObject){ 
        xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); 
        if (!xmlhttp){ 
            xmlhttp=new ActiveXObject("Msxml2.XMLHTTP"); 
        } 
        

      return xmlhttp; 
    }

    function appendOptionLast(num)
    {
      var elOptNew = document.createElement('option');
      elOptNew.text = '---' + num + '---';
      elOptNew.value = num;
      var elSel = document.getElementById('shop_id');
      try {
        elSel.add(elOptNew, null); // standards compliant; doesn't work in IE
      }
      catch(ex) {
        elSel.add(elOptNew); // IE only
      }
    }

    function removeOptionLast(num)
    {
        var elSel = document.getElementById('shop_id');
        
        for(var i=num-1;i>=0;i--)
        {
        
        elSel.remove(i);    
        }
    }

     
    function select_server() 
    {   
        var sId =document.getElementById('shop_id').value;
        var full_url = url+escape(sId);
                
        http.open("GET",full_url,true); 
        http.onreadystatechange = handleHttpResponse; 
        http.send(null); 
     } 
        

    function handleHttpResponse()
     {        
        if (http.readyState == 4)
         {
             if(http.status==200)
             {             
                var results=http.responseText;    
            
                var num;
                //var elOptNew = document.createElement('option');
         
                //var elSel = document.getElementById('shop_id');
                var ajaxDisplay = document.getElementById('ajaxDiv');
                ajaxDisplay.innerHTML = http.responseText;

                num=results.split(",");                
                
                if(elSel.length>0)
                {
        
                removeOptionLast(elSel.length);
                
              }
                for(var i=0;i<num.length;i++)
                {
                    appendOptionLast(num[i]);                                    
                }
                
              
            
        } 
       } 

            

    </script>
    Last edited by timgolding; 05-12-2009 at 05:29 PM.
    You can not say you know how to do something, until you can teach it to someone else.

  • Users who have thanked timgolding for this post:

    tomraffe (05-19-2009)

  • #15
    New Coder
    Join Date
    Oct 2003
    Posts
    46
    Thanks
    6
    Thanked 0 Times in 0 Posts
    Server back up, we still have the problem of the number being displayed after the form is submitted. See above for repro steps.

    http://www.twrnet.co.uk/spendandgive.biz/


  •  
    Page 1 of 2 12 LastLast

    Posting Permissions

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