beta
Hello developer. Login with your existing account. New to Vodafone Developer? Register your account.

+ Login or create an account

0

Hi @all,

i am working on a widget launching a mobile website. The widget exists of two input fields. After clicking the "search"-Button the mobile Website will be launched showing a result list depending on the entered parameters.

My problem is that the javascript function is not called!

Part of my html-code:

<form name="form1">
<input type="text" id="location" name="location"/>
<input type="text" id="search" name="search"/>

<input type="button" value="Suchen" onclick='searchButtonClicked();'/>
</form>

and the js-part:

function searchButtonClicked() {
var location = document.form1.location.value;
var search = document.form1.search.value;
var launchURL = "http://mySite.de/launcher?&location=" + location + "&search=" + search;
widget.openURL(launchURL);
}

Do I have to pay special attention on calling a function in a opera/vodafone widget?

Thanks for any kind of help!
niwi

6 Answers:

0
Hi niwi, I've had a look at your HTML and JavaScript code, since the "form" tag is not really needed and you don't specify an "action" property within it, it might be best to remove it altogether so you're left with the following HTML: <input type="text" id="location" name="location"/> <input type="text" id="search" name="search"/> <input type="button" value="Suchen" onclick="javascript:searchButtonClicked();"/> Moving on to your JavaScript, I'm not sure if the way you are pointing to the input fields is as the DOM would expect it to be, I'm sure using a format like "document.getElementById" will do the trick: function searchButtonClicked() { var location = document.getElementById('location').value; var search = document.getElementById('search').value; var launchURL = "http://mySite.de/launcher?location=" + location + "&search=" + search; widget.openURL(launchURL); } I hope the above will help making your widget work the way that you expect it to. Kind regards, Ernst
0
Hi Dan, so, Ripple is runnig - very cool! Perhaps it helps me to find the bug... Regards niwi
0
Hi Dan, thanks again! Yes, i'm testing on real devices, but also in Firefox. When clicking on the button, firebug is showing the misstake "searchButtonClicked is not defined". And i think that's the problem. But i don't know why. My fellow controlled the html and js-code, but he can't see any misstake... That's an odd thing.... Regards! niwi PS: Thanks for the Ripple link. I am working on it to run my own widget...
0
Hey niwi, How are you testing your application? are you in the emulator, or on a physical device? It could be a your function is actually throwing an exception and you're just not seeing it. Try wrapping the entire inside of your function in a try catch block with an alert to see what happens. Also, the onclick event isn't always all that reliable for JIL, you should try onmousedown. Finally, not to push our product, but it might help you see what's going on. You might want to take a look at Ripple (http://ripple.tinyhippos.com) If an exception is thrown, it'll tell you about it since it runs in the Chrome browser and you have access to the console. Hope this helps, Dan Silivestru.
0
Hi Dan, thanks for the fast answer and the advise. I tested the different notations, but nothing happened. The problem is that the function "searchButtonClicked();" is not called. When clicking on the button nothing happend. I don't know why the function doesn't execute... Best regards niwi
0
Hi niwi, I notice that you're using the lower case widget object. If you're targeting the Vodafone plaform (i.e. JIL 1.2.x) you'll need to use the capitalized Widget object. So the call will look like this: Widget.openURL(launchURL); Now... for opera widgets... you have to use the line you already. (i.e. the lower case widget object). Hope this help. Best regards, Dan Silivestru http://ripple.tinyhippos.com

Login and answer the question