geatzo Posted April 28 Share Posted April 28 (edited) im getting this error Uncaught ReferenceError: changeAvi is not defined at HTMLSelectElement.onchange I have the script working on another website which works fine ive simply tried to add it to my new website and getting this error I have the script at the top of the page <script src="http://code.jquery.com/jquery-1.10.2.js"></script> <script src="http://code.jquery.com/ui/1.11.2/jquery-ui.js"></script> <script src="http://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/js/bootstrap.min.js"></script> <script src="https://pkmnhelios.com/membersarea_files/button.e7f9415a2e000feaab02c86dd5802747.js.download"></script> <script src="exponential.js"></script> <script type="text/javascript"> function changeAvi(){ var image = document.getElementById('avatarchange'); var dropd = document.getElementById('Avatar'); image.src = dropd.value; }; </script> <br> <input type="submit" name="update" id="button"/> </form> <p> <script type="text/javascript"> function changeAvi(){ var image = document.getElementById('avatarchange'); var dropd = document.getElementById('Avatar'); image.src = dropd.value; }; </script> Then i run some php oose your avatar <br><?php echo '<img id=avatarchange src=images/trainers/000.png />'; ?> <?php echo '<select name="avatar" id="Avatar" onChange="changeAvi()"">'; $sql6=mysqli_query($link,"SELECT * FROM avatars"); while ($row6=mysqli_fetch_array($sql6)){ echo "<option value='".$row6['Image']."'>".$row6['Name']."</option>"; ?> <?php } echo '</select>'; And yes im gonna update it to pdo again this script works on another page inside my site but not a blank page Edited April 28 by geatzo Quote Link to comment https://forums.phpfreaks.com/topic/320172-uncaught-referenceerror/ Share on other sites More sharing options...
Barand Posted April 28 Share Posted April 28 Strange a function that is defined twice should be flagged as "undefined". You have a surfeit of quotes in this line... echo '<select name="avatar" id="Avatar" onChange="changeAvi()"">'; ^ Quote Link to comment https://forums.phpfreaks.com/topic/320172-uncaught-referenceerror/#findComment-1622609 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.