return a value from javascript

Reply

Join Date: Oct 2006
Posts: 4
Reputation: praseena is an unknown quantity at this point 
Solved Threads: 0
praseena praseena is offline Offline
Newbie Poster

To get selected value from combobox

 
0
  #1
Oct 13th, 2006
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
Reply With Quote Quick reply to this message  
Join Date: Sep 2006
Posts: 133
Reputation: sn4rf3r is an unknown quantity at this point 
Solved Threads: 2
sn4rf3r's Avatar
sn4rf3r sn4rf3r is offline Offline
Junior Poster

Re: To get selected value from combobox

 
0
  #2
Oct 13th, 2006
please post the relevant code.
Reply With Quote Quick reply to this message  
Join Date: Dec 2004
Posts: 1,655
Reputation: tgreer is an unknown quantity at this point 
Solved Threads: 35
Team Colleague
tgreer tgreer is offline Offline
Made Her Cry

Re: To get selected value from combobox

 
0
  #3
Oct 13th, 2006
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.
Reply With Quote Quick reply to this message  
Join Date: Oct 2006
Posts: 4
Reputation: praseena is an unknown quantity at this point 
Solved Threads: 0
praseena praseena is offline Offline
Newbie Poster

return a value from javascript

 
0
  #4
Oct 16th, 2006
Is it possible to return a value from java script to php form.if possible how?
Reply With Quote Quick reply to this message  
Join Date: Sep 2006
Posts: 133
Reputation: sn4rf3r is an unknown quantity at this point 
Solved Threads: 2
sn4rf3r's Avatar
sn4rf3r sn4rf3r is offline Offline
Junior Poster

Re: return a value from javascript

 
0
  #5
Oct 16th, 2006
you can have a hidden field in your form, and then set the value using js before it is passed to php.
  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
Reply With Quote Quick reply to this message  
Join Date: Oct 2006
Posts: 4
Reputation: praseena is an unknown quantity at this point 
Solved Threads: 0
praseena praseena is offline Offline
Newbie Poster

Re: return a value from javascript

 
0
  #6
Oct 17th, 2006
<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.
Reply With Quote Quick reply to this message  
Join Date: Sep 2006
Posts: 133
Reputation: sn4rf3r is an unknown quantity at this point 
Solved Threads: 2
sn4rf3r's Avatar
sn4rf3r sn4rf3r is offline Offline
Junior Poster

Re: return a value from javascript

 
0
  #7
Oct 17th, 2006
are you trying to use some AJAX here?
http://www.google.com/search?hl=en&q...=Google+Search
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the PHP Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC