943,940 Members | Top Members by Rank

Ad:
  • PHP Discussion Thread
  • Unsolved
  • Views: 7902
  • PHP RSS
Oct 13th, 2006
0

To get selected value from combobox

Expand Post »
How can i get a selected value from combo box ? i used combo.selectedItem.But it is not working.will u pls give me a solution for this
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
praseena is offline Offline
4 posts
since Oct 2006
Oct 13th, 2006
0

Re: To get selected value from combobox

please post the relevant code.
Reputation Points: 10
Solved Threads: 2
Junior Poster
sn4rf3r is offline Offline
133 posts
since Sep 2006
Oct 13th, 2006
0

Re: To get selected value from combobox

HTML doesn't have a "combobox" control. Do you mean a "select" element? If your select element has an id of "x", you would get the value of the selected option:

x.options[x.selectedIndex].value;

Proper terminology is very important in any technical discussion.
Team Colleague
Reputation Points: 227
Solved Threads: 37
Made Her Cry
tgreer is offline Offline
1,697 posts
since Dec 2004
Oct 16th, 2006
0

return a value from javascript

Is it possible to return a value from java script to php form.if possible how?
Reputation Points: 10
Solved Threads: 0
Newbie Poster
praseena is offline Offline
4 posts
since Oct 2006
Oct 16th, 2006
0

Re: return a value from javascript

you can have a hidden field in your form, and then set the value using js before it is passed to php.
PHP Syntax (Toggle Plain Text)
  1. <script>
  2. var hidden=document.getElementById('myfield');
  3. hidden.value='whatever you want'
  4. </script>
  5. <input type="hidden" id="myfield" name="myfield" value="" />
Last edited by sn4rf3r; Oct 16th, 2006 at 12:25 pm. Reason: changed variable name
Reputation Points: 10
Solved Threads: 2
Junior Poster
sn4rf3r is offline Offline
133 posts
since Sep 2006
Oct 17th, 2006
0

Re: return a value from javascript

<body>
<form>
<select name="wcode" onChange="disp(this.form)">
<option value="1">India</option>
<option value="2">Pakistan</option>
<option value="3">Nepal</option>

</select>
<?php
id=$_get['id'];

?>
</form>
</body>

<script>
function disp(frm)
{
var index=frm.wcode.selectedIndex;
var value=frm.wcode.options[index].value;
var item=frm.wcode.options[index].text;
document.action=worksfwdtogovt.php?id=+value;
document.worksfwdtogovt.submit();
}//disp


is this script return the index value to form.if not .pls give correct syntax.
Last edited by praseena; Oct 17th, 2006 at 8:13 am.
Reputation Points: 10
Solved Threads: 0
Newbie Poster
praseena is offline Offline
4 posts
since Oct 2006
Oct 17th, 2006
0

Re: return a value from javascript

are you trying to use some AJAX here?
http://www.google.com/search?hl=en&q...=Google+Search
Reputation Points: 10
Solved Threads: 2
Junior Poster
sn4rf3r is offline Offline
133 posts
since Sep 2006

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in PHP Forum Timeline: PHP5x,Apache2.2 : Apache not reading php file
Next Thread in PHP Forum Timeline: Problems with While Loop





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC