Jump to content

"Edit" mode on a form, input variables into form fields.


nafetski

Recommended Posts

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
Share on other sites

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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.