JavaScript Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 



Go Back   Dev Articles Community ForumsProgrammingJavaScript Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old December 19th, 2005, 02:12 PM
nevillemehta nevillemehta is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Oct 2002
Location: India
Posts: 64 nevillemehta User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 10 h 44 m 17 sec
Reputation Power: 17
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

Reply With Quote
  #2  
Old December 20th, 2005, 09:33 AM
MadCowDzz's Avatar
MadCowDzz MadCowDzz is offline
I'm Internet Famous
Dev Articles Frequenter (2500 - 2999 posts)
 
Join Date: Jan 2003
Location: Toronto, Canada
Posts: 2,886 MadCowDzz User rank is Lance Corporal (50 - 100 Reputation Level)MadCowDzz User rank is Lance Corporal (50 - 100 Reputation Level)MadCowDzz User rank is Lance Corporal (50 - 100 Reputation Level) 
Time spent in forums: 1 Week 16 h 19 m 35 sec
Reputation Power: 18
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

Reply With Quote
  #3  
Old December 21st, 2005, 12:13 PM
nevillemehta nevillemehta is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Oct 2002
Location: India
Posts: 64 nevillemehta User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 10 h 44 m 17 sec
Reputation Power: 17
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

Reply With Quote
  #4  
Old December 21st, 2005, 12:50 PM
MadCowDzz's Avatar
MadCowDzz MadCowDzz is offline
I'm Internet Famous
Dev Articles Frequenter (2500 - 2999 posts)
 
Join Date: Jan 2003
Location: Toronto, Canada
Posts: 2,886 MadCowDzz User rank is Lance Corporal (50 - 100 Reputation Level)MadCowDzz User rank is Lance Corporal (50 - 100 Reputation Level)MadCowDzz User rank is Lance Corporal (50 - 100 Reputation Level) 
Time spent in forums: 1 Week 16 h 19 m 35 sec
Reputation Power: 18
Try this instead:
var popList = window.opener.document.mainform.stores;

Reply With Quote
  #5  
Old December 21st, 2005, 12:51 PM
MadCowDzz's Avatar
MadCowDzz MadCowDzz is offline
I'm Internet Famous
Dev Articles Frequenter (2500 - 2999 posts)
 
Join Date: Jan 2003
Location: Toronto, Canada
Posts: 2,886 MadCowDzz User rank is Lance Corporal (50 - 100 Reputation Level)MadCowDzz User rank is Lance Corporal (50 - 100 Reputation Level)MadCowDzz User rank is Lance Corporal (50 - 100 Reputation Level) 
Time spent in forums: 1 Week 16 h 19 m 35 sec
Reputation Power: 18
Moved to Javascript

Reply With Quote
  #6  
Old December 22nd, 2005, 02:35 AM
nevillemehta nevillemehta is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Oct 2002
Location: India
Posts: 64 nevillemehta User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 10 h 44 m 17 sec
Reputation Power: 17
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!

Reply With Quote
  #7  
Old December 22nd, 2005, 09:54 AM
MadCowDzz's Avatar
MadCowDzz MadCowDzz is offline
I'm Internet Famous
Dev Articles Frequenter (2500 - 2999 posts)
 
Join Date: Jan 2003
Location: Toronto, Canada
Posts: 2,886 MadCowDzz User rank is Lance Corporal (50 - 100 Reputation Level)MadCowDzz User rank is Lance Corporal (50 - 100 Reputation Level)MadCowDzz User rank is Lance Corporal (50 - 100 Reputation Level) 
Time spent in forums: 1 Week 16 h 19 m 35 sec
Reputation Power: 18
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:
 $query mysql_query("SELECT * FROM table WHERE place = '{$_GET['s']}'"); 


Again this is off the top of my head and may require some tweaking.

Reply With Quote
  #8  
Old December 22nd, 2005, 11:50 AM
milindkumar milindkumar is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Dec 2005
Posts: 3 milindkumar User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 h 6 m 18 sec
Reputation Power: 0
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>

Reply With Quote
  #9  
Old December 22nd, 2005, 04:25 PM
nevillemehta nevillemehta is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Oct 2002
Location: India
Posts: 64 nevillemehta User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 10 h 44 m 17 sec
Reputation Power: 17
Thanks...

Quote:
Originally Posted by MadCowDzz
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:
 $query mysql_query("SELECT * FROM table WHERE place = '{$_GET['s']}'"); 


Again this is off the top of my head and may require some tweaking.


Your code works fine.

Thanks a lot..

Reply With Quote
  #10  
Old December 23rd, 2005, 08:16 AM
MadCowDzz's Avatar
MadCowDzz MadCowDzz is offline
I'm Internet Famous
Dev Articles Frequenter (2500 - 2999 posts)
 
Join Date: Jan 2003
Location: Toronto, Canada
Posts: 2,886 MadCowDzz User rank is Lance Corporal (50 - 100 Reputation Level)MadCowDzz User rank is Lance Corporal (50 - 100 Reputation Level)MadCowDzz User rank is Lance Corporal (50 - 100 Reputation Level) 
Time spent in forums: 1 Week 16 h 19 m 35 sec
Reputation Power: 18
Perhaps this should move back to PHP. I originally misunderstood the context of the question.
Could a Javascript forum Mod make the move please?

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingJavaScript Development > Accessing drop down value from popup...


Developer Shed Advertisers and Affiliates


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.

© 2003-2018 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap