Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

please help me with this code


sinryder

Recommended Posts

what i am trying to do is in the email box i have the text "enter your email" but when i click on that email box to enter the email this text should disappear. can any one pleae fix this code below

 

Full code

 

<?php
 $info_box_contents = array();
 $info_box_contents[] = array('align' => 'left',
                              'text'  =>  '<form name="newsletter" action="' . tep_href_link(FILENAME_NEWSLETTERS_SUBSCRIBE, '', 'NONSSL') . '" method="post" onSubmit="return verify(this);">' . TEXT_EMAIL . '<br><input type="text" name="Email" value="enter your email"  onfocus="Email.value="" checked size="15" maxlength="35">' . '<input type="submit" name="Submit" value="go">' . '<a href="' . tep_href_link(FILENAME_NEWSLETTERS, '', 'NONSSL') . '"></form>');

 new infoBox($info_box_contents);
?>

 

this is the part that i added in above code

 

onfocus="Email.value=""

 

thankyou

Link to comment
Share on other sites

 

this is the part that i added in above code

 

onfocus="Email.value=""

Could it be mismatched quotes? You have three double quotes and I think you need four. Or maybe use single quotes for the value and double quotes around the onfocus like this?

 

onfocus="Email.value=' ' "

Link to comment
Share on other sites

hey guys thankx for replying. tried both codes but didnt work :(

 

code one

 

'text'  =>  '<form name="newsletter" action="' . tep_href_link(FILENAME_NEWSLETTERS_SUBSCRIBE, '', 'NONSSL') . '" method="post" onSubmit="return verify(this);">' . TEXT_EMAIL . '<br><input type="text" name="Email" value="enter your email"  onfocus="Email.value="" checked size="15" maxlength="35">' . '<input type="submit" name="Submit" value="go">' . '<a href="' . tep_href_link(FILENAME_NEWSLETTERS, '', 'NONSSL') . '"></form>');

 

 

code 2

 

'text'  =>  '<form name="newsletter" action="' . tep_href_link(FILENAME_NEWSLETTERS_SUBSCRIBE, '', 'NONSSL') . '" method="post" onSubmit="return verify(this);">' . TEXT_EMAIL . '<br><input type="text" name="Email" value="enter your email" onfocus="this.value='' ". checked size="15" maxlength="35">' . '<input type="submit" name="Submit" value="go">' . '<a href="' . tep_href_link(FILENAME_NEWSLETTERS, '', 'NONSSL') . '"></form>');

 

even tried the code by removing the . (dot)

this is the error ia m getting

 

Parse error: parse error, unexpected T_CONSTANT_ENCAPSED_STRING, expecting ')' in home/public_html/includes/boxes/newsletter.php on line 90

Link to comment
Share on other sites

hey guys thankx for replying. tried both codes but didnt work :(

 

code one

 

'text' ?=> ?'<form name="newsletter" action="' . tep_href_link(FILENAME_NEWSLETTERS_SUBSCRIBE, '', 'NONSSL') . '" method="post" onSubmit="return verify(this);">' . TEXT_EMAIL . '<br><input type="text" name="Email" value="enter your email" ?onfocus="Email.value="" checked size="15" maxlength="35">' . '<input type="submit" name="Submit" value="go">' . '<a href="' . tep_href_link(FILENAME_NEWSLETTERS, '', 'NONSSL') . '"></form>');

code 2

 

'text' ?=> ?'<form name="newsletter" action="' . tep_href_link(FILENAME_NEWSLETTERS_SUBSCRIBE, '', 'NONSSL') . '" method="post" onSubmit="return verify(this);">' . TEXT_EMAIL . '<br><input type="text" name="Email" value="enter your email" onfocus="this.value='' ". checked size="15" maxlength="35">' . '<input type="submit" name="Submit" value="go">' . '<a href="' . tep_href_link(FILENAME_NEWSLETTERS, '', 'NONSSL') . '"></form>');

 

even tried the code by removing the . (dot)

this is the error ia m getting

 

Parse error: parse error, unexpected T_CONSTANT_ENCAPSED_STRING, expecting ')' in home/public_html/includes/boxes/newsletter.php on line 90

 

escape your single quotes when used within a single quotes bordered string definition like :

 

echo tep_draw_input_field('keywords', $def_keywords, ' onfocus="this.value=\'\'" class="inputBox" size="20" maxlength="40"');

Treasurer MFC

Link to comment
Share on other sites

escape your single quotes when used within a single quotes bordered string definition like :

 

        echo tep_draw_input_field('keywords', $def_keywords, ' onfocus="this.value=\'\'" class="inputBox"  size="20" maxlength="40"');

 

 

hey the error is gone now

but when i click on the box the text doesnt disappear.

 

this is the code i have

 

   'text'  =>  '<form name="newsletter" action="' . tep_href_link(FILENAME_NEWSLETTERS_SUBSCRIBE, '', 'NONSSL') . '" method="post" onSubmit="return verify(this);">' . TEXT_EMAIL . '<br><input type="text" name="Email" value="enter your email"  onfocus="Email.value=\'\"" checked size="15" maxlength="35">' . '<input type="submit" name="Submit" value="go">' . '<a href="' . tep_href_link(FILENAME_NEWSLETTERS, '', 'NONSSL') . '"></form>');

Link to comment
Share on other sites

?onfocus="Email.value=\'\"" 

Boxtel suggested this (spaces added for readability):

onfocus="this.value=\' \' " [single, single, double]

 

But you have

onfocus="Email.value=\' \" " [single, double, double]

 

Don't know if that will make a difference?

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...