Forum Moderators: coopster

Message Too Old, No Replies

Cannot pre-populate text box

         

Naota

7:37 pm on Feb 2, 2011 (gmt 0)

10+ Year Member



I have an online database that I am working on that uses both SQL, Javascript and PHP.

I have it set up so the user creates a job and puts in the job description, name, etc. After that the database user can send an email to our partners. This email page pre-fills the subject and the message itself with the job name (for subject) and the job description (for the message body). The user also can edit this information and add/edit whatever is there before sending the email.

I have noticed that if I make the job description longer than 1 line, the subject and the body will not pre-populate. If it is 1 line or less then it does pre-populate like it should.

I cannot seem to find out what the problem is. I would think that at least the subject would prepopulate, but it won't either.

I know this is a vague description of the problem and I haven't really shown any code. But does anyone have any suggestions on where I should look? I don't know whether to look at the page where the job is built, or whether i should look at the page where the email is sent from.

This is what the pre-filling code looks like:

{
document.getElementById('subject').value = '<?php echo $rfqinfo['name']; ?> Request For Bid';
text = "\n\n\n\t---Job Information:---\n\nProject: <?php echo $rfqinfo['name']; ?> \n";
text = text + "Description: <?php echo $rfqinfo['description']; ?>\n";
text = text + "Due Date: <?php echo $rfqinfo['dateto']; ?> at <?php echo $rfqinfo['time1']; ?> <?php echo $rfqinfo['time2']; ?>\n";
text = text + "Log into the portal to view the project details.\n\n";
text = text + "http://portal.jcc-va.com/ \n";
document.getElementById("bodytext").value = text;
}

Matthew1980

9:29 pm on Feb 2, 2011 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Hi there Naota,

Welcome to WebmasterWorld!

When setting php to populate JS or anything else for that matter, you need to ensure that the information this there before you can ask it to be echoed, else this will cause errors, or just put null or blank data there.

Really you need to see the page source to see what your actually getting from the variables.

Hope that makes sense to you. JS isn't my forte so I can't validate your code, so there could be something in that, that is not compiling properly.

Typically you would do something like this for putting data into your type of scenario:-

value = <?php echo (isset($someVar) ? $someVar : '');?> though In theory there should be some error handling prior to this so that you wouldn't get the blank being used, as I assume your getting your info from mysql table, so you could have an if/else clause after the query to act as an error handler.

Cheers,
MRb

Naota

3:17 pm on Feb 3, 2011 (gmt 0)

10+ Year Member



Hi Matthew. Thanks for the welcoming and response. The information is echoed without a problem if the description it is echoing is only 1 line in length... if it is more than one line nothing is being echoed.