nafetski Posted December 28, 2007 Share Posted December 28, 2007 Hey everyone, this is one of those situations where I feel like the solution should be very simple, and I'm going about it in a complex way. (Par for the course for me!) The entire page is driven by ajax (definitely more of an experiement than a necessity) but the problem that I'm facing is how do I populate the form fields when I go into edit mode? Text input boxes, and a textarea is easy enough (tho with the textarea I need to remove the <br> and replace them with newlines...when posting a new job I do it with Javascript, I'm pretty confident I can do the reverse. What I need is a way to select the value on the dropdown boxes =) The data that I'm working with is coming form a database, and I have all the form fields saved to a session variable after a job is selected. Hopefully this makes sense? If so, I'd really appreciate a push in the right direction. I'm not sure if the solution to my problem is javascript, or PHP - so if this isn't a PHP question then I appologize! :: Edit :: ignore "POOPLOL" on the input field for jobname. That was me using a JS function to write the data (an experiment) and most of my test variables/experiments are juvenile. I can just use <? php echo $_SESSION['jobname'] ?> in the VALUE field there. -Steve Link to comment https://forums.phpfreaks.com/topic/83467-edit-mode-on-a-form-input-variables-into-form-fields/ Share on other sites More sharing options...
nafetski Posted December 28, 2007 Author Share Posted December 28, 2007 Nevermind, was looking for an overcomplicated solution to a simple problem. <select id='salary'> <option value='<?php echo $_SESSION['salary']; ?>' selected><?php echo $_SESSION['salary']; ?></option> <?php if($_SESSION['salary']!="30k"){ echo "<option value='30k'>$20,000-$30,000</option> } if($_SESSION['salary']!="Negotiable"){ echo "<option value='negotiable'>Negotiable</option>"; } ?> </select> Kind of ugly and not elegant, but it works Link to comment https://forums.phpfreaks.com/topic/83467-edit-mode-on-a-form-input-variables-into-form-fields/#findComment-424665 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.