|
|
|||||||||
|
|||||||||
|
|||||||||
| |
|||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
|
|
Free Web 2.0 Code Generator! Generate data entry and reporting .NET Web apps in minutes. Quickly create visually stunning, feature-rich apps that are easy to customize and ready to deploy. Download Now!
|
|
#1
|
|||
|
|||
|
Accessing drop down value from popup...
Hi,
I have a drop down menu (say named 'popname') with a list of values. I have a go button which causes a popup to appear when clicked. My question is, how can i access the value chosen in that drop down menu in the popup? Thanks Neville |
|
#2
|
||||
|
||||
|
You'll have to use Javascript...
This is off the top of my head: Code:
var popList = document.frmName.popName; alert(popList.options[popList.selectedIndex].value);
__________________
Daryl's Homepage | My Blogroll | My Profile | Firefox supporter! DevArticles Forum Moderator "The net is a waste of time, and that's exactly what's right about it." -- William Gibson |
|
#3
|
|||
|
|||
|
Hi,
I tried the code. Let me show you both the source codes. index.html ------------------------------------ Code:
<html>
<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<script langauge="javascript">
function openpopup(varpopurl,varwidth,varheight)
{
var dimensions = 'width=' + varwidth + ',height=' + varheight;
winpops=window.open(varpopurl,"",dimensions)
}
</script>
</head>
<body>
<form name="mainform">
<select name="stores">
<option>a</option>
<option>b</option>
<option>c</option>
</select>
<a href="javascript:openpopup('stores.html',300,300)">GO</a>
</form>
</body>
</html>
------------------------------------ stores.html (the popup page) ------------------------------------ Code:
<html> <head> <title>Stores</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> </head> <body> <script language="javascript"> var popList = document.mainform.stores; alert(popList.options[popList.selectedIndex].value); </script> </body> </html> ------------------------------------ This doesnt seem to work. I basically need to access the value currenty selected in the index.html from the stores.html. Thanks |
|
#4
|
||||
|
||||
|
Try this instead:
var popList = window.opener.document.mainform.stores; |
|
#5
|
||||
|
||||
|
Moved to Javascript
|
|
#6
|
|||
|
|||
|
Accessing value in PHP query...
Hi,
Thanks for the previous help. I am able to access the drop down value however i need to insert that value into a php query, which i am getting stuck with. Code:
$query = mysql_query("SELECT * FROM table WHERE place = 'popList.options[popList.selectedIndex].value'");
This is ofcourse not gonna work, anyway this explains exactly what i wanna do. Thanks in advance! |
|
#7
|
||||
|
||||
|
Ah, well, that changes everything... indeed the code in your post above wont work.
I was afraid that was the real issue =) Both code samples in your original post were named "HTML" so I figured it was strictly Javascript. The solution to this is somewhat easier than what you have already. On your parent page (index.html), I would change the link to be: Code:
<a href="javascript:openpopup('stores.php?s='+popList.optio ns[popList.selectedIndex].value,300,300)">GO</a>
Then on your popup, stores.php, use the line: PHP Code:
Again this is off the top of my head and may require some tweaking. |
|
#8
|
|||
|
|||
|
Accessing value in PHP query...
Try out this one.
You just fire the form and get value posted like below.It may help. <form name="mainform" method="post"> <select name="stores" onChange="document.mainform.submit();"> <option>a</option> <option>b</option> <option>c</option> </select> </form> <? $stores = $_POST["stores"]; ?> Get posted value in button element, <button onClick="openpopup('stores.html?value=<?= $stores ?> ',300,300)">Go</button> |
|
#9
|
|||
|
|||
|
Thanks...
Quote:
Your code works fine. Thanks a lot.. |
|
#10
|
||||
|
||||
|
Perhaps this should move back to PHP. I originally misunderstood the context of the question.
Could a Javascript forum Mod make the move please? |
![]() |
| Viewing: Dev Articles Community Forums > Programming > JavaScript Development > Accessing drop down value from popup... |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|