Alvaro
Alvaro

Reputation: 273

1 line. Where to place ID in the link

I have created a separate posting from the large one of before because I think to have isolated the cause of the ID value not getting passed.

I have this link, but there is something not fully correct and no value is sent.

$sOutput .= '"<a href=\"#' ."id=" .addslashes($aRow['id_cruise']) .'\" class=\"flip\">'.addslashes($aRow['from_country']).'</a>",';

That above is the line of interest.

And for curiosity, this is the snippet which receives the value

<script type="text/javascript"> 
$(document).ready(function(){
$('a.flip').live('click',function(){
    $(".panel").slideToggle("slow");
    $('#reviews').load('SendIdToDatabase.php', {idCruise: this.id});
     });
});

</script>

So, the whole scenario is:

A table, rows and links on a column in the rows.

When you click on the link, 2 things should happen.

a) A slide panel is opened

b) and the value is passed to a DIV inside that panel (div which loads the result of a php query which received that ID value)

but like I said, it is expected that only the Link needs to be tweaked

thanks a million

Alvaro

UPDATE

Well, 2 links have been proposed. None of them works.

This link allows the Slide Panel to open but it does not populate the div inside it

$sOutput .= '"<a href=\"#\"' .' id=\"' .addslashes($aRow['id_cruise']) .'\" class=\"flip\">'.addslashes($aRow['from_country']).'</a>",';

And this link seems to do just the opposite. The slide wont open but the div seems to be loading info but I cant see it because the slide, like I said, doesnt open

$sOutput .= '"<a href=\"?id=' .addslashes($aRow['id_cruise']) .'\" id=\"' .addslashes($aRow['id_cruise']) .'\" class=\"flip\">'.addslashes($aRow['from_country']).'</a>",'; 

So, the goal is to get 1 Line that can make both things happening. Open the slide, and populate the div. Of course, using the JQUERY snippet shown

Upvotes: 0

Views: 124

Answers (1)

Jason
Jason

Reputation: 393

Alvaro, It seems to me your link building code is incorrect, ie

$sOutput .= '"<a href=\"#' ."id=" .addslashes($aRow['id_cruise']) .'\" class=\"flip\">'.addslashes($aRow['from_country']).'</a>",';

would echo to the screen

<a href="#id=id_cruise" class="flip">from_country</a>

Your HTML code is wrong, in that you haven't closed off the href and your browser thinks the href is href="#id=id_cruise" instead of your what I think you are trying to do

 $sOutput .= '"<a href=\"#\"' .' id=\"' .addslashes($aRow['id_cruise']) .'\" class=\"flip\">'.addslashes($aRow['from_country']).'</a>",';

which should echo out the correctly formed HTML like this:

<a href="#" id="id_cruise" class="flip">from_country</a>

Now your href & id attributes are correctly formed, jQuery should be able to play nicely.

Cheers, J.

Upvotes: 3

Related Questions