close ad
Install the LAtest Updates to Work with CC 2017 and CC 2018
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

rating

How to pass child list value to next page?

Thread began 7/16/2010 8:39 pm by jeffmg279672 | Last modified 7/21/2010 1:36 pm by Dave Buchholz | 3165 views | 27 replies |

jeffmg279672

How to pass child list value to next page?

Attached zip contains 2 pages - review_add.php which contains the dynamic dropdowns, and add_review.php. I want to be able to make a selection from the parent list, then select from the child list (which all works fine) then pass the selected item from the child list into a text field on the second page when "Submit" is pressed. How can I do this?

Attached Files
Archive.zip
Sign in to reply to this post

Dave BuchholzBeta Tester

Assuming that you are talking about this field

<input name="vetname" type="text" id="vetname" value="<?php echo $row_Child['practicename']; ?>" size="35" />



then you need to filter your recordset by the value posted from the child select list on the previous page.

To do this open up your recordset in Dreamweaver in simple view and from the filter menu choose the id of the recordset then choose Form Variable from the drop down below that and type the name of your form field into the text box, in this case child. Save your changes and try it in a browser. the field vetname should now contain the practisename after the previous page is submitted.

Sign in to reply to this post

jeffmg279672

Many thanks, Dave - that really helped, now working fine, thanks. I now need to get the rest of the fields on that second page inserting to the db and all will be good. Appreciate your assistance.

Sign in to reply to this post

Dave BuchholzBeta Tester

no worries, it really is easy once you know how.

for database inserts you can use the data assist wizard available in the server behaviours panel or the standard dreamweaver insert behaviour, either will get you going.

Sign in to reply to this post

jeffmg279672

I thought I'd give it a whirl and add some insert behaviours as suggested, so created two more recordsets - one for the comments to insert into my reviews table, and the other to insert the reviewers' details into the reviewers table. I then tried testing it locally and I got a fatal error message; a quick search on here indicated that the include call for the DA App Builder file had been inserted too low down the page - it had, so I moved it up under the include call for the Connections file. I ran through the add review procedure using my local server, and the review was added to the db and I was redirected to the "thanks" page as anticipated, so I thought I'd cracked it, so I tried adding a second review, and got this error:
Duplicate entry '0' for key 2

I had no idea what this meant, so I searched on here and decided that it had something to do with the fact that the practice_id number is being added to the table as '0' each time, which is why the second review wasn't added. In other words, the practice_id isn't being passed through, which means that the review isn't linked to the correct practice, so I need to sort that somehow. I presume this is a similar thing to needing to pass the child list value (above)? I've just manually added the correct practice id number to the reviews table, and then added another dummy review and it's inserted that into "reviews" perfectly, but again with the practice_id '0'. Any suggestions how to ensure that the correct practice_id is pulled from the parent/child drop-downs and inserted into the "reviews" table?

Sign in to reply to this post

Dave BuchholzBeta Tester

post your current pages and I'll have a look and see if I can point out where you are going wrong

Sign in to reply to this post

jeffmg279672

Thanks Dave, attached zip contains the page with the drop-downs and the page that's giving me trouble. Wasn't sure if you wanted the db as well so have included that in the zip file.

Attached Files
Archive.zip
Sign in to reply to this post

Dave BuchholzBeta Tester

I'll take a look in the morning for you

Sign in to reply to this post

jeffmg279672

Many thanks, appreciate it.

Sign in to reply to this post

Dave BuchholzBeta Tester

Originally Said By: jeffmg279672
  I ran through the add review procedure using my local server, and the review was added to the db and I was redirected to the "thanks" page as anticipated, so I thought I'd cracked it, so I tried adding a second review, and got this error:
Duplicate entry '0' for key 2  



Jeff,

you are correct the error you are seeing is due to the fact that you are not inserting the practise_id into the table reviews, to solve this issue add a hidden field to your current form like so:

<input type="hidden" id="practiseID" name="practiseID" value="<?php echo $_POST['child'];" />



and then use this form in your database insert.

There is potentially another issue though as you have a field reviewers_id which will never get a value the way you have things set up currently as the standard dreamweaver database insert doesn't have an inbuilt method of creating a variable (session or global) that you can use to get the reviewers id from the insert into the reviewers table. It is possible to hand code a solution to this but I suspect that would not be your preferred option so if you have data assist you can get around this very easily by using the data assist insert server behaviour to do the insert to the reviewers table first with a blank redirect, this creates a session variable for the id of the record created that you can then use in the 2nd insert to the reviews table.

Hope that makes sense.

Sign in to reply to this post
loading

Build websites with a little help from your friends

Your friends over here at WebAssist! These Dreamweaver extensions will assist you in building unlimited, custom websites.

Build websites from already-built web applications

These out-of-the-box solutions provide you proven, tested applications that can be up and running now.  Build a store, a gallery, or a web-based email solution.

Want your website pre-built and hosted?

Close Windowclose

Rate your experience or provide feedback on this page

Account or customer service questions?
Please user our contact form.

Need technical support?
Please visit support to ask a question

Content

rating

Layout

rating

Ease of use

rating

security code refresh image

We do not respond to comments submitted from this page directly, but we do read and analyze any feedback and will use it to help make your experience better in the future.

Close Windowclose

We were unable to retrieve the attached file

Close Windowclose

Attach and remove files

add attachmentAdd attachment
Close Windowclose

Enter the URL you would like to link to in your post

Close Windowclose

This is how you use right click RTF editing

Enable right click RTF editing option allows you to add html markup into your tutorial such as images, bulleted lists, files and more...

-- click to close --

Uploading file...