Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
Minor tweek needed on a current script...
Old 11-01-2007, 11:11 PM Minor tweek needed on a current script...
Average Talker

Posts: 27
Location: CT
Trades: 0
I have a script, (which I did not create) that makes form fields required…

<?

function formatText($inputName,$text) {

if ($_SERVER['REQUEST_METHOD']=="POST") {

if(empty($_POST[$inputName])) {

echo '<span class="redBold">'.$text.'</span>';

$_SESSION['ispassed']=false;

}

else {echo $text;}

}

else echo $text;

}

?>

and then:
<td><? formatText("nmF","First:"); ?></td>

This way works fine, but what I am now trying to do is to put it into a php page that is already echoing an output.

Basically I need to change the html part of the code to this: <td>’.formatText("nmF","First:").’</td>

Problem is, all the text gets echoed at the top of the page, not where I want it, in the <td>.

I’ve tried to change all the “echos” and tried <td>’.$formatText("nmF","First:").’</td> but it throws errors…

Anyone have any ideas on how I can change this script?
DBookatay is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 11-01-2007, 11:38 PM Re: Minor tweek needed on a current script...
mgraphic's Avatar
Truth Seeker

Latest Blog Post:
JAMISONTUNES
Posts: 2,918
Name: Keith Marshall
Location: Connecticut
Trades: 0
In the function, replace echo with return instead. Then in your table cell, use this line to print the data where you intend to have it:

<td><?php echo formatText('nmf', 'First:'); ?></td>
__________________

<mgraphic /> - I don't have a solution but I admire the problem.
mgraphic is offline
Reply With Quote
View Public Profile
 
Old 11-01-2007, 11:41 PM Re: Minor tweek needed on a current script...
Average Talker

Posts: 27
Location: CT
Trades: 0
Quote:
Originally Posted by mgraphic View Post
In the function, replace echo with return instead. Then in your table cell, use this line to print the data where you intend to have it:

<td><?php echo formatText('nmf', 'First:'); ?></td>
I cant do this, because I already have the page echoing the text within a case statement... Meaning
PHP Code:
if(isset($_GET['regType'])); switch($_GET['regType']) {
        case 
'Rep'
            
$regType '
<table>
<tr>
<td valign="top">
<!-- START LEFT -->
<div id="sctnTle">Personal Information</div>
<div id="sctnHldr">
<table>
<tr>
    <td class="frm">'
.formatText("nmF","First") .'</td>
    <td width="10" rowspan="2">&nbsp;</td>
    <td class="frm">M.</td>
    <td width="10" rowspan="2">&nbsp;</td>
    <td class="frm">'
.formatText("nmL","Last") .'</td>
</tr>
<tr>
    <td><input id="input" type="text" name="nmF" size="20" autocomplete="off" value="'
.$POST_nmF.'" /></td>
    <td><input id="char1" type="text" name="nmM" size="1" autocomplete="off" maxlength="1" value="'
.$POST_nmM.'" onKeyup="autotab(this, document.form.nmL)" /></td>
    <td><input id="input" type="text" name="nmL" size="24" autocomplete="off" value="'
.$POST_nmL.'" /></td>
</tr>
<tr><td class="frmPad" colspan="5">'
.formatText("email1","Email Address") .'</td></tr>
    <tr><td  colspan="5"><input id="input" type="text" name="email1" size="40" autocomplete="off" value="'
.$POST_email1.'" /></td></tr>
    <tr><td class="frmPad" colspan="5">'
.formatText("email2","Confirm Email Address") .'</td></tr>
    <tr><td  colspan="5"><input id="input" type="text" name="email2" size="40" autocomplete="off" value="'
.$POST_email2.'" /></td></tr>
</table>'
; break;




DBookatay is offline
Reply With Quote
View Public Profile
 
Old 11-01-2007, 11:47 PM Re: Minor tweek needed on a current script...
mgraphic's Avatar
Truth Seeker

Latest Blog Post:
JAMISONTUNES
Posts: 2,918
Name: Keith Marshall
Location: Connecticut
Trades: 0
OK, I didn't fully understand the bottom part of your original question. Your example will work as it is as long as you replace echo with return within the function.
__________________

<mgraphic /> - I don't have a solution but I admire the problem.
mgraphic is offline
Reply With Quote
View Public Profile
 
Old 11-01-2007, 11:50 PM Re: Minor tweek needed on a current script...
Average Talker

Posts: 27
Location: CT
Trades: 0
Thank you... That solved my problem!
DBookatay is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to Minor tweek needed on a current script...
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.84327 seconds with 12 queries