RayWilk
February 14, 2012, 2:44am
1
Hello, my first posting
I have uploaded a script and all is well, except this!
On one web page is a word “Select” when clicked on it should open a list
Yet it is dead, when the mouse is over is it reads: javascript:;
I used :Inspect Element with Firebug" to locate the “Select” corresponding code
<tr class=“c1”>
<td width=“150” align=“right”></td>
<td class=“contentfont” colspan=“2”><span id=“main_category_display”><?=$main_category_display;?></span>
[ <a href=“javascript:;” onClick=“select_category(document.getElementById(‘category_id’).value, ‘main_category_field’, ‘main_’, false, true, ‘wanted’);”><?=GMSG_SELECT;?></a> ]</td>
</tr>
your help greatly appreciated
RayWilk:
On one web page is a word “Select” when clicked on it should open a list
Yet it is dead, when the mouse is over is it reads: javascript:;
Get rid of the “javascript:” part - that’s doing you no favours at all.
The standard way to prevent the default behaviour (of following a link) from occurring when you click on one, is to return false from the event.
<a href="[color="green"]#[/color][s][color="red"]javascript:;[/color][/s]" onClick="select_category(document.getElementById('category_id').value, 'main_category_field', 'main_', false, true, 'wanted');[color="green"] return false;[/color]"><?=GMSG_SELECT;?></a>
A way to further improve on that, is to remove the scripting that is embedded within the HTML content, and move the scripting to the end of the body instead.
This can be easily achieved by giving the link a unique identifier, so that scripting can then more easily access it.
<a id="select" href="#"><?=GMSG_SELECT;?></a>
document.getElementById('select').onclick = function () {
select_category(document.getElementById('category_id').value, 'main_category_field', 'main_', false, true, 'wanted');
return false;
}
RayWilk
February 14, 2012, 8:37am
3
Hello Paul
many thank yous, for you help with this,
ok I did your first suggestion, removed “javascript;” and saved the file
I know have
<a href= onClick=“select_category(document.getElementById(‘category_id’).value, ‘main_category_field’, ‘main_’, false, true);”><?=GMSG_SELECT;?></a></td>
when I go to the site page and hover over “Select” I see
http://trade.comeze.com/onClick= "select_category(document.getElementById(‘category_id’).value,
and clicking on "Select causes my hosters main page to load
what should I do now?
I see you are a Kiwi. I am also, from Auckland
your help greatly appreciated
Ray
RayWilk:
what should I do now?
Let me repeat what I mentioned before.
<a href="[color="green"]#[/color][s][color="red"]javascript:;[/color][/s]" onClick="select_category(document.getElementById('category_id').value, 'main_category_field', 'main_', false, true, 'wanted');[color="green"] return false;[/color]"><?=GMSG_SELECT;?></a>
The green is to be added, the red is to be removed.
RayWilk
February 14, 2012, 2:04pm
5
Hello Paul, thank you.
I have edited the code and saved it as you have here, (copied from your reply)
<a href=“#” onClick=“select_category(document.getElementById(‘category_id’).value, ‘main_category_field’, ‘main_’, false, true, ‘wanted’); return false;”><?=GMSG_SELECT;?></a>
now with my mouse over the “Select” word I see
http://trade.comeze.com/sell_item.php and when clicked nothing happens
your help and patience appreciated
Ray
Oh something happens alright, it’s just that you can’t tell what is happening without looking at the network traffic.
A request gets made from the select_category() function to the following link:
http://trade.comeze.com/ajax_files/select_category.php?category_id=&target_box_id=main_category_field&prefix=main_&reverse_categories=false&click_select=true&listing_type=wanted
But the select_category.php file doesn’t seem to exist.
RayWilk
February 15, 2012, 2:48am
7
Hi Paul,
ok I got a bit confused yet have it sorted correctly now,
there are 2 php page files that have the “Select” word on them: sell_item_details-tpl.php & wanted_manage.tpl.php
in my 1st post I gave you the ‘wanted’ script, then proceeded to paste your new script into the sell php page,
got my head together now
<a href=“#” onClick=“select_category(document.getElementById(‘category_id’).value, ‘main_category_field’, ‘main_’, false, true, ‘wanted’); return false;”><?=GMSG_SELECT;?></a>
the above ‘wanted’ corrected by you saved into the wanted_manage.tpl.php
results mouse hover over gives me: http://trade.comeze.com/wanted_manage.php# and nothing visible happening when clicked
if it would help you to access my site or any files then I am happy to email you the Log In details
thank you again
Ray PS: having problems with sitepoint Log IN, using Firefox, yet says I must re-Log In You do not have permission to perform this action. Please refresh the page and login before trying again.
RayWilk
February 15, 2012, 5:46am
8
Hi Paul
yes I do not have a select_category.php, but I have a category_selector.php
so I renamed the category_selector.php to select_category.php, and loaded in my files on the hoster,
yet no change to the “Select” behavior
I have 2 versions of this script, I looked in both, neither have a select_category.php
all ideas appreciated
Ray
RayWilk
February 15, 2012, 6:21am
9
Hello Paul
I have been looking over the code on my site, and using Inspect Element with Firebug, I looked at the code on another site using the same or similar script ( his is working )
My code: (original code from my script)
[ <a href=“javascript:;” onClick=“select_category(document.getElementById(‘category_id’).value, ‘main_category_field’, ‘main_’, false, true);”><?=GMSG_SELECT;?></a>
]
</td>
His Code: (using Firebug)(this code works correctly when “Select” is clicked)
[
<a onclick=“select_category(document.getElementById(‘category_id’).value, ‘main_category_field’, ‘main_’, false, true, ‘auction’, document.getElementById(‘list_in’).value);” href=“javascript:;”>Select</a>
]
</td>
I tried using his code to replace mine and saving it, yet it did not work,
Ray
As said before, the problem you have now is not directly to do with JavaScript scripting. Your problem is that the required PHP file cannot be found.
RayWilk
February 15, 2012, 8:43am
11
Hi Paul
thank you,
I am doing some research on this missing php file, why? where? how?
I will get back to you when I know more
thank you again for all your help
best wishes
Ray
RayWilk
February 15, 2012, 3:05pm
12
Hi Paul,
ok I have had some good fortune
I was looking at older versions of my script when I saw this,
<a href=“javascript:;” onClick=“openPopup(‘<?=SITE_PATH;?>category_selector.php?cat=category_id&category_id=<?=$item_details[‘category_id’];?>&auction_id=<?=$item_details[‘auction_id’];?>&form_name=ad_create_form’)”>
<?=GMSG_MODIFY;?></a>
with: category_selector.php
so I pasted it in, saved it, and Yes it works, when the “Select” is clicked a Pop Up window opens showing the Categories for selection.
so now could you help me integrate both lines, as the older versions had a Popup, yet now a small in the page window should open,
…
[<a href=“javascript:;” onClick=“openPopup(‘<?=SITE_PATH;?>category_selector.php?cat=category_id&category_id=<?=$item_details[‘category_id’];?>&auction_id=<?=$item_details[‘auction_id’];?>&form_name=ad_create_form’)”>
<?=GMSG_SELECT;?></a>]
…
[<a href=“javascript:;” onClick=“category_selector(document.getElementById(‘addl_category_id’).value, ‘addl_category_field’, ‘addl_’, false, true, ‘wanted’);”><?=GMSG_SELECT;?></a>]
…
your help greatly appreciated
Ray
I don’t think that it is possible to get the second one working until you can resolve the issue with is attempting to access the file called select_category.php
RayWilk
February 15, 2012, 11:27pm
14
Hi Paul,
ok I understand you, I am beginning to understand the php functions
the Pop Up windows works well, so I will stay with that
another question: I would like to increase the text size on my site pages, so they load with a slightly larger size font,
where do I go to adjust this ? and how ?
your help appreciated
RayWilk:
another question: I would like to increase the text size on my site pages, so they load with a slightly larger size font,
where do I go to adjust this ? and how ?
By adjusting the font size in your CSS file.
The people in the CSS forum will be best able to help you with the best way of doing that.
RayWilk
February 15, 2012, 11:34pm
16
Hi Paul,
ok I will look at the CSS file and contact the CSS forum,
a fast reply! just awake here, 6.32 am Bangkok time
RayWilk
February 15, 2012, 11:54pm
17
Hi Paul,
a question:
if I have the line: <?=GMSG_SELECT;?></a>]</td> then only the word “Select” is displayed on the web page.
but if I have the line: <?=GMSG_SELECT_MAIN_CATEGORY;?></a>]</td> then all the words “GMSG_SELECT_MAIN_CATEGORY” is displayed on the web
page.
how to stop the GMSG from displaying?
RayWilk:
if I have the line: <?=GMSG_SELECT;?></a>]</td> then only the word “Select” is displayed on the web page.
but if I have the line: <?=GMSG_SELECT_MAIN_CATEGORY;?></a>]</td> then all the words “GMSG_SELECT_MAIN_CATEGORY” is displayed on the web
page.
how to stop the GMSG from displaying?
That’s PHP which is doing everything with the <?=…?> so you’ll be able to gain the best assistance with that from our PHP forum .
RayWilk
February 16, 2012, 12:43am
19
Hi Paul,
just when I thought I had it sorted, the popup script for the wanted.php works well, but when placed in the sell_details.php does not,
so manage.php page calls the PopUp, yet sell_details.php does not,
could you have a look please, see what you see,
…
<td width=“150” align=“right”></td>
<td class=“contentfont” colspan=“2”><span id=“main_category_display”><?=$main_category_display;?></span>
[<a href="javascript:;" onClick="openPopup('<?=SITE_PATH;?>category_selector.php?cat=category_id&category_id= <?=$item_details['category_id'];?>&auction_id=<?=$item_details['auction_id'];?>&form_name=ad_create_form')">
<?=GMSG_SELECT;?></a>]</td>
</tr>
<tr class="c2" id="main_category_box">
<td></td>
<td id="main_category_field" colspan="2"></td>
</tr>
<tr class="reguser">
<td></td>
<td colspan="2"><?=MSG_CATEGORY_CHANGE_NOTE;?></td> (wanted-working)
…
<td width=“150” align=“right”></td>
<td class=“contentfont”>
<span id=“main_category_display”><?=$main_category_display;?></span>
[ <a href="javascript:;" onClick="openPopup('<?=SITE_PATH;?>category_selector.php?cat=category_id&category_id=<?=$item_details['category_id'];?>&auction_id=<?=$item_details['auction_id'];?>&form_name=ad_create_form')">
<?=GMSG_SELECT;?></a> ]
</td>
</tr>
<tr class=“c2” id=“main_category_box”>
<td></td>
<td id=“main_category_field”></td> (sell-not working)
…
RayWilk
February 16, 2012, 10:52am
20
Hi Paul,
to let you know I solved the problem, by pasting the PopUp Java script code into the sell_details.php
thank you for all your help