lpxxfaintxx Posted February 9, 2009 Share Posted February 9, 2009 Basically, this is what I want to output: <li onselect="this.text.value = 'name'; document.getElementById('schoolID').value = 'id'; "> name </li> I have tried the following: echo '<li onselect="this.text.value = '.$name.'; document.getElementById('schoolID').value ='.$id.' \; ">$name</li>n'; But because of the semicolon, it thinks that the echo ENDS where the semicolon is. Any way to work around that? Thanks Link to comment https://forums.phpfreaks.com/topic/144428-solved-how-do-i-echo-out-a-semicolon/ Share on other sites More sharing options...
genericnumber1 Posted February 9, 2009 Share Posted February 9, 2009 It's not the semicolon, it's your single quotes around schoolID <?php echo '<li onselect="this.text.value = '.$name.'; document.getElementById('schoolID').value ='.$id.'; ">$name</li>n'; see? Try... <?php echo '<li onselect="this.text.value = '.$name.'; document.getElementById(\'schoolID\').value ='.$id.'; ">$name</li>n'; Link to comment https://forums.phpfreaks.com/topic/144428-solved-how-do-i-echo-out-a-semicolon/#findComment-757880 Share on other sites More sharing options...
lpxxfaintxx Posted February 9, 2009 Author Share Posted February 9, 2009 WOW, I feel so stupid now. One thing though... It echos out the literal '$name', not the value stored in $name. I made sure that the correct values were stored in $name and $id. Any idea what's up? while ($row = mysql_fetch_array( $results )) { $id = $row["ID"]; $name = ucwords( strtolower( $row["School_name"] ) ); $name = preg_replace("/(" . $q . ")/i", "<b>$1</b>", $name); echo '<li onselect="this.text.value = '.$name.'; document.getElementById(\'schoolID\').value ='.$id.'; ">$name</li>n'; } Once again, I made sure that values were indeed stored in $name and $id, but currently its echoing out literally "$name" and $id" Thanks! Link to comment https://forums.phpfreaks.com/topic/144428-solved-how-do-i-echo-out-a-semicolon/#findComment-757884 Share on other sites More sharing options...
Philip Posted February 9, 2009 Share Posted February 9, 2009 Replace echo '<li onselect="this.text.value = '.$name.'; document.getElementById(\'schoolID\').value ='.$id.'; ">$name</li>n'; with: echo '<li onselect="this.text.value = '.$name.'; document.getElementById(\'schoolID\').value ='.$id.'; ">'.$name.'</li>n'; You need to take the variable out of the quotes Syntax highlighting will help you in this case. Link to comment https://forums.phpfreaks.com/topic/144428-solved-how-do-i-echo-out-a-semicolon/#findComment-757885 Share on other sites More sharing options...
lpxxfaintxx Posted February 9, 2009 Author Share Posted February 9, 2009 Oh god, I feel like an idiot. Anyways, thank you very much. Link to comment https://forums.phpfreaks.com/topic/144428-solved-how-do-i-echo-out-a-semicolon/#findComment-757890 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.