shahid_hussnain Posted February 16, 2011 Share Posted February 16, 2011 hi all here is my code... <?php echo "<input name="."button"." type="."submit"." class="."formbutton"." id="."button"." value="."Submit 1"." />"; ?> problem is, i want to display the value of button is Submit space 1 like "Submit 1", but it is display only "Submit" value and blank space and 1 are not display.. someone help me please.... thanks shahid hussnain Quote Link to comment https://forums.phpfreaks.com/topic/227894-want-space-in-button-value/ Share on other sites More sharing options...
cs.punk Posted February 16, 2011 Share Posted February 16, 2011 It is simple, your code isn't producing any 'quotation marks' (look at the html source). You can escape them: <?php echo "<input name= \"button\" type=\"submit\" value=\"Submit 1\" />"; ?> or use single quotes: <?php echo "<input name= 'button' type='submit' value='Submit 1' />"; ?> Quote Link to comment https://forums.phpfreaks.com/topic/227894-want-space-in-button-value/#findComment-1175115 Share on other sites More sharing options...
Maq Posted February 16, 2011 Share Posted February 16, 2011 Yep. I would use double for the master string (for interpolation purposes) and singles for the attribute values. It's much cleaner and easier to read. Quote Link to comment https://forums.phpfreaks.com/topic/227894-want-space-in-button-value/#findComment-1175119 Share on other sites More sharing options...
shahid_hussnain Posted February 16, 2011 Author Share Posted February 16, 2011 thanks Quote Link to comment https://forums.phpfreaks.com/topic/227894-want-space-in-button-value/#findComment-1175165 Share on other sites More sharing options...
elmas156 Posted February 16, 2011 Share Posted February 16, 2011 how would you use the single quote method in strings that already have single quotes? For example using php and javascript the following way would not work with single quotes because you already have single quotes in the string: echo "<a href=\"popup.php\" onMouseOver=\"window.name='main'\" onClick=\"return popup(this, 'notes')\">Click Here</a>"; Any suggestions? Quote Link to comment https://forums.phpfreaks.com/topic/227894-want-space-in-button-value/#findComment-1175206 Share on other sites More sharing options...
Pikachu2000 Posted February 16, 2011 Share Posted February 16, 2011 Well, then you'd just need to escape the single quotes instead of the double quotes. Quote Link to comment https://forums.phpfreaks.com/topic/227894-want-space-in-button-value/#findComment-1175207 Share on other sites More sharing options...
elmas156 Posted February 16, 2011 Share Posted February 16, 2011 Like this?: echo "<a href='popup.php' onMouseOver='window.name=\'main\'' onClick='return popup(this, \'notes\')'>Click Here</a>"; Is this correct? Or would it be like this?: echo "<a href=\'popup.php\' onMouseOver=\'window.name='main'\' onClick=\'return popup(this, 'notes')\'>Click Here</a>"; Quote Link to comment https://forums.phpfreaks.com/topic/227894-want-space-in-button-value/#findComment-1175242 Share on other sites More sharing options...
Pikachu2000 Posted February 16, 2011 Share Posted February 16, 2011 All you have to do is escape quotes that are the same type as the ones that enclose the string. If it's a single quoted string, any single quotes within it would need to be escaped, likewise for double quotes. Quote Link to comment https://forums.phpfreaks.com/topic/227894-want-space-in-button-value/#findComment-1175246 Share on other sites More sharing options...
elmas156 Posted February 16, 2011 Share Posted February 16, 2011 For this: <a href="pwordhelp.php" onMouseOver="window.name = 'main'" onClick="return pwpopup(this, 'notes')>Click</a> I tried this: echo "<a href='pwordhelp.php' onMouseOver='window.name = \'main\' ' onClick='return pwpopup(this, \'notes\')'>Click</a>"; and this: echo "<a href=\'pwordhelp.php\' onMouseOver=\'window.name = 'main'\' onClick=\'return pwpopup(this, 'notes')\'>Click</a>"; neither of them worked... oh well, guess I'm sticking with double quotes :-) Quote Link to comment https://forums.phpfreaks.com/topic/227894-want-space-in-button-value/#findComment-1175258 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.