Moderators: macek, egami, gesf

iLLuZZiOn wrote:i need to get the value of a dropdown menu into a variable, Without submiting the form. I also would like it if it updates instantly
So as soon as someone picks an option from the dropdown menu(lets say 'mymenu') it creates a variable called 'myvar'.
Is it possible, if not is there anyway to convert a javascript or vbscript variable into a php variable?

WiZARD wrote:Hi!
I don't know how about Jay, but I think what if use a form with refresh after change dropdown menu you can di it. :wink:
Jay wrote:WiZARD wrote:Hi!
I don't know how about Jay, but I think what if use a form with refresh after change dropdown menu you can di it. :wink:
Yes, there is that way around it. You can set the drop down menu with javascript to refresh the page with a 'GET' variable, and using this variable you can generate the rest of the page. The reason I didn't mention this was because technically you're still submitting part of a form, although indirectly and I was of the opnion the solution being sought was entirely client side.
Is there any particular reason you need the variables in PHP? You might be able to accomplish the same thing with Javascript which would be better as it would take strain off the server.

WiZARD wrote:see this maby it's be interestin for you:
http://www.devshed.com/Server_Side/PHP/ ... lass/print
SELECT Price FROM cpu WHERE ID=1
iLLuZZiOn wrote:well..
is there any client side language that can access a mySQl database?
iLLuZZiOn wrote:what i am trying to do is make a online quote for a computer, so there is a dropdown menu for each componect in a computer.
i have got the values in the dropdown from the mysql database, the value in the dropdown is the product no.
so when it is submited i can use the value in the dropdown the generate the quote
so to get the price i would use
- Code: Select all
SELECT Price FROM cpu WHERE ID=1
i think that code is right anyway(if not correct me)
but i also want to have a text box that despays the price of the item in the dropdown.
iLLuZZiOn wrote:well..
is there any client side language that can access a mySQl database?
what i am trying to do is make a online quote for a computer, so there is a dropdown menu for each componect in a computer.
i have got the values in the dropdown from the mysql database, the value in the dropdown is the product no.
so when it is submited i can use the value in the dropdown the generate the quote
so to get the price i would use
- Code: Select all
SELECT Price FROM cpu WHERE ID=1
i think that code is right anyway(if not correct me)
but i also want to have a text box that despays the price of the item in the dropdown.


iLLuZZiOn wrote:so is there anyway to do this in a html page
with asp or .jsp
could it be done in flash?
<?php
$item1price = mysql_query("SELECT UnitPrice FROM Item1table Where IDnumber = $dropdown1value", $Connection1) or die(mysql_error());
echo $item1price;
?>
iLLuZZiOn wrote:
- Code: Select all
<?php
$item1price = mysql_query("SELECT UnitPrice FROM Item1table Where IDnumber = $dropdown1value", $Connection1) or die(mysql_error());
echo $item1price;
?>
please correct that statement, becuase it keeps returning Resource id #6
i have no idea what to do, or what i am doing wrong, HELP
<?php
$query = "SELECT UnitPrice FROM Item1table Where IDnumber = ".$_REQUEST['dropdown1value'];
$item1price = mysql_query($query,$Connection1) or die(mysql_error());
echo $item1price;
?><?php
mysql_select_db($database_Connection1, $Connection1);
$querycpu = "SELECT UnitPrice FROM amd_cpu Where ProductID = ".$_REQUEST['amd_cpu'];
$cpuprice = mysql_query($querycpu,$Connection1) or die(mysql_error());
echo $cpuprice;
?>
$result = mysql_query($query);
$first_row = mysql_fetch_array($result);
<form name="ezyquote" method="post" action="print.php">
<select name="amd_cpu" id="amd_cpu">
<?php
do {
?>
<option value="<?php echo $row_amd_cpu['ProductID']?>"><?php echo "($",$row_amd_cpu['UnitPrice'].") ",$row_amd_cpu['Product_Name'] ?></option>
<?php
} while ($row_amd_cpu = mysql_fetch_assoc($amd_cpu));
$rows = mysql_num_rows($amd_cpu);
if($rows > 0) {
mysql_data_seek($amd_cpu, 0);
$row_amd_cpu = mysql_fetch_assoc($amd_cpu);
}
?>
</select>
<form name="ezyquote" method="post" action="print.php">
<select name="amd_cpu" id="amd_cpu">
<?php
do {
?>
<option value="<?php echo $row_amd_cpu['ProductID']?>"><?php echo "($",$row_amd_cpu['UnitPrice'].") ",$row_amd_cpu['Product_Name'] ?></option>
<?php
} while ($row_amd_cpu = mysql_fetch_assoc($amd_cpu));
$rows = mysql_num_rows($amd_cpu);
if($rows > 0) {
mysql_data_seek($amd_cpu, 0);
$row_amd_cpu = mysql_fetch_assoc($amd_cpu);
}
?>
</select><form name="ezyquote" method="post" action="print.php">
<select name="amd_cpu" id="amd_cpu">
<?php
while ($row_amd_cpu = mysql_fetch_assoc($amd_cpu))
{
print ('<option value="' . $row_amd_cpu['ProductID'] . '">' . '($' . $row_amd_cpu['UnitPrice'] . ')' . $row_amd_cpu['Product_Name'] . '</option>');
}
?>
</select> Return to PHP coding => General
Users browsing this forum: No registered users and 5 guests