0

I can get this popup to return the proper value when I type the actual var choice in to the url that exists in the database.

<script type="text/javascript">
var data = $.get("logbookincludes/sqftpoles.php?choice=Front Range", function(data) {
alert("Data Loaded: " + data);
});
</script>

I want the variable to be set by the actual dropdown selector id. I can't seem to get the syntax correct.

var data = $.get("logbookincludes/sqftpoles.php?choice=" +    $("#item36_select_1").val());

Here's the server side php to fill the selector dropdown.

zones.php

 <?php
  include("dbinfo.php");

$query = "SELECT zonename FROM zone";

$result=mysql_query($query);

while ($row=mysql_fetch_array($result)) {
    echo "<option>" . $row{'zonename'} . "</option>";
}
    ?>

Here's the dropdown code.

Zone
 <select name="zone" id="item36_select_1" required data-hint="">
        <option id="item36_0_option" selected value="Front Range">
          Front Range
        </option>
      <? include('logbookincludes/zones.php');?>
      </select>

Here's the sqftpoles.php

   <?php
   include("dbinfo.php");

$choice = mysql_real_escape_string($_GET['choice']);

$query = "SELECT sqftpoles FROM zone WHERE zonename = '$choice'";

$result=mysql_query($query);

    $result2=mysql_query($query2);
while ($row=mysql_fetch_array($result)) {
echo  $row{'sqftpoles'};
}   
   ?>
4
  • 1
    Can you show the server side code Commented Mar 16, 2013 at 12:43
  • I just edited my post to include the server side php and the dropdown code. Makedon's reply returned an empty popup box. I'm only using it for testing. Commented Mar 16, 2013 at 14:26
  • Your sqftpoles.php file doesn't look like it's syntactically correct. Commented Mar 16, 2013 at 15:03
  • The sqftpoles.php returns the proper value in the popup in my original post when I type the actual variable into the url. Commented Mar 16, 2013 at 16:30

1 Answer 1

1

It is example code correct:

$.get('http://stackoverflow.com/questions/tagged/' + 'javascript', function(data){
    alert(data);
})

Here's the code you need. Javascript is a client language

$.get('logbookincludes/sqftpoles.php?choice=' + $("#item36_select_1").val(), function(data){
    alert(data);
});



function updatesub(){
  $.get('logbookincludes/sqftpoles.php?choice=' + $("#item36_select_1").val(), function(data){
   var u = $('#item44_number_1').val()-0,
       q = $('#sqftofzone').val()-0,
       n = data-0;
   $('#item49_number_1').val(u*q*n);
   alert(data);
});
} 
Sign up to request clarification or add additional context in comments.

10 Comments

Thanks for looking. Now I get an empty Popup.
Is it correct url logbookincludes/sqftpoles.php?choice=" + $("#item36_select_1").val() ?
You have to configure your Web server (or 127.0.0.1)? What is the address you type into your browser to see what gives your php code?
Yes,this works. $.get("logbookincludes/sqftpoles.php?choice=Front Range", function(data) { alert("Data Loaded: " + data); Front Range is in the database. I just can't get it to pick it up from the selector. Which shows the proper value. I put it in as the default value for testing.
Unsure of your question but here's the url to see the value show from direct url typing. ericrohloff.com/pesticide/logbookincludes/…
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.