Click here to Skip to main content
15,884,838 members
Home / Discussions / Web Development
   

Web Development

 
QuestionNeed to manipulate an excel file using MS Office SDK Pin
Sebastian T Xavier22-Oct-09 18:43
Sebastian T Xavier22-Oct-09 18:43 
QuestionCan't get a simple IF statement to work Pin
dennisw1122-Oct-09 10:52
dennisw1122-Oct-09 10:52 
AnswerRe: Can't get a simple IF statement to work Pin
Wes Aday22-Oct-09 11:22
professionalWes Aday22-Oct-09 11:22 
AnswerRe: Can't get a simple IF statement to work Pin
dennisw1123-Oct-09 3:02
dennisw1123-Oct-09 3:02 
GeneralRe: Can't get a simple IF statement to work Pin
David Skelly23-Oct-09 6:53
David Skelly23-Oct-09 6:53 
GeneralRe: Can't get a simple IF statement to work Pin
dennisw1123-Oct-09 7:09
dennisw1123-Oct-09 7:09 
QuestionObject Data Source Configuration Error Pin
RB@Emphasys22-Oct-09 8:54
RB@Emphasys22-Oct-09 8:54 
QuestionHow do I keep data on form when page is refreshed? Pin
nickbtheitguy22-Oct-09 5:25
nickbtheitguy22-Oct-09 5:25 
I haven't touched any programming language in almost 10 years. I have a small project that I am working on and I have run into a small snag that I haven't been able to figure out. I have a form that contains several elements and 5 of these are drop down boxes that get populated from a database. They are dependant on each other. I have been able to successfully update my drop downs from the information in the database depending on what is selected in each box.

The problem that I am running into is that if I have information entered in any of the textboxes on the form and then use the drop down, that information is lost. I want to keep this information on the form until the submit button is hit. I have included my existing code. Any suggestions would be greatly appreciated.

I'm not sure why posting this has converted my < and > to extended characters.

<pre>
&lt;?php

include("functions.php");

// server info
$server = "";
$user = "";
$password = "";
$db = "";

// server connection string
$dbconnect = mssql_connect($server, $user, $password)
     or die("Couldn't connect to the Heat server.");

// db select string
$selectdb = mssql_select_db($db, $dbconnect)
     or die("Coudn't open the Heat database.");
    

?&gt;

&lt;html&gt;

&lt;head&gt;
&lt;title&gt;Heat Legacy : Advanced Search&lt;/title&gt;

&lt;link rel="stylesheet" href="css/heat.css" type="text/css" media="screen" /&gt;
&lt;script type="text/javascript" src="js/jquery.js"&gt;&lt;/script&gt;
&lt;script type="text/javascript" src="js/jquery.searchbox.js"&gt;&lt;/script&gt;

&lt;script type="text/javascript"&gt;


     function depReload(form)
     {
          var val1=form.dep.options[form.dep.options.selectedIndex].value;
          self.location='form_search.php?dep=' + val1 ;
     }

     function d1Reload(form)
     {
          var val1=form.dep.options[form.dep.options.selectedIndex].value;
          var val2=form.d1.options[form.d1.options.selectedIndex].value;
          self.location='form_search.php?dep=' + val1 + '&amp;d1=' + val2 ;
     }

     function d2Reload(form)
     {
          var val1=form.dep.options[form.dep.options.selectedIndex].value;
          var val2=form.d1.options[form.d1.options.selectedIndex].value;
          var val3=form.d2.options[form.d2.options.selectedIndex].value;
          self.location='form_search.php?dep=' + val1 + '&amp;d1=' + val2 + '&amp;d2=' + val3 ;
     }

     function d3Reload(form)
     {
          var val1=form.dep.options[form.dep.options.selectedIndex].value;
          var val2=form.d1.options[form.d1.options.selectedIndex].value;
          var val3=form.d2.options[form.d2.options.selectedIndex].value;
          var val4=form.d3.options[form.d3.options.selectedIndex].value;
          self.location='form_search.php?dep=' + val1 + '&amp;d1=' + val2 + '&amp;d2=' + val3 +  
'&amp;d3=' + val4 ;
     }


&lt;/script&gt;
&lt;/head&gt;

&lt;body class='aformbody'&gt;
&lt;?php

@$dep = $_GET['dep'];
@$d1 = $_GET['d1'];
@$d2 = $_GET['d2'];
@$d3 = $_GET['d3'];


// Call Type drop down.
$query1=mssql_query("SELECT DISTINCT calltype FROM calltype order by calltype");

// Query to displays Drop1 based off of CallType
if(isset($dep)){
     $query2=mssql_query("SELECT DISTINCT drop1 FROM drop1 where calltype='$dep' order by  
drop1");
}

// Query to displays Drop2 based off of Drop1
if(isset($d1)){
     $query3=mssql_query("SELECT DISTINCT drop2 FROM drop2 where drop1='$d1' order by  
drop2");
}

// Query to displays Drop3 based off of Drop2
if(isset($d2)){
     $query4=mssql_query("SELECT DISTINCT drop3 FROM drop3 where drop2='$d2' order by  
drop3");
}

// Query to displays Drop4 based off of Drop1
if(isset($d3)){
     $query5=mssql_query("SELECT DISTINCT drop4 FROM drop4 where drop1='$d1' order by  
drop4");
}


echo "&lt;h1&gt; Advanced Search &lt;/h1&gt;";
echo "&lt;a href='index.php'&gt;Back to Main Search&lt;/a&gt; &lt;br /&gt;&lt;br /&gt;";

echo "&lt;form method='post' name='advanced' class='aform' action='form_search.php'&gt;";
?&gt;

&lt;table class="atable"&gt;

     &lt;tr&gt;
          &lt;td&gt;Account:&lt;/td&gt;
          &lt;td colspan="2"&gt;Firm Name:&lt;/td&gt;
          &lt;td&gt;Primary Contact:&lt;/td&gt;
          &lt;td&gt;City&lt;/td&gt;
          &lt;td&gt;State&lt;/td&gt;
     &lt;/tr&gt;
     &lt;tr&gt;
          &lt;td&gt;&lt;input type="text" name="account" maxlength="6" /&gt;&lt;/td&gt;
          &lt;td colspan="2"&gt;&lt;input type="text" name="firmname" maxlength="255" size="44"  
/&gt;&lt;/td&gt;
          &lt;td&gt;&lt;input type="text" name="primarycontact" maxlength="50" /&gt;&lt;/td&gt;
          &lt;td&gt;&lt;input type="text" name="city" maxlength="25" /&gt;&lt;/td&gt;
          &lt;td&gt;&lt;input type="text" name="state" maxlength="3" /&gt;&lt;/td&gt;
     &lt;/tr&gt;
     &lt;tr&gt;
          &lt;td&gt;Main Phone #:&lt;/td&gt;
          &lt;td&gt;Addtional Phone #:&lt;/td&gt;
          &lt;td&gt;Fax #:&lt;/td&gt;
          &lt;td&gt;Technical Rep:&lt;/td&gt;
          &lt;td&gt;Network:&lt;/td&gt;
          &lt;td&gt;Users:&lt;/td&gt;
     &lt;/tr&gt;
     &lt;tr&gt;
          &lt;td&gt;&lt;input type="text" name="mainphone" maxlength="22" /&gt;&lt;/td&gt;
          &lt;td&gt;&lt;input type="text" name="addphone" maxlength="22" /&gt;&lt;/td&gt;
          &lt;td&gt;&lt;input type="text" name="fax" maxlength="22" /&gt;&lt;/td&gt;
          &lt;td&gt;&lt;input type="text" name="techrep" maxlength="25" /&gt;&lt;/td&gt;
          &lt;td&gt;&lt;input type="text" name="network" maxlength="29" /&gt;&lt;/td&gt;
          &lt;td&gt;&lt;input type="text" name="users" maxlength="5" /&gt;&lt;/td&gt;
     &lt;/tr&gt;
     &lt;tr&gt;
          &lt;td colspan="3"&gt;Technical Note:&lt;/td&gt;
          &lt;td&gt;Tax Rep:&lt;/td&gt;
          &lt;td&gt;Center:&lt;/td&gt;
          &lt;td&gt;Password:&lt;/td&gt;         
     &lt;/tr&gt;
     &lt;tr&gt;
          &lt;td colspan="3"&gt;&lt;input type="text" name="technote" maxlength="95" size="68"  
/&gt;&lt;/td&gt;
          &lt;td&gt;&lt;input type="text" name="taxrep" maxlength="20" /&gt;&lt;/td&gt;
          &lt;td&gt;&lt;input type="text" name="center" maxlength="3" /&gt;&lt;/td&gt;
          &lt;td&gt;&lt;input type="text" name="password" maxlength="10" /&gt;&lt;/td&gt;         
     &lt;/tr&gt;
     &lt;tr&gt;
          &lt;td colspan="6"&gt;Account Note:&lt;/td&gt;         
     &lt;/tr&gt;    
     &lt;tr&gt;
          &lt;td colspan="6"&gt;&lt;input type="text" name="technote" maxlength="255" size="140"  
/&gt;&lt;/td&gt;
     &lt;/tr&gt;
     &lt;tr&gt;
          &lt;td colspan="6"&gt;&lt;hr width="800" align="left" /&gt;&lt;/td&gt;
     &lt;/tr&gt;
     &lt;tr&gt;
          &lt;td&gt;Received by:&lt;/td&gt;
          &lt;td&gt;&lt;input type="text" name="recby" /&gt;&lt;/td&gt;
          &lt;td&gt;&lt;input type="text" name="recbydate" /&gt;&lt;/td&gt;
          &lt;td&gt;&lt;input type="text" name="recbytime" /&gt;&lt;/td&gt;
     &lt;/tr&gt;
     &lt;tr&gt;
          &lt;td&gt;Last Mod by:&lt;/td&gt;
          &lt;td&gt;&lt;input type="text" name="modby" /&gt;&lt;/td&gt;
          &lt;td&gt;&lt;input type="text" name="modbydate" /&gt;&lt;/td&gt;
          &lt;td&gt;&lt;input type="text" name="modbytime" /&gt;&lt;/td&gt;
     &lt;/tr&gt;
     &lt;tr&gt;
          &lt;td colspan="6"&gt;&lt;hr width="800" align="left" /&gt;&lt;/td&gt;
     &lt;/tr&gt;
     &lt;tr&gt;
          &lt;td style="text-align: right;"&gt;Call Contact:&lt;/td&gt;
          &lt;td&gt;&lt;input type="text" name="contact" /&gt;&lt;/td&gt;
          &lt;td style="text-align: right;"&gt;Dept:&lt;/td&gt;
          &lt;td&gt;
               &lt;?php
                    // Populate the CallType drop down.
                    echo "&lt;select name='dep'  
onchange=\"depReload(this.form)\"&gt;&lt;option value='one'&gt;Select one&lt;/option&gt;";
                    while($depart = mssql_fetch_array($query1))
                    {
                         if($depart['calltype']==@$dep)
                              {
                                   echo "&lt;option selected  
value='$depart[calltype]'&gt;$depart[calltype]&lt;/option&gt;"."&lt;BR&gt;";
                              } else {
                                   echo   "&lt;option  
value='$depart[calltype]'&gt;$depart[calltype]&lt;/option&gt;";
                              }
                    }
                    echo "&lt;/select&gt;";
               ?&gt;
          &lt;/td&gt;         
          &lt;td style="text-align: right;"&gt;Status:&lt;/td&gt;
          &lt;td&gt;&lt;input type="text" name="status" /&gt;&lt;/td&gt;
     &lt;/tr&gt;
     &lt;tr&gt;
          &lt;td style="text-align: right;"&gt;Received From:&lt;/td&gt;
          &lt;td&gt;&lt;input type="text" name="from" /&gt;&lt;/td&gt;
          &lt;td style="text-align: right;"&gt;Dept:&lt;/td&gt;
          &lt;td&gt;&lt;input type="text" name="dept" /&gt;&lt;/td&gt;
          &lt;td style="text-align: right;"&gt;Reason:&lt;/td&gt;
          &lt;td&gt;&lt;input type="text" name="reason" /&gt;&lt;/td&gt;
     &lt;/tr&gt;
     &lt;tr&gt;
          &lt;td colspan="6"&gt;&lt;hr width="800" align="left" /&gt;&lt;/td&gt;
     &lt;/tr&gt;
     &lt;tr&gt;
          &lt;td colspan="5"&gt;Problem:&lt;/td&gt;
          &lt;td&gt;Solution ID:&lt;/td&gt;
     &lt;/tr&gt;
     &lt;tr&gt;
          &lt;td colspan="5"&gt;&lt;textarea rows="4" cols="99" name="problem"&gt;&lt;/textarea&gt;&lt;/td&gt;
          &lt;td&gt;&lt;input type="text" name="solid" /&gt;&lt;/td&gt;
     &lt;/tr&gt;
     &lt;tr&gt;
          &lt;td colspan="6"&gt;Error Msg:&lt;/td&gt;
     &lt;/tr&gt;
     &lt;tr&gt;
          &lt;td colspan="6"&gt;&lt;input type="text" name="error" size="140" /&gt;&lt;/td&gt;
     &lt;/tr&gt;
     &lt;tr&gt;
          &lt;td&gt;    

               &lt;?php

                    // Populate Drop1
                    echo "&lt;select name='d1'  
onchange=\"d1Reload(this.form)\"&gt;&lt;option value=''&gt;Select one&lt;/option&gt;";
                    while($drop1 = mssql_fetch_array($query2))
                    {
                         if ($drop1['drop1']==@$d1)
                              {
                                   echo   "&lt;option selected  
value='$drop1[drop1]'&gt;$drop1[drop1]&lt;/option&gt;"."&lt;BR /&gt;";
                              } else {
                                   echo "&lt;option  
value='$drop1[drop1]'&gt;$drop1[drop1]&lt;/option&gt;";
                              }
                    }
                    echo "&lt;/select&gt;";
               ?&gt;
          &lt;/td&gt;
          &lt;td&gt;
               &lt;?php
              
                    // Populate Drop2
                    echo "&lt;select name='d2'  
onchange=\"d2Reload(this.form)\"&gt;&lt;option value=''&gt;Select one&lt;/option&gt;";
                    while($drop2 = mssql_fetch_array($query3))
                    {
                         if ($drop2['drop2']==@$d2)
                              {
                                   echo   "&lt;option selected  
value='$drop2[drop2]'&gt;$drop2[drop2]&lt;/option&gt;"."&lt;BR /&gt;";
                              } else {
                                   echo "&lt;option  
value='$drop2[drop2]'&gt;$drop2[drop2]&lt;/option&gt;";
                              }
                    }
                    echo "&lt;/select&gt;";
               ?&gt;
          &lt;/td&gt;
          &lt;td&gt;
               &lt;?php

                    // Populate Drop3
                    echo "&lt;select name='d3'  
onchange=\"d3Reload(this.form)\"&gt;&lt;option value=''&gt;Select one&lt;/option&gt;";
                    while($drop3 = mssql_fetch_array($query4))
                    {
                         if ($drop3['drop3']==@$d3)
                              {
                                   echo   "&lt;option selected  
value='$drop3[drop3]'&gt;$drop3[drop3]&lt;/option&gt;"."&lt;BR /&gt;";
                              } else {
                                   echo "&lt;option  
value='$drop3[drop3]'&gt;$drop3[drop3]&lt;/option&gt;";
                              }
                    }
                    echo "&lt;/select&gt;";
                   
               ?&gt;
          &lt;/td&gt;
          &lt;td colspan="3"&gt;
               &lt;?php

                    // Populate Drop 4
                    echo "&lt;select name='d4'&gt;&lt;option value=''&gt;Select one&lt;/option&gt;";
                    while($drop4 = mssql_fetch_array($query5))
                    {
                         echo "&lt;option  
value='$drop4[drop4]'&gt;$drop4[drop4]&lt;/option&gt;";
                    }
                    echo "&lt;/select&gt;";
               ?&gt;
          &lt;/td&gt;
     &lt;/tr&gt;
     &lt;tr&gt;
          &lt;td colspan="6"&gt;Resolution:&lt;/td&gt;
     &lt;/tr&gt;
     &lt;tr&gt;
          &lt;td colspan="6"&gt;&lt;textarea rows="4" cols="120"  
name="resolution"&gt;&lt;/textarea&gt;&lt;/td&gt;
     &lt;/tr&gt;
     &lt;tr&gt;
          &lt;td&gt;&lt;input type="submit" value="Submit"&gt;&lt;/td&gt;
     &lt;/tr&gt;
    
&lt;/form&gt;

&lt;/table&gt;

&lt;/body&gt;

&lt;/html&gt;
&lt;?php

// close the connection to the db
mssql_close($dbconnect);
?&gt;

</pre>
QuestionHow to 'Test' an IIS Mapping Pin
Jammer22-Oct-09 3:19
Jammer22-Oct-09 3:19 
QuestionPhone calling from webapplication to phone or mobile Pin
Pradeep kumar.V21-Oct-09 22:26
Pradeep kumar.V21-Oct-09 22:26 
AnswerRe: Phone calling from webapplication to phone or mobile Pin
Richard MacCutchan21-Oct-09 23:29
mveRichard MacCutchan21-Oct-09 23:29 
GeneralRe: Phone calling from webapplication to phone or mobile Pin
Pradeep kumar.V21-Oct-09 23:33
Pradeep kumar.V21-Oct-09 23:33 
AnswerRe: Phone calling from webapplication to phone or mobile Pin
Christian Graus22-Oct-09 0:58
protectorChristian Graus22-Oct-09 0:58 
GeneralRe: Phone calling from webapplication to phone or mobile Pin
Pradeep kumar.V22-Oct-09 1:14
Pradeep kumar.V22-Oct-09 1:14 
AnswerRe: Phone calling from webapplication to phone or mobile Pin
David Skelly22-Oct-09 2:16
David Skelly22-Oct-09 2:16 
QuestionExtracting the print-specific CSS properties from a webpage using javaScript Pin
Sharadb.adobe21-Oct-09 21:57
Sharadb.adobe21-Oct-09 21:57 
QuestionSending voice message to Phones in jsp applications Pin
sanuji21-Oct-09 19:01
sanuji21-Oct-09 19:01 
AnswerRe: Sending voice message to Phones in jsp applications Pin
Richard MacCutchan21-Oct-09 23:31
mveRichard MacCutchan21-Oct-09 23:31 
QuestionI need a "Global" Timer... Pin
Loophole321-Oct-09 10:10
Loophole321-Oct-09 10:10 
AnswerRe: I need a "Global" Timer... Pin
thorsman9921-Oct-09 10:54
thorsman9921-Oct-09 10:54 
Questionjavascript on ie8 Pin
Denver Thomas20-Oct-09 21:15
Denver Thomas20-Oct-09 21:15 
AnswerRe: javascript on ie8 Pin
Marc Firth20-Oct-09 23:15
Marc Firth20-Oct-09 23:15 
AnswerRe: javascript on ie8 Pin
Abhijit Jana20-Oct-09 23:18
professionalAbhijit Jana20-Oct-09 23:18 
AnswerRe: javascript on ie8 Pin
Sujith Divakaran19-May-12 3:11
Sujith Divakaran19-May-12 3:11 
QuestionHow can i get we service for sending SMS to Mobile Pin
sanuji20-Oct-09 21:12
sanuji20-Oct-09 21:12 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.