Welcome Guest, Not a member yet? Register   Sign In
Easy Javascript Question
#1

[eluser]codelearn[/eluser]
Hi all,

I'm trying to build a similar interface to http://www.metacrawler.com. I have a few search engine queries and I'd like to switch over them with Javascript (to avoid loading them all) and then submit the form.

How do I use javascript, like the one in Metacrawler, to be able to tell which link I should be using? What passe the correct information from the Javascript to the form?ks!

Thanks!
#2

[eluser]majidmx[/eluser]
can you explain a little bit more, what exactly you need to implement ?
Do you want to have the parameters to be set by click [like selecting images,news,... in metacrawler.com] and when you submit the form, all those info be sent ? Am I correct ?

Take care,
MajiD
#3

[eluser]codelearn[/eluser]
Yes. I want to pass 2 different input hidden fields depending on which is selected, and I need to get them from the database.

Thanks much!
#4

[eluser]majidmx[/eluser]
cool,
you can have the hidden fields and access them by getElelemntById. Something like this :

Code:
<form action=<?PHP echo site_url('action/form/'); ?>" >
<input type="hidden" name="search_category" value="" id="search_category"  />
<input type="hidden" name="search_var2" value="" id="search_var2"  />

<a>Images</a>
<a>Videos</a>
<a>News</a>

&lt;input type="text" name="key_word"  /&gt;
&lt;input type="submit" name="submit_form" value="Search" /&gt;

&lt;/form&gt;

Altough it's better to use CI form helper to create the form elements, I just used HTML tags to make it more readable.

Let me know if it solved your problem,

MajiD Fatemian
#5

[eluser]codelearn[/eluser]
Where would the JS go? Apologies -- JS rookie.

Thanks for the help!
#6

[eluser]majidmx[/eluser]
lol, it removed my JS
I try to post it somehow :

Code:
<a>Images</a>
it has an onlcick value which is :
Code:
document.getElementById('search_category').value='images';


Code:
<a>News</a>
it has an onlcick value which is :
Code:
document.getElementById('search_category').value='news';

and so on...
#7

[eluser]codelearn[/eluser]
Hi,

I think that what I am looking for may be the exact opposite. I need to change the two hidden input fields based on the tab selection. Is that possible?
#8

[eluser]codelearn[/eluser]
Bumping. =)
#9

[eluser]majidmx[/eluser]
Hi Boris,
I attached the code to the message, please take a look and let me know if I got it right or not.

Take care,
MajiD
#10

[eluser]codelearn[/eluser]
Majidmx -- I don't think that is what I am looking for.

I have built the same interface as Metacrawler.com, all I need now is as you click on the different links, it updates the form with the appropriate information.

For instance, an Image search, when it is the active tab, will grab the appropriate search query from the database. I just need to know how to dynamically "know" which tab is selected.

I need the hidden field value to change depending on which tab is selected (by grabbing the id of the tab, somehow).

Thanks so much,

-Boris




Theme © iAndrew 2016 - Forum software by © MyBB