| | |
return a value from javascript
Please support our PHP advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
![]() |
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)
<script> var hidden=document.getElementById('myfield'); hidden.value='whatever you want' </script> <input type="hidden" id="myfield" name="myfield" value="" />
Last edited by sn4rf3r; Oct 16th, 2006 at 12:25 pm. Reason: changed variable name
•
•
Join Date: Oct 2006
Posts: 4
Reputation:
Solved Threads: 0
<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.
<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.
![]() |
Similar Threads
- setting up an automatic email reply from a form. (Site Layout and Usability)
- .net validation/javascript conflict (ASP.NET)
- Validation with js of two dimensional array (JavaScript / DHTML / AJAX)
- for validation - text box and drop down menu (JavaScript / DHTML / AJAX)
- return a value to php form (PHP)
- changing font type working in IE not in firefox (HTML and CSS)
- Help with .js JAVASCRIPT file!!!!!?!!?!? (JavaScript / DHTML / AJAX)
- a weird Javascript error (JavaScript / DHTML / AJAX)
- Javascript help please (JavaScript / DHTML / AJAX)
Other Threads in the PHP Forum
- Previous Thread: PHP5x,Apache2.2 : Apache not reading php file
- Next Thread: Problems with While Loop
| Thread Tools | Search this Thread |
advanced apache api array basics beginner binary broken cakephp check checkbox class cms code codingproblem combobox cookies cron curl database date datepart display dynamic echo email error file files folder form forms function functions google head href htaccess html image include includingmysecondfileinthechain insert ip javascript job joomla js limit link login mail menu mlm mobile multiple mysql nodes oop outofmemmory paging parse password paypal pdf php problem procedure query radio random recursion remote script search server sessions smarty sms source space sql stored syntax system table traffic tutorial unicode up-to-date update upload url validation validator variable video web webapplications youtube






