SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Guru
    Join Date
    Oct 2004
    Location
    uk
    Posts
    853
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    form loses data when selected

    Hi guys

    Having a bit if a issue with my form


    This is my javascript, the problem is when a user selects a option in the dropdown box, it resets the whole form so they are all blank

    How can I keep it from doing this?

    PHP Code:
    <form method="post" action="<?php print $_SELF?>">
    <input type="hidden" name="op" value="contact">

    <br>
    <br>
    <TABLE width="100%">
    <Tr>
    <td width="100%">
    <font size="3" face="century gothic">
    </td>
    </tR>
    <TR>
    <TD> 
    <font face="century gothic" size="4">Catergory:</TD><TD>

     <?
     $cat
    =$_POST['category'];
    @
    $cat=$_GET['category']; 
    $quer2=mysql_query("SELECT DISTINCT category,cat_id FROM category order by category"); 
    echo 
    "<select name='category'>
    <option value=''>------------------------ Please select a category ---------------------------</option>"
    ;
    while(
    $noticia2 mysql_fetch_array($quer2)) { 
    if(
    $noticia2['cat_id']==@$cat){echo "<option selected value='$noticia2[cat_id]'>$noticia2[category]</option>"."<BR>";}
    else{echo  
    "<option value='$noticia2[cat_id]'>$noticia2[category]</option>";}
    }


    ?>


    </TD><td valign="top"><img src="required.gif"></td></TR>
    <TR><TD><font face="century gothic" size="4">Location:</TD><TD> 
     <?
     $cat
    =$_POST['location'];
    $subcat=$_POST['sublocation'];
    /*
    If register_global is off in your server then after reloading of the page to get the value of cat from query string we have to take special care.
    To read more on register_global visit.
      http://www.plus2net.com/php_tutorial/register-globals.php
    */
    @$cat=$_GET['location']; // Use this line or below line if register_global is off
    //@$cat=$HTTP_GET_VARS['location']; // Use this line or above line if register_global is off

    ///////// Getting the data from Mysql table for first list box//////////
    $quer2=mysql_query("SELECT DISTINCT location,cat_id FROM location order by location"); 
    ///////////// End of query for first list box////////////



    /////// for second drop down list we will check if category is selected else we will display all the subcategory///// 
    if(isset($cat) and strlen($cat) > 0){



    $quer=mysql_query("SELECT DISTINCT sublocation FROM sublocation where cat_id=$cat order by sublocation"); 
    }else{
    $quer=mysql_query("SELECT DISTINCT sublocation FROM sublocation order by sublocation"); } 
    ////////// end of query for second subcategory drop down list box ///////////////////////////


    /// Add your form processing page address to action in above line. Example  action=dd-check.php////
    //////////        Starting of first drop downlist /////////
    echo "<select name='location' onchange=\"reload(this.form)\">
    <option value=''>------------------------ Please select a Location ---------------------------</option>"
    ;
    while(
    $noticia2 mysql_fetch_array($quer2)) { 
    if(
    $noticia2['cat_id']==@$cat){echo "<option selected value='$noticia2[cat_id]'>$noticia2[location]</option>"."<BR>";}
    else{echo  
    "<option value='$noticia2[cat_id]'>$noticia2[location]</option>";}
    }
    echo 
    "</select></TD></TR><TR><TD><font size=4>Sub Location</td><td>";
    //////////////////  This will end the first drop down list ///////////

    //////////        Starting of second drop downlist /////////
    echo "<select name='sublocation'>
    <option value=''>---------------------- Please select a Sub Location ----------------------</option>"
    ;
    while(
    $noticia mysql_fetch_array($quer)) { 
    echo  
    "<option value='$noticia[sublocation]'>$noticia[sublocation]</option>";
    }
    echo 
    "</select>";
    //////////////////  This will end the second drop down list ///////////


    ?>


    </TD>
    <td valign="top"><img src="required.gif"></td></TR>

    <TR><TD><font face="century gothic" size="4">Job Title: </TD>
    <TD><input type="text" size="60" name="jobtitle" value="<?php echo "$jobtitle?>" /></TD>
    <td valign="top"><img src="required.gif"></td></TR>
    <TR><TD valign="top"><font face="century gothic" size="4">Job Description:</TD>
    <TD> <textarea rows="15" cols="45" name="jobdescription" wrap="physical" value="<? htmlspecialchars($_POST['jobdescription']); ?>"></textarea><br /></TD>
    <td valign="top"><img src="required.gif"></td></TR>





    <TR><TD><font face="century gothic" size="4">Salary: </TD><TD>
     <select name="salary">
    <?php if(isset($_POST['salary'])) { ?> 
    <option value="<?php echo htmlspecialchars($_POST['salary']); ?>" selected><?php echo htmlspecialchars($_POST['salary']); ?></option>
    <??> 
        <option value="">-------------------------- Please select a Salary --------------------------- </option>
    <option value="0 - 9,999">0 - 9,999</option>
    <option value="10,000 - 11,999">10,000 - 11,999</option>
    <option value="12,000 - 13,999">12,000 - 13,999</option>
    <option value="14,000 - 15,999">14,000 - 15,999</option>
    <option value="16,000 - 17,999">16,000 - 17,999</option>
    <option value="18,000 - 19,999">18,000 - 19,999</option>
    <option value="20,000 - 23,999">20,000 - 23,999</option>
    <option value="24,000 - 27,999">24,000 - 27,999</option>
    <option value="28,000 - 31,999">28,000 - 31,999</option>
    <option value="32,000 - 35,999">32,000 - 35,999</option>
    <option value="36,000 - 39,999">36,000 - 39,999</option>
    <option value="40,000 - 49,999">40,000 - 49,999</option>
    <option value="50,000 - ">50,000 - </option>

    </select></TD><td valign="top"><img src="required.gif"></td></TR>
    <TR><TD><font face="century gothic" size="4">Job Status:</TD><TD>
     <select name="jobstatus">
    <?php if(isset($_POST['jobstatus'])) { ?> 
    <option value="<?php echo htmlspecialchars($_POST['jobstatus']); ?>" selected><?php echo htmlspecialchars($_POST['jobstatus']); ?></option>
    <??> 
        <option value="">----------------------- Please select a Job Status ------------------------ </option>
    <option value="Permanent">Permanent</option>
    <option value="Part Time">Part Time</option>
    <option value="Temporary">Temporary</option>

    </select></TD><td valign="top"><img src="required.gif"></td></TR>
    <tr><td><font face="century gothic" size="4"><b>Contact Info</b></td></tr>
    <TR><TD><font face="century gothic" size="4">Company:</TD><TD><input type="text" size="60" name="company" value="<?php echo "$company?>" /></TD><td valign="top"><img src="required.gif"></td></TR>
    <TR><TD><font face="century gothic" size="4">First Name:</TD><TD><input type="text" size="60" name="firstname" value="<?php echo "$firstname?>" /></TD><td valign="top"><img src="required.gif"></td></TR>
    <TR><TD><font face="century gothic" size="4">Surname:</TD><TD><input type="text" size="60" name="surname" value="<?php echo "$surname?>" /></TD><td valign="top"><img src="required.gif"></td></TR>
    <TR><TD><font face="century gothic" size="4">E Mail:</TD><TD><input type="text" size="60" name="email" value="<?php echo "$email?>" /></TD><td valign="top"><img src="required.gif"></td></TR>
    <TR><TD><font face="century gothic" size="4">Telephone:</TD><TD><input type="text" size="60" name="telephone" value="<?php echo "$telephone?>" /></TD><td valign="top"><img src="required.gif"></td></TR>
    <TR><TD><font face="century gothic" size="4">Fax:</TD><TD><input type="text" size="60" name="fax" value="<?php echo "$fax?>" /></TD><td valign="top"><img src="required.gif"></td></TR>
    </table>
    <table width="100%">
    <tr><td><font face="century gothic" size="4"><b>Payment Info</b></td></tr>
    <TR><td>
    The cost to list your job is <b>1</b> credit<br> This will automatically be deducted from your account
    <br>
    If your account has no credits you will be redirected to our payment page

    </td></TR>
    <TR>
    <TD>
    </TD>
    <TD>


    <input type="hidden" name="custom" value="id">
    <input type="submit" value="Submit Job" />
    </form>

  2. #2
    SitePoint Zealot
    Join Date
    Sep 2005
    Posts
    159
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    No idea but I wouldn't recommend using font tags.

  3. #3
    SitePoint Guru
    Join Date
    Oct 2004
    Location
    uk
    Posts
    853
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    that doesn't really help me


Bookmarks

Posting Permissions

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