Monday, June 3, 2024
 Popular · Latest · Hot · Upcoming
23
rated 0 times [  27] [ 4]  / answers: 1 / hits: 40473  / 12 Years ago, sat, september 22, 2012, 12:00:00

I am trying to call a javascript function from the onchange attribute of the select tag ! My issue is that I am passing the name attribute of the select to the function which always go null.



<body>


<form action= method=post>
<select name=slct id=name onchange=rohan('measurement_conversion', '<?php echo isset($_POST[slct])?$_POST[slct]:null ?>')>
<option value=yes selected=selected> yes </option>
<option value=nopes> nopes </option>
<option value=may be> May be </option>
<option value=dont know> dont know </option>
</select>
</form>

<div id=abc>
</div>


</body>


And here my javascript function



<script>

function rohan(var1, var2)
{

document.getElementById(abc).innerHTML=var1 + + var2;
}

</script>


It always prints null..
Any help will be appreciated !


More From » php

 Answers
15

HTML:



<body>
<form action= method=post>
<select name=slct id=name onchange=rohan(this.value)>
<option>Select</option>
<option value=yes selected=selected> yes </option>
<option value=nopes> nopes </option>
<option value=may be> May be </option>
<option value=dont know> dont know </option>
</select>
</form>
</body>


JS:



<script>
function rohan(value)
{
//you can get the value from arguments itself
alert(value);
}
</script>

[#82958] Thursday, September 20, 2012, 12 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
maxh

Total Points: 137
Total Questions: 100
Total Answers: 103

Location: Kazakhstan
Member since Mon, Sep 26, 2022
2 Years ago
maxh questions
Tue, May 18, 21, 00:00, 3 Years ago
Mon, Jan 4, 21, 00:00, 3 Years ago
Mon, Nov 23, 20, 00:00, 4 Years ago
;