TP-Docs
HTML5 Icon HTML5 Icon HTML5 Icon
TP on Social Media

Recent

Welcome to TinyPortal. Please login or sign up.

Members
Stats
  • Total Posts: 195,815
  • Total Topics: 21,284
  • Online today: 82
  • Online ever: 8,223 (February 19, 2025, 04:35:35 AM)
Users Online
  • Users: 0
  • Guests: 42
  • Total: 42

Scriptblock question

Started by reanna6, March 08, 2008, 05:44:24 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

reanna6

Is it possible to callup a scriptbox using a html file?       I have numerous scriptboxes that are similiar, all the same design but shows one thing different, can I put this in just text with links so that it isnt so bundlesome on my page?

IchBin

Split your post reanna6, as your discussion wasn't relevant to the topic.

reanna6

My post was actually about that radio block, I had numberous blocks with one being rock, the other country and so on till I had 9 of them, I was just curious if a code could be written to call up one and link to all 9, instead of 9 different players.

JPDeni

You'd likely have to change it to a php block and create a form. You could start with a default type of music -- say rock -- and then below the player have a drop-down list with all of the options and a button below it to click.

I haven't followed the radio block thing because I don't "do" javascript. I'll take a look at it, though.

JPDeni

Okay. It looks as though the code for generating the player is the same for all types of music, except for the name of the type of music that is in there. There are some numbers that are different, but those appear to be randomly generated.

I can give you an idea for the way to do this, but I can't really give you the exact code because I don't know what the javascript is that you're using. There are too many variables that you can set in the script for me to know what you have. That said, this is what I came up with, to go into a php block:


// list all the types of music you want to include here,
// one on each line.
// Put the default type of music in the first position.
$style[] = 'rock';
$style[] = 'country';
$style[] = 'funk';

///////////////////////////////////////////////////////////////////////////
(isset($_POST['type'])) ? $type = $_POST['type'] : $type = $style[0];

echo **** see notes for this line ****

echo '<form  action="',$action,'" method="post">';
echo '<SELECT NAME="type">';
foreach ($style as $option)
  echo "<OPTION>$option";
echo '</SELECT>';
echo '<INPUT type="submit" name="mysubmit" value="Change my music!">';
echo '</FORM>';


For that one line above that says **** see notes for this line ****, there are several things you need to do.

First, copy the code for one of your radios into a text editor. Let's say you're using the javascript for the "country" radio. Do a search and replace, replacing every instance of double quotes (the " character) with a slash and double quotes ( like \" ).

Next, replace every instance of the word country with $type. For example, there should be a line in your code that starts out looking like


<td><a title="Music tagged country" href="http://www.last.fm/listen/globaltags/country" target="_blank"


After the search-and-replace actions, the above will look like


<td><a title=\"Music tagged $type\" href=\"http://www.last.fm/listen/globaltags/$type\" target=\"_blank\"


Third, add double quotes to the beginning and end of the code. No slashes this time.

Fourth, add a semicolon -- ; -- to the end of the code, after the last double quote.

Fifth, copy the whole thing and paste it into that line above after the word echo. IOW, it will look like this at the beginning:


echo "<style type=\"text/css\">table.lfmWidgetradio_a3c3cdccd144fbbbbd539e24cd047453 td {margin:0 !important;padding:0 !important;border:0


and like this at the end


onclick=\"window.open(this.href + '&amp;resize=0','lfm_popup','height=240,width=234,resizable=yes,scrollbars=yes'); return false;\"></a></td></tr></table></td></tr></table>";


I think this will work. If not, post what you have and tell me what errors you get and I'll see if I can work out what's wrong.

reanna6

I never actually expected a reply. lol. thanks so much JPDeni.. I'll let you know how it turns out, good or bad.. :) thanks again

reanna6

The player is working perfectly, and looks great as well. However, I'm getting some errors now, and it appears in my error log each time I click a channel.
This is my error 8: Undefined variable: action on Line 20 . and this is line 20 of the script echo '<form  action="',$action,'" method="post">';

I've opened the php in dreamweaver and this line of
code is a bright yellow, not sure if that is where the error is...   ';
foreach ($style as $option)
  echo "

Zetan

Change that echo " to: echo '

JPDeni

Well, there's a problem with the $action thing. I wasn't thinking when I copied the code from one other thing I wrote. Sorry.

Add the following somewhere before the form prints out:


  $str = getenv("QUERY_STRING");
  ($str) ? $action = 'index.php?'.$str : $action = 'index.php';


Don't do what ZTN suggested. That line needs double quotes because we're using a variable within the quotes.

Zetan

I realised that a while after posting.. it also ends in ";

This website is proudly hosted on Crocweb Cloud Website Hosting.