| | |||||
| ||||||||
| Programming PHP, Perl, Ruby on Rails, AJAX, HTML, XHTML, CSS, JavaScript, MySQL and any other coding topics. |
![]() |
| | LinkBack | Thread Tools |
| | THREAD STARTER #1 (permalink) |
| Senior Member Join Date: Oct 2006 Location: http://akshayjain.org
Posts: 2,830
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() | help with html+php hi as always please tell me what am i doing wrong in this? Code: <?php
$list = file('list.txt');
srand((float)microtime() * 1000000);
shuffle($list);
echo '<html><br><select multiple name="crap" size="10">';
foreach ($list as $url) {
$u= "<option value='$url' onclick=\"window.location='$url'\"><b>$url</b></option>";
echo $u;
}
echo '</select>';
?> ????: NamePros.com http://www.namepros.com/programming/328017-help-with-html-php.html this outputs the html code as Code: <html><br><select multiple name="crap" size="10"><option value='http://mail.yahoo.com ' onclick="window.location='http://mail.yahoo.com '"><b>http://mail.yahoo.com </b></option><option value='http://gmail.com ' onclick="window.location='http://gmail.com '"><b>http://gmail.com </b></option><option value='http://yahoo.com ' onclick="window.location='http://yahoo.com '"><b>http://yahoo.com </b></option><option value='http://airb.us.to ' onclick="window.location='http://airb.us.to '"><b>http://airb.us.to </b></option><option value='http://google.com ' onclick="window.location='http://google.com '"><b>http://google.com </b></option></select> therefore i guess the problem is with these arrangement and the new lines that are being created before ' onclick thanks
Last edited by champ_rock; 05-15-2007 at 03:10 AM.
|
| |
| | #2 (permalink) |
| NamePros Regular Join Date: Mar 2005
Posts: 442
![]() ![]() ![]() | those line breaks are breaking the javascript. In your text file don't have the list on new lines or remove line breaks with some php. You could separate each value with a comma and then use implode/explode. Or you could use a string replace to remove line breaks in each url value.
__________________ Please add to my rep points if i was helpful. Thanks. Content management system and online shop software |
| |
| | THREAD STARTER #4 (permalink) |
| Senior Member Join Date: Oct 2006 Location: http://akshayjain.org
Posts: 2,830
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() | thanks guys this trim() works.. also, please tell me how do i open it in a new window on being clicked? one more thing, i am feeling that i am miserable in php. do u think i should even think about continuing it? every script it create has some bug which i have to get sorted here by your help. |
| |
| | #5 (permalink) | ||||||||
| NamePros Regular Join Date: May 2004 Location: NYC
Posts: 236
![]() ![]() ![]() |
????: NamePros.com http://www.namepros.com/showthread.php?t=328017 PHP Code: PHP Code:
I've been doing this for years (decades actually) and I still keep the manual open because I never remember things like the parameter order to str_replace()Like anything, it gets easier over time. But I know how frustrating it is when just starting out with a new language. Besides, it seems like you have a head for this stuff, so don't give up; just keep having fun and asking questions. | ||||||||
| |
| | #6 (permalink) | ||||
| Senior Member Join Date: Aug 2005 Location: East Yorkshire, England
Posts: 2,689
![]() ![]() ![]() ![]() ![]() ![]() ![]() | Keep at it, all languages seem hard at first (though I would rather learn another programming language than do my french gcse, yikes!)
| ||||
| |
| | #8 (permalink) |
| NamePros Member Join Date: Apr 2005
Posts: 117
![]() ![]() | parameter order was an issue until I started using a IDE that did code completion... it pops up the parameter order as soon as I type the first "(" in "str_replace("... gone are the days of memorizing "search,replace,subject" |
| |
| | THREAD STARTER #9 (permalink) |
| Senior Member Join Date: Oct 2006 Location: http://akshayjain.org
Posts: 2,830
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() | Code: window.open('$url'); please check at http://www.champrock.uk.to/demo/list.php |
| |
| | #10 (permalink) | ||||
| NamePros Regular Join Date: May 2004 Location: NYC
Posts: 236
![]() ![]() ![]() |
????: NamePros.com http://www.namepros.com/showthread.php?t=328017 Code: onclick="window.open='http://gmail.com'" Code: onclick="window.open('http://gmail.com');" | ||||
| |
| | THREAD STARTER #11 (permalink) |
| Senior Member Join Date: Oct 2006 Location: http://akshayjain.org
Posts: 2,830
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() | well please check the syntax now.. i think i have rectified it the php code is Code: $u= "<option value='$url' onclick=\"window.open=('$url')\"><b>$url</b></option>"; but it still does not work |
| |