0

I have a problem I cant seem to figure out, been looking at it for the last 2 days...

I'm testing so my JS function to copy from form1 to form2 works. And it does, partially.

If you look at the fiddle i've pasted just the necessary bits of code.

  • the input type with name="txtTitle" gets copied from name="hidTitle".
  • the input type with name="txtCount" does not get copied from name="hidCount".

But it should be working since it's basically the same code?

http://jsfiddle.net/mVfZa/7/

4
  • 4
    Your fiddle has errors... there is html in the css field. And I believe some js is missing. Commented Jan 2, 2012 at 19:26
  • 1
    you wanna name your variables more descriptively Commented Jan 2, 2012 at 19:29
  • edited fiddle.. When you press "edit" the song and count input fields should have text in them. In the fiddle, neither has. But on my computer Song-textfield gets the copied info but not the count-textfield Commented Jan 2, 2012 at 19:32
  • Your code has many errors. This issue is occurring due to an error in you copyEditDeleteSongFormData function in line formUpd.fileSoundFileName.value = formDel.hidSoundeFileName.value as it is unable to find that element. If you move this line as the last line of the function your code would work. If you check the errors in error console in any browser you would be able to see all the errors. I have removed some errors in this fiddle. jsfiddle.net/mVfZa/8 Commented Jan 2, 2012 at 19:50

1 Answer 1

1

From your JSFiddle - I think this is a simple mistake. you wrote formDel.hidSoundeFileName instead of formDel.hidSoundFileName

remove the redundant "e" and you should be fine. below is my working example. let me know if I missed something.

<!DOCTYPE html>
<html>
    <head>

        <script type="text/javascript">
            function copyEditDeleteSongFormData(formDel, formUpd) {
                formUpd.txtTitle.value = formDel.hidTitle.value;
                formUpd.fileSoundFileName.value = formDel.hidSoundeFileName.value;
                formUpd.txtCount.value = formDel.hidCount.value;
                formUpd.txtTitle.value = formDel.hidTitle.value;
            }

        </script>
    </head>
    <body>

        <form action="adminSong.php" method="post" name="frmNewUpdateSong" id="fUpdateSong" enctype="multipart/form-data"
              onsubmit="return verifySongDetails(this)" action="adminSong.php">
            <fieldset>
                <legend>New/Edit Songs</legend>
                Artist
                <br>
                <select name="cboArtist" id="ddList">
                    <option value=''></option>
                    <option value='test1'>test1</option>
                    <option value='test2'>test2</option>
                    <option value='test3'>test3</option>
                </select><br>
                Song
                <br>
                <input type="text" name="txtTitle" id="txTitle">
                <br>
                <input type="file" name="fileSoundFileName">
                <br>
                <br>
                Count
                <br>
                <input type="text" name="txtCount">
                <br>
                <input type="submit" name="btnSave" value="Save"/>
                <input type="button" name="btnReset" value="Reset" onclick="resetNewUpdateSongFormData(this.form)"/>
                <br>
                <input type="hidden" name="hidId">
                <input type="hidden" name="hidSoundFileName">
                <br>
            </fieldset>
        </form>
        <br>


        <form action="#" method="post" name="frmEditDeleteSong" id="fDeleteSong" enctype="multipart/form-data">
            <fieldset>
                <legend>Stored Songs</legend>
                id: <br/>
                artistid:<br/>
                title:<br/>
                sound:<br/>
                count:<br/>
                changedate:<br/>
                <input type="hidden" name="hidId">
                <input type="hidden" name="hidArtistId" value="">
                <input type="hidden" name="hidTitle" value="Songtest">
                <input type="hidden" name="hidCount" value="Count123">
                <input type="hidden" name="hidSoundFileName">

                <br>
                <input type="button" name="btnEdit" value="Edit"
                       onclick="copyEditDeleteSongFormData(this.form, frmNewUpdateSong)"/>
                <input type="submit" name="btnDelete" value="Delete" onclick="verifyDeleteOfSong(this.form)"/>
                <br>

            </fieldset>
        </form>
    </body>
</html>
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.